|
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 |
|
5 #include "Hal.h" |
|
6 #include "mozilla/dom/ScreenOrientation.h" |
|
7 #include "nsIScreenManager.h" |
|
8 #include "nsServiceManagerUtils.h" |
|
9 |
|
10 namespace mozilla { |
|
11 namespace hal_impl { |
|
12 |
|
13 void |
|
14 EnableScreenConfigurationNotifications() |
|
15 { |
|
16 } |
|
17 |
|
18 void |
|
19 DisableScreenConfigurationNotifications() |
|
20 { |
|
21 } |
|
22 |
|
23 void |
|
24 GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration) |
|
25 { |
|
26 nsresult rv; |
|
27 nsCOMPtr<nsIScreenManager> screenMgr = |
|
28 do_GetService("@mozilla.org/gfx/screenmanager;1", &rv); |
|
29 if (NS_FAILED(rv)) { |
|
30 NS_ERROR("Can't find nsIScreenManager!"); |
|
31 return; |
|
32 } |
|
33 |
|
34 nsIntRect rect; |
|
35 int32_t colorDepth, pixelDepth; |
|
36 dom::ScreenOrientation orientation; |
|
37 nsCOMPtr<nsIScreen> screen; |
|
38 |
|
39 screenMgr->GetPrimaryScreen(getter_AddRefs(screen)); |
|
40 screen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height); |
|
41 screen->GetColorDepth(&colorDepth); |
|
42 screen->GetPixelDepth(&pixelDepth); |
|
43 orientation = rect.width >= rect.height |
|
44 ? dom::eScreenOrientation_LandscapePrimary |
|
45 : dom::eScreenOrientation_PortraitPrimary; |
|
46 |
|
47 *aScreenConfiguration = |
|
48 hal::ScreenConfiguration(rect, orientation, colorDepth, pixelDepth); |
|
49 } |
|
50 |
|
51 bool |
|
52 LockScreenOrientation(const dom::ScreenOrientation& aOrientation) |
|
53 { |
|
54 return false; |
|
55 } |
|
56 |
|
57 void |
|
58 UnlockScreenOrientation() |
|
59 { |
|
60 } |
|
61 |
|
62 } // hal_impl |
|
63 } // mozilla |