-
Notifications
You must be signed in to change notification settings - Fork 52
/
WinSystemX11.h
135 lines (117 loc) · 4.13 KB
/
WinSystemX11.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
#ifndef WINDOW_SYSTEM_X11_H
#define WINDOW_SYSTEM_X11_H
#pragma once
/*
* 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/>.
*
*/
#include "system_gl.h"
#if defined(HAS_GLX)
#include <GL/glx.h>
#endif
#if defined(HAS_EGL)
#include <EGL/egl.h>
#endif
#include "windowing/WinSystem.h"
#include "utils/Stopwatch.h"
#include "threads/CriticalSection.h"
#include "settings/lib/ISettingCallback.h"
class IDispResource;
class CWinSystemX11 : public CWinSystemBase, public ISettingCallback
{
public:
CWinSystemX11();
virtual ~CWinSystemX11();
// CWinSystemBase
virtual bool InitWindowSystem();
virtual bool DestroyWindowSystem();
virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction);
virtual bool DestroyWindow();
virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop);
virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays);
virtual void UpdateResolutions();
virtual int GetNumScreens() { return 1; }
virtual int GetCurrentScreen() { return m_nScreen; }
virtual void ShowOSMouse(bool show);
virtual void ResetOSScreensaver();
virtual bool EnableFrameLimiter();
virtual void EnableSystemScreenSaver(bool bEnable);
virtual void NotifyAppActiveChange(bool bActivated);
virtual void NotifyAppFocusChange(bool bGaining);
virtual bool Minimize();
virtual bool Restore() ;
virtual bool Hide();
virtual bool Show(bool raise = true);
virtual void Register(IDispResource *resource);
virtual void Unregister(IDispResource *resource);
virtual bool HasCalibration(const RESOLUTION_INFO &resInfo);
// Local to WinSystemX11 only
Display* GetDisplay() { return m_dpy; }
#if defined(HAS_GLX)
GLXWindow GetWindow() { return m_glWindow; }
GLXContext GetGlxContext() { return m_glContext; }
#endif
#if defined(HAS_EGL)
EGLDisplay GetEGLDisplay() const { return m_eglDisplay;}
EGLSurface GetEGLSurface() const { return m_eglSurface;}
EGLContext GetEGLContext() const { return m_eglContext;}
#endif
void NotifyXRREvent();
void GetConnectedOutputs(std::vector<CStdString> *outputs);
bool IsCurrentOutput(CStdString output);
void RecreateWindow();
int GetCrtc() { return m_crtc; }
protected:
bool RefreshGlxContext(bool force);
void OnLostDevice();
bool SetWindow(int width, int height, bool fullscreen, const std::string &output);
Window m_glWindow, m_mainWindow;
#if defined(HAS_GLX)
GLXContext m_glContext;
#endif
#if defined(HAS_EGL)
EGLDisplay m_eglDisplay;
EGLSurface m_eglSurface;
EGLContext m_eglContext;
EGLConfig m_eglConfig;
#endif
Display* m_dpy;
Cursor m_invisibleCursor;
Pixmap m_icon;
bool m_bIsRotated;
bool m_bWasFullScreenBeforeMinimize;
bool m_minimized;
bool m_bIgnoreNextFocusMessage;
CCriticalSection m_resourceSection;
std::vector<IDispResource*> m_resources;
std::string m_currentOutput;
std::string m_userOutput;
bool m_windowDirty;
bool m_bIsInternalXrr;
bool m_newGlContext;
int m_MouseX, m_MouseY;
int m_crtc;
private:
bool IsSuitableVisual(XVisualInfo *vInfo);
static int XErrorHandler(Display* dpy, XErrorEvent* error);
bool CreateIconPixmap();
bool HasWindowManager();
void UpdateCrtc();
CStopWatch m_screensaverReset;
};
#endif // WINDOW_SYSTEM_H