Merge pull request #26273 from 78andyp/blurayfixes2
[xbmc.git] / xbmc / windowing / win10 / WinSystemWin10.h
blob6b5be4bb4e92fe691ec8e91518e68ec4ea8531a1
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "guilib/DispResource.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/SystemClock.h"
14 #include "windowing/WinSystem.h"
16 #include <vector>
18 #pragma pack(push)
19 #pragma pack(8)
21 /* Controls the way the window appears and behaves. */
22 enum WINDOW_STATE
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
30 static const char* window_state_names[] =
32 "unknown",
33 "true fullscreen",
34 "windowed fullscreen",
35 "windowed",
36 "borderless"
39 /* WINDOW_STATE restricted to fullscreen modes. */
40 enum WINDOW_FULLSCREEN_STATE
42 WINDOW_FULLSCREEN_STATE_FULLSCREEN = WINDOW_STATE_FULLSCREEN,
43 WINDOW_FULLSCREEN_STATE_FULLSCREEN_WINDOW = WINDOW_STATE_FULLSCREEN_WINDOW
46 /* WINDOW_STATE restricted to windowed modes. */
47 enum WINDOW_WINDOW_STATE
49 WINDOW_WINDOW_STATE_WINDOWED = WINDOW_STATE_WINDOWED,
50 WINDOW_WINDOW_STATE_BORDERLESS = WINDOW_STATE_BORDERLESS
53 struct MONITOR_DETAILS
55 // Windows desktop info
56 int ScreenWidth;
57 int ScreenHeight;
58 float RefreshRate;
59 int Bpp;
60 bool Interlaced;
63 class CWinSystemWin10 : public CWinSystemBase
65 public:
66 CWinSystemWin10();
67 virtual ~CWinSystemWin10();
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 ForceFullScreen(const RESOLUTION_INFO& resInfo) override;
75 void UpdateResolutions() override;
76 void NotifyAppFocusChange(bool bGaining) override;
77 void ShowOSMouse(bool show) override;
78 bool HasInertialGestures() override { return true; }//if win32 has touchscreen - it uses the win32 gesture api for inertial scrolling
79 bool Minimize() override;
80 bool Restore() override;
81 bool Hide() override;
82 bool Show(bool raise = true) override;
83 std::string GetClipboardText() override;
84 bool UseLimitedColor() override;
85 float GetGuiSdrPeakLuminance() const override;
86 bool HasSystemSdrPeakLuminance() override;
88 // videosync
89 std::unique_ptr<CVideoSync> GetVideoSync(CVideoReferenceClock* clock) override;
91 bool WindowedMode() const { return m_state != WINDOW_STATE_FULLSCREEN; }
92 bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override;
94 // CWinSystemWin10
95 bool IsAlteringWindow() const { return m_IsAlteringWindow; }
96 void SetAlteringWindow(bool altering) { m_IsAlteringWindow = altering; }
97 bool IsTogglingHDR() const { return false; }
98 void SetTogglingHDR(bool toggling) {}
99 virtual bool DPIChanged(WORD dpi, RECT windowRect) const;
100 bool IsMinimized() const { return m_bMinimized; }
101 void SetMinimized(bool minimized) { m_bMinimized = minimized; }
102 void CacheSystemSdrPeakLuminance();
104 bool CanDoWindowed() override;
106 // winevents override
107 bool MessagePump() override;
109 protected:
110 bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override = 0;
111 virtual void UpdateStates(bool fullScreen);
112 WINDOW_STATE GetState(bool fullScreen) const;
113 virtual void SetDeviceFullScreen(bool fullScreen, RESOLUTION_INFO& res) = 0;
114 virtual void ReleaseBackBuffer() = 0;
115 virtual void CreateBackBuffer() = 0;
116 virtual void ResizeDeviceBuffers() = 0;
117 virtual bool IsStereoEnabled() = 0;
118 virtual void AdjustWindow();
120 virtual void Register(IDispResource *resource);
121 virtual void Unregister(IDispResource *resource);
123 bool ChangeResolution(const RESOLUTION_INFO& res, bool forceChange = false);
124 const MONITOR_DETAILS* GetDefaultMonitor() const;
125 void RestoreDesktopResolution();
126 void GetConnectedDisplays(std::vector<MONITOR_DETAILS>& outputs);
129 \brief Adds a resolution to the list of resolutions if we don't already have it
130 \param res resolution to add.
132 static bool AddResolution(const RESOLUTION_INFO &res);
134 void OnDisplayLost();
135 void OnDisplayReset();
136 void OnDisplayBack();
137 void ResolutionChanged();
139 std::vector<MONITOR_DETAILS> m_displays;
140 bool m_ValidWindowedPosition;
141 bool m_IsAlteringWindow;
143 CCriticalSection m_resourceSection;
144 std::vector<IDispResource*> m_resources;
145 bool m_delayDispReset;
146 XbmcThreads::EndTime<> m_dispResetTimer;
148 WINDOW_STATE m_state; // the state of the window
149 WINDOW_FULLSCREEN_STATE m_fullscreenState; // the state of the window when in fullscreen
150 WINDOW_WINDOW_STATE m_windowState; // the state of the window when in windowed
151 bool m_inFocus;
152 bool m_bMinimized;
153 bool m_bFirstResChange = true;
155 winrt::Windows::UI::Core::CoreWindow m_coreWindow = nullptr;
157 bool m_validSystemSdrPeakLuminance{false};
158 float m_systemSdrPeakLuminance{.0f};
160 DWORD m_uiThreadId{0};
161 HDR_STATUS m_cachedHdrStatus{HDR_STATUS::HDR_UNSUPPORTED};
162 bool m_cachedHasSystemSdrPeakLum{false};
165 #pragma pack(pop)