Bug 867104 - Add a crashtest. r=ehsan
[gecko.git] / widget / os2 / nsScreenManagerOS2.cpp
blob09a49c0f40c9bd2958818a4b5cc3d719285f5657
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsScreenManagerOS2.h"
7 #include "nsScreenOS2.h"
10 nsScreenManagerOS2 :: nsScreenManagerOS2 ( )
12 // nothing else to do. I guess we could cache a bunch of information
13 // here, but we want to ask the device at runtime in case anything
14 // has changed.
18 nsScreenManagerOS2 :: ~nsScreenManagerOS2()
20 // nothing to see here.
24 // addref, release, QI
25 NS_IMPL_ISUPPORTS1(nsScreenManagerOS2, nsIScreenManager)
29 // CreateNewScreenObject
31 // Utility routine. Creates a new screen object from the given device handle
33 // NOTE: For this "single-monitor" impl, we just always return the cached primary
34 // screen. This should change when a multi-monitor impl is done.
36 nsIScreen*
37 nsScreenManagerOS2 :: CreateNewScreenObject ( )
39 nsIScreen* retval = nullptr;
40 if ( !mCachedMainScreen )
41 mCachedMainScreen = new nsScreenOS2 ( );
42 NS_IF_ADDREF(retval = mCachedMainScreen.get());
44 return retval;
49 // ScreenForRect
51 // Returns the screen that contains the rectangle. If the rect overlaps
52 // multiple screens, it picks the screen with the greatest area of intersection.
54 // The coordinates are in pixels (not twips) and in screen coordinates.
56 NS_IMETHODIMP
57 nsScreenManagerOS2 :: ScreenForRect ( int32_t /*inLeft*/, int32_t /*inTop*/, int32_t /*inWidth*/,
58 int32_t /*inHeight*/, nsIScreen **outScreen )
60 GetPrimaryScreen ( outScreen );
61 return NS_OK;
63 } // ScreenForRect
67 // GetPrimaryScreen
69 // The screen with the menubar/taskbar. This shouldn't be needed very
70 // often.
72 NS_IMETHODIMP
73 nsScreenManagerOS2 :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
75 *aPrimaryScreen = CreateNewScreenObject(); // addrefs
76 return NS_OK;
78 } // GetPrimaryScreen
82 // GetNumberOfScreens
84 // Returns how many physical screens are available.
86 NS_IMETHODIMP
87 nsScreenManagerOS2 :: GetNumberOfScreens(uint32_t *aNumberOfScreens)
89 *aNumberOfScreens = 1;
90 return NS_OK;
92 } // GetNumberOfScreens
94 NS_IMETHODIMP
95 nsScreenManagerOS2::GetSystemDefaultScale(float *aDefaultScale)
97 *aDefaultScale = 1.0f;
98 return NS_OK;
101 NS_IMETHODIMP
102 nsScreenManagerOS2 :: ScreenForNativeWidget(void *nativeWidget, nsIScreen **aScreen)
104 *aScreen = CreateNewScreenObject(); // addrefs
105 return NS_OK;