Bug 1849470 - Update in-tree zlib to version 1.3. r=aosmond
[gecko.git] / widget / ScreenManager.h
blob7c40b9fcdb2afb1dfcf191a5dcdb2891a8c5315a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_widget_ScreenManager_h
8 #define mozilla_widget_ScreenManager_h
10 #include "nsIScreenManager.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/UniquePtr.h"
14 #include "mozilla/widget/Screen.h"
15 #include "nsTArray.h"
17 namespace mozilla {
18 namespace dom {
19 class ContentParent;
20 class ScreenDetails;
21 } // namespace dom
22 } // namespace mozilla
24 namespace mozilla::widget {
26 class ScreenManager final : public nsIScreenManager {
27 public:
28 class Helper {
29 public:
30 virtual ~Helper() = default;
33 public:
34 NS_DECL_ISUPPORTS
35 NS_DECL_NSISCREENMANAGER
37 static ScreenManager& GetSingleton();
38 static already_AddRefed<ScreenManager> GetAddRefedSingleton();
40 void SetHelper(UniquePtr<Helper> aHelper);
41 static void Refresh(nsTArray<RefPtr<Screen>>&& aScreens);
42 void Refresh(nsTArray<mozilla::dom::ScreenDetails>&& aScreens);
43 void CopyScreensToRemote(mozilla::dom::ContentParent* aContentParent);
44 already_AddRefed<Screen> GetPrimaryScreen();
45 already_AddRefed<Screen> ScreenForRect(const DesktopIntRect& aRect);
47 const nsTArray<RefPtr<Screen>>& CurrentScreenList() const {
48 return mScreenList;
51 private:
52 ScreenManager();
53 virtual ~ScreenManager();
55 void RefreshInternal(nsTArray<RefPtr<Screen>>&& aScreens);
56 template <class Range>
57 void CopyScreensToRemoteRange(Range aRemoteRange);
58 void CopyScreensToAllRemotesIfIsParent();
60 AutoTArray<RefPtr<Screen>, 4> mScreenList;
61 UniquePtr<Helper> mHelper;
64 } // namespace mozilla::widget
66 #endif // mozilla_widget_ScreenManager_h