/
WinSystemWin32.h
207 lines (175 loc) · 6.82 KB
/
WinSystemWin32.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Copyright (C) 2005-2013 Team XBMC
* http://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_WIN32_H
#define WINDOW_SYSTEM_WIN32_H
#include "guilib/DispResource.h"
#include "threads/CriticalSection.h"
#include "threads/SystemClock.h"
#include "windowing/WinSystem.h"
#include <string>
struct MONITOR_DETAILS
{
// Windows desktop info
int ScreenWidth;
int ScreenHeight;
int RefreshRate;
int Bpp;
bool Interlaced;
HMONITOR hMonitor;
std::wstring MonitorNameW;
std::wstring CardNameW;
std::wstring DeviceNameW;
int ScreenNumber; // XBMC POV, not Windows. Windows primary is XBMC #0, then each secondary is +1.
};
#ifndef WM_GESTURE
#define WM_GESTURE 0x0119
#define WM_GESTURENOTIFY 0x011A
// Gesture Information Flags
#define GF_BEGIN 0x00000001
#define GF_INERTIA 0x00000002
#define GF_END 0x00000004
// Gesture IDs
#define GID_BEGIN 1
#define GID_END 2
#define GID_ZOOM 3
#define GID_PAN 4
#define GID_ROTATE 5
#define GID_TWOFINGERTAP 6
#define GID_PRESSANDTAP 7
#define GID_ROLLOVER GID_PRESSANDTAP
#define GC_ALLGESTURES 0x00000001
// Zoom Gesture Confiration Flags
#define GC_ZOOM 0x00000001
// Pan Gesture Configuration Flags
#define GC_PAN 0x00000001
#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
#define GC_PAN_WITH_GUTTER 0x00000008
#define GC_PAN_WITH_INERTIA 0x00000010
// Rotate Gesture Configuration Flags
#define GC_ROTATE 0x00000001
// Two finger tap configuration flags
#define GC_TWOFINGERTAP 0x00000001
// Press and tap Configuration Flags
#define GC_PRESSANDTAP 0x00000001
#define GC_ROLLOVER GC_PRESSANDTAP
typedef struct _GESTUREINFO {
UINT cbSize;
DWORD dwFlags;
DWORD dwID;
HWND hwndTarget;
POINTS ptsLocation;
DWORD dwInstanceID;
DWORD dwSequenceID;
ULONGLONG ullArguments;
UINT cbExtraArgs;
}GESTUREINFO, *PGESTUREINFO;
// GESTURECONFIG struct defintion
typedef struct tagGESTURECONFIG {
DWORD dwID; // gesture ID
DWORD dwWant; // settings related to gesture ID that are to be turned on
DWORD dwBlock; // settings related to gesture ID that are to be turned off
} GESTURECONFIG, *PGESTURECONFIG;
/*
* Gesture notification structure
* - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
* - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
* in progress and a gesture will be generated if one is recognized under the
* current gesture settings.
*/
typedef struct tagGESTURENOTIFYSTRUCT {
UINT cbSize; // size, in bytes, of this structure
DWORD dwFlags; // unused
HWND hwndTarget; // handle to window targeted by the gesture
POINTS ptsLocation; // starting location
DWORD dwInstanceID; // internally used
} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
DECLARE_HANDLE(HGESTUREINFO);
#endif
class CWinSystemWin32 : public CWinSystemBase
{
public:
CWinSystemWin32();
virtual ~CWinSystemWin32();
// CWinSystemBase
virtual bool InitWindowSystem();
virtual bool DestroyWindowSystem();
virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction);
virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop);
virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays);
virtual bool SetFullScreenEx(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays, bool forceResChange);
virtual void UpdateResolutions();
virtual bool CenterWindow();
virtual void NotifyAppFocusChange(bool bGaining);
virtual int GetNumScreens() { return m_MonitorsInfo.size(); };
virtual int GetCurrentScreen();
virtual void ShowOSMouse(bool show);
virtual bool WindowedMode() { return true; }
virtual bool HasInertialGestures(){ return true; }//if win32 has touchscreen - it uses the win32 gesture api for inertial scrolling
virtual bool Minimize();
virtual bool Restore();
virtual bool Hide();
virtual bool Show(bool raise = true);
// CWinSystemWin32
HWND GetHwnd() { return m_hWnd; }
bool IsAlteringWindow() { return m_IsAlteringWindow; }
// touchscreen support
typedef BOOL (WINAPI *pGetGestureInfo)(HGESTUREINFO, PGESTUREINFO);
typedef BOOL (WINAPI *pSetGestureConfig)(HWND, DWORD, UINT, PGESTURECONFIG, UINT);
typedef BOOL (WINAPI *pCloseGestureInfoHandle)(HGESTUREINFO);
pGetGestureInfo PtrGetGestureInfo;
pSetGestureConfig PtrSetGestureConfig;
pCloseGestureInfoHandle PtrCloseGestureInfoHandle;
protected:
bool ChangeResolution(RESOLUTION_INFO res, bool forceChange = false);
virtual bool ResizeInternal(bool forceRefresh = false);
virtual bool UpdateResolutionsInternal();
virtual bool CreateBlankWindows();
virtual bool BlankNonActiveMonitors(bool bBlank);
const MONITOR_DETAILS* GetMonitor(int screen) const;
void RestoreDesktopResolution(int screen);
RECT ScreenRect(int screen);
/*!
\brief Adds a resolution to the list of resolutions if we don't already have it
\param res resolution to add.
*/
void AddResolution(const RESOLUTION_INFO &res);
virtual void Register(IDispResource *resource);
virtual void Unregister(IDispResource *resource);
void OnDisplayLost();
virtual void ResolutionChanged();
HWND m_hWnd;
std::vector<HWND> m_hBlankWindows;
HDC m_hDC;
HINSTANCE m_hInstance;
HICON m_hIcon;
std::vector<MONITOR_DETAILS> m_MonitorsInfo;
int m_nPrimary;
bool m_ValidWindowedPosition;
bool m_IsAlteringWindow;
CCriticalSection m_resourceSection;
std::vector<IDispResource*> m_resources;
bool m_delayDispReset;
XbmcThreads::EndTime m_dispResetTimer;
};
extern HWND g_hWnd;
#endif // WINDOW_SYSTEM_H