| 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 |
|
| 53 |
struct MONITOR_DETAILS |
| 54 |
{ |
| 55 |
// Windows desktop info |
| 56 |
int ScreenWidth; |
| 57 |
int ScreenHeight; |
| 58 |
float RefreshRate; |
| 59 |
int Bpp; |
| 60 |
bool Interlaced; |
| 61 |
}; |
| 62 |
|
| 63 |
class CWinSystemWin10 : public CWinSystemBase |
| 64 |
{ |
| 65 |
public: |
| 66 |
CWinSystemWin10(); |
| 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 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; |
| 87 |
|
| 88 |
// videosync |
| 89 |
std::unique_ptr<CVideoSync> GetVideoSync(CVideoReferenceClock* clock) override; |
| 90 |
|
| 91 |
bool WindowedMode() const { return m_state != WINDOW_STATE_FULLSCREEN; } |
| 92 |
bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override; |
| 93 |
|
| 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(); |
| 103 |
|
| 104 |
bool CanDoWindowed() override; |
| 105 |
|
| 106 |
// winevents override |
| 107 |
bool MessagePump() override; |
| 108 |
|
| 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(); |
| 119 |
|
| 120 |
virtual void Register(IDispResource *resource); |
| 121 |
virtual void Unregister(IDispResource *resource); |
| 122 |
|
| 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); |
| 127 |
|
| 128 |
/*! |
| 129 |
\brief Adds a resolution to the list of resolutions if we don't already have it |
| 130 |
\param res resolution to add. |
| 131 |
*/ |
| 132 |
static bool AddResolution(const RESOLUTION_INFO &res); |
| 133 |
|
| 134 |
void OnDisplayLost(); |
| 135 |
void OnDisplayReset(); |
| 136 |
void OnDisplayBack(); |
| 137 |
void ResolutionChanged(); |
| 138 |
|
| 139 |
std::vector<MONITOR_DETAILS> m_displays; |
| 140 |
bool m_ValidWindowedPosition; |
| 141 |
bool m_IsAlteringWindow; |
| 142 |
|
| 143 |
CCriticalSection m_resourceSection; |
| 144 |
std::vector<IDispResource*> m_resources; |
| 145 |
bool m_delayDispReset; |
| 146 |
XbmcThreads::EndTime<> m_dispResetTimer; |
| 147 |
|
| 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; |
| 154 |
|
| 155 |
winrt::Windows::UI::Core::CoreWindow m_coreWindow = nullptr; |
| 156 |
|
| 157 |
bool m_validSystemSdrPeakLuminance{false}; |
| 158 |
float m_systemSdrPeakLuminance{.0f}; |
| 159 |
|
| 160 |
DWORD m_uiThreadId{0}; |
| 161 |
HDR_STATUS m_cachedHdrStatus{HDR_STATUS::HDR_UNSUPPORTED}; |
| 162 |
bool m_cachedHasSystemSdrPeakLum{false}; |
| 163 |
}; |
| 164 |
|
| 165 |
#pragma pack(pop) |
| 166 |
|