xbmc
WinSystemWin10.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "guilib/DispResource.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/SystemClock.h"
14 #include "windowing/WinSystem.h"
15 
16 #include <vector>
17 
18 #pragma pack(push)
19 #pragma pack(8)
20 
21 /* Controls the way the window appears and behaves. */
22 enum WINDOW_STATE
23 {
24  WINDOW_STATE_FULLSCREEN = 1, // Exclusive fullscreen
25  WINDOW_STATE_FULLSCREEN_WINDOW, // Non-exclusive fullscreen window
26  WINDOW_STATE_WINDOWED, //Movable window with border
27  WINDOW_STATE_BORDERLESS //Non-movable window with no border
28 };
29 
30 static const char* window_state_names[] =
31 {
32  "unknown",
33  "true fullscreen",
34  "windowed fullscreen",
35  "windowed",
36  "borderless"
37 };
38 
39 /* WINDOW_STATE restricted to fullscreen modes. */
40 enum WINDOW_FULLSCREEN_STATE
41 {
42  WINDOW_FULLSCREEN_STATE_FULLSCREEN = WINDOW_STATE_FULLSCREEN,
43  WINDOW_FULLSCREEN_STATE_FULLSCREEN_WINDOW = WINDOW_STATE_FULLSCREEN_WINDOW
44 };
45 
46 /* WINDOW_STATE restricted to windowed modes. */
47 enum WINDOW_WINDOW_STATE
48 {
49  WINDOW_WINDOW_STATE_WINDOWED = WINDOW_STATE_WINDOWED,
50  WINDOW_WINDOW_STATE_BORDERLESS = WINDOW_STATE_BORDERLESS
51 };
52 
54 {
55  // Windows desktop info
56  int ScreenWidth;
57  int ScreenHeight;
58  float RefreshRate;
59  int Bpp;
60  bool Interlaced;
61 };
62 
64 {
65 public:
67  virtual ~CWinSystemWin10();
68 
69  // CWinSystemBase overrides
70  bool InitWindowSystem() override;
71  bool DestroyWindowSystem() override;
72  bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override;
73  void FinishWindowResize(int newWidth, int newHeight) override;
74  void UpdateResolutions() override;
75  void NotifyAppFocusChange(bool bGaining) override;
76  void ShowOSMouse(bool show) override;
77  bool HasInertialGestures() override { return true; }//if win32 has touchscreen - it uses the win32 gesture api for inertial scrolling
78  bool Minimize() override;
79  bool Restore() override;
80  bool Hide() override;
81  bool Show(bool raise = true) override;
82  std::string GetClipboardText() override;
83  bool UseLimitedColor() override;
84 
85  // videosync
86  std::unique_ptr<CVideoSync> GetVideoSync(void *clock) override;
87 
88  bool WindowedMode() const { return m_state != WINDOW_STATE_FULLSCREEN; }
89  bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override;
90 
91  // CWinSystemWin10
92  bool IsAlteringWindow() const { return m_IsAlteringWindow; }
93  void SetAlteringWindow(bool altering) { m_IsAlteringWindow = altering; }
94  bool IsTogglingHDR() const { return false; }
95  void SetTogglingHDR(bool toggling) {}
96  virtual bool DPIChanged(WORD dpi, RECT windowRect) const;
97  bool IsMinimized() const { return m_bMinimized; }
98  void SetMinimized(bool minimized) { m_bMinimized = minimized; }
99  int GetGuiSdrPeakLuminance() const;
100 
101  bool CanDoWindowed() override;
102 
103  // winevents override
104  bool MessagePump() override;
105 
106 protected:
107  bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override = 0;
108  virtual void UpdateStates(bool fullScreen);
109  WINDOW_STATE GetState(bool fullScreen) const;
110  virtual void SetDeviceFullScreen(bool fullScreen, RESOLUTION_INFO& res) = 0;
111  virtual void ReleaseBackBuffer() = 0;
112  virtual void CreateBackBuffer() = 0;
113  virtual void ResizeDeviceBuffers() = 0;
114  virtual bool IsStereoEnabled() = 0;
115  virtual void AdjustWindow();
116 
117  virtual void Register(IDispResource *resource);
118  virtual void Unregister(IDispResource *resource);
119 
120  bool ChangeResolution(const RESOLUTION_INFO& res, bool forceChange = false);
121  const MONITOR_DETAILS* GetDefaultMonitor() const;
122  void RestoreDesktopResolution();
123  void GetConnectedDisplays(std::vector<MONITOR_DETAILS>& outputs);
124 
129  static bool AddResolution(const RESOLUTION_INFO &res);
130 
131  void OnDisplayLost();
132  void OnDisplayReset();
133  void OnDisplayBack();
134  void ResolutionChanged();
135 
136  std::vector<MONITOR_DETAILS> m_displays;
137  bool m_ValidWindowedPosition;
138  bool m_IsAlteringWindow;
139 
140  CCriticalSection m_resourceSection;
141  std::vector<IDispResource*> m_resources;
142  bool m_delayDispReset;
143  XbmcThreads::EndTime<> m_dispResetTimer;
144 
145  WINDOW_STATE m_state; // the state of the window
146  WINDOW_FULLSCREEN_STATE m_fullscreenState; // the state of the window when in fullscreen
147  WINDOW_WINDOW_STATE m_windowState; // the state of the window when in windowed
148  bool m_inFocus;
149  bool m_bMinimized;
150  bool m_bFirstResChange = true;
151 
152  winrt::Windows::UI::Core::CoreWindow m_coreWindow = nullptr;
153 };
154 
155 #pragma pack(pop)
156 
Definition: WinSystemWin10.h:53
Definition: WinSystem.h:44
Definition: SystemClock.h:31
Definition: DispResource.h:14
Provide info of a resolution.
Definition: Resolution.h:66
Definition: WinSystemWin10.h:63