/
WinSystem.h
122 lines (106 loc) · 3.95 KB
/
WinSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (C) 2005-2012 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#ifndef WINDOW_SYSTEM_BASE_H
#define WINDOW_SYSTEM_BASE_H
#include "WinEvents.h"
#include "guilib/Resolution.h"
#include <vector>
typedef enum _WindowSystemType
{
WINDOW_SYSTEM_WIN32,
WINDOW_SYSTEM_OSX,
WINDOW_SYSTEM_IOS,
WINDOW_SYSTEM_X11,
WINDOW_SYSTEM_SDL,
WINDOW_SYSTEM_EGL,
WINDOW_SYSTEM_ANDROID
} WindowSystemType;
struct RESOLUTION_WHR
{
int width;
int height;
int ResInfo_Index;
};
struct REFRESHRATE
{
float RefreshRate;
bool Interlaced;
int ResInfo_Index;
};
class CWinSystemBase
{
public:
CWinSystemBase();
virtual ~CWinSystemBase();
WindowSystemType GetWinSystem() { return m_eWindowSystem; }
// windowing interfaces
virtual bool InitWindowSystem();
virtual bool DestroyWindowSystem(){ return false; }
virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) = 0;
virtual bool DestroyWindow(){ return false; }
virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) = 0;
virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) = 0;
virtual bool MoveWindow(int topLeft, int topRight){return false;}
virtual bool CenterWindow(){return false;}
virtual bool IsCreated(){ return m_bWindowCreated; }
virtual void NotifyAppFocusChange(bool bGaining) {}
virtual void NotifyAppActiveChange(bool bActivated) {}
virtual void ShowOSMouse(bool show) {};
virtual bool HasCursor(){ return true; }
//some plattforms have api for gesture inertial scrolling - default to false and use the InertialScrollingHandler
virtual bool HasInertialGestures(){ return false; }
virtual bool Minimize() { return false; }
virtual bool Restore() { return false; }
virtual bool Hide() { return false; }
virtual bool Show(bool raise = true) { return false; }
// notifications
virtual void OnMove(int x, int y) {}
// OS System screensaver
virtual void EnableSystemScreenSaver(bool bEnable) {};
virtual bool IsSystemScreenSaverEnabled() {return false;}
virtual void ResetOSScreensaver() {};
virtual bool EnableFrameLimiter() {return false;};
// resolution interfaces
unsigned int GetWidth() { return m_nWidth; }
unsigned int GetHeight() { return m_nHeight; }
int GetLeft() { return m_nLeft; }
int GetTop() { return m_nTop; }
virtual int GetNumScreens() { return 0; }
virtual int GetCurrentScreen() { return 0; }
bool IsFullScreen() { return m_bFullScreen; }
virtual void UpdateResolutions();
void SetWindowResolution(int width, int height);
int DesktopResolution(int screen);
std::vector<RESOLUTION_WHR> ScreenResolutions(int screen);
std::vector<REFRESHRATE> RefreshRates(int screen, int width, int height);
REFRESHRATE DefaultRefreshRate(int screen, std::vector<REFRESHRATE> rates);
protected:
void UpdateDesktopResolution(RESOLUTION_INFO& newRes, int screen, int width, int height, float refreshRate, uint32_t dwFlags = 0);
WindowSystemType m_eWindowSystem;
int m_nWidth;
int m_nHeight;
int m_nTop;
int m_nLeft;
bool m_bWindowCreated;
bool m_bFullScreen;
bool m_bBlankOtherDisplay;
float m_fRefreshRate;
};
#endif // WINDOW_SYSTEM_H