forked from ValveSoftware/steamos-compositor
-
Notifications
You must be signed in to change notification settings - Fork 183
/
xwayland_ctx.hpp
271 lines (222 loc) · 6.59 KB
/
xwayland_ctx.hpp
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#pragma once
#include "backend.h"
#include "waitable.h"
#include <mutex>
#include <memory>
#include <vector>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrender.h>
#include <X11/extensions/XRes.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/xf86vmode.h>
class gamescope_xwayland_server_t;
struct ignore;
struct steamcompmgr_win_t;
class MouseCursor;
extern LogScope xwm_log;
struct focus_t
{
steamcompmgr_win_t *focusWindow;
steamcompmgr_win_t *inputFocusWindow;
uint32_t inputFocusMode;
steamcompmgr_win_t *overlayWindow;
steamcompmgr_win_t *externalOverlayWindow;
steamcompmgr_win_t *notificationWindow;
steamcompmgr_win_t *overrideWindow;
bool outdatedInteractiveFocus;
bool bResetToCorner = false;
bool bResetToCenter = false;
uint64_t ulCurrentFocusSerial = UINT64_MAX;
bool IsDirty();
};
struct CommitDoneEntry_t
{
uint64_t winSeq;
uint64_t commitID;
uint64_t desiredPresentTime;
uint64_t earliestPresentTime;
uint64_t earliestLatchTime;
bool fifo;
};
struct CommitDoneList_t
{
std::mutex listCommitsDoneLock;
std::vector< CommitDoneEntry_t > listCommitsDone;
};
struct xwayland_ctx_t final : public gamescope::IWaitable
{
gamescope_xwayland_server_t *xwayland_server;
Display *dpy;
// Not used for most of steamcompmgr thread. Just to sync whenever
// wlserver wants it.
std::mutex list_mutex;
steamcompmgr_win_t *list;
int scr;
Window root;
XserverRegion allDamage;
bool clipChanged;
int root_height, root_width;
int xfixes_event, xfixes_error;
int damage_event, damage_error;
int composite_event, composite_error;
int render_event, render_error;
int xshape_event, xshape_error;
int composite_opcode;
int xinput_opcode, xinput_event, xinput_error;
Window ourWindow;
focus_t focus;
Window currentKeyboardFocusWindow;
Window focusControlWindow;
std::unique_ptr<MouseCursor> cursor;
CommitDoneList_t doneCommits;
double accum_x = 0.0;
double accum_y = 0.0;
bool force_windows_fullscreen = false;
std::vector< steamcompmgr_win_t* > GetPossibleFocusWindows();
void DetermineAndApplyFocus( const std::vector< steamcompmgr_win_t* > &vecPossibleFocusWindows );
struct {
Atom steamAtom;
Atom gameAtom;
Atom overlayAtom;
Atom externalOverlayAtom;
Atom gamesRunningAtom;
Atom screenZoomAtom;
Atom screenScaleAtom;
Atom opacityAtom;
Atom winTypeAtom;
Atom winDesktopAtom;
Atom winDockAtom;
Atom winToolbarAtom;
Atom winMenuAtom;
Atom winUtilAtom;
Atom winSplashAtom;
Atom winDialogAtom;
Atom winNormalAtom;
Atom sizeHintsAtom;
Atom netWMStateFullscreenAtom;
Atom activeWindowAtom;
Atom netWMStateAtom;
Atom WMTransientForAtom;
Atom netWMStateHiddenAtom;
Atom netWMStateFocusedAtom;
Atom netWMStateSkipTaskbarAtom;
Atom netWMStateSkipPagerAtom;
Atom WLSurfaceIDAtom;
Atom WMStateAtom;
Atom steamInputFocusAtom;
Atom WMChangeStateAtom;
Atom steamTouchClickModeAtom;
Atom utf8StringAtom;
Atom netWMNameAtom;
Atom netWMIcon;
Atom motifWMHints;
Atom netSystemTrayOpcodeAtom;
Atom steamStreamingClientAtom;
Atom steamStreamingClientVideoAtom;
Atom gamescopeFocusableAppsAtom;
Atom gamescopeFocusableWindowsAtom;
Atom gamescopeFocusedWindowAtom;
Atom gamescopeFocusedAppAtom;
Atom gamescopeFocusedAppGfxAtom;
Atom gamescopeCtrlAppIDAtom;
Atom gamescopeCtrlWindowAtom;
Atom gamescopeInputCounterAtom;
Atom gamescopeScreenShotAtom;
Atom gamescopeDebugScreenShotAtom;
Atom gamescopeFocusDisplay;
Atom gamescopeMouseFocusDisplay;
Atom gamescopeKeyboardFocusDisplay;
Atom gamescopeTuneableVBlankRedZone;
Atom gamescopeTuneableRateOfDecay;
Atom gamescopeScalingFilter;
Atom gamescopeFSRSharpness;
Atom gamescopeSharpness;
Atom gamescopeXWaylandModeControl;
Atom gamescopeFPSLimit;
Atom gamescopeDynamicRefresh[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT];
Atom gamescopeLowLatency;
Atom gamescopeFSRFeedback;
Atom gamescopeBlurMode;
Atom gamescopeBlurRadius;
Atom gamescopeBlurFadeDuration;
Atom gamescopeCompositeForce;
Atom gamescopeCompositeDebug;
Atom gamescopeAllowTearing;
Atom gamescopeDisplayForceInternal;
Atom gamescopeDisplayModeNudge;
Atom gamescopeDisplayIsExternal;
Atom gamescopeDisplayModeListExternal;
Atom gamescopeCursorVisibleFeedback;
Atom gamescopeSteamMaxHeight;
Atom gamescopeVRRCapable;
Atom gamescopeVRREnabled;
Atom gamescopeVRRInUse;
Atom gamescopeNewScalingFilter;
Atom gamescopeNewScalingScaler;
Atom gamescopeDisplayEdidPath;
Atom gamescopeXwaylandServerId;
Atom gamescopeDisplaySupportsHDR;
Atom gamescopeDisplayHDREnabled;
Atom gamescopeDebugForceHDR10Output;
Atom gamescopeDebugForceHDRSupport;
Atom gamescopeDebugHDRHeatmap;
Atom gamescopeDebugHDRHeatmap_MSWCG;
Atom gamescopeHDROutputFeedback;
Atom gamescopeSDROnHDRContentBrightness;
Atom gamescopeHDRInputGain;
Atom gamescopeSDRInputGain;
Atom gamescopeHDRItmEnable;
Atom gamescopeHDRItmSDRNits;
Atom gamescopeHDRItmTargetNits;
Atom gamescopeColorLookPQ;
Atom gamescopeColorLookG22;
Atom gamescopeColorOutputVirtualWhite;
Atom gamescopeHDRTonemapDisplayMetadata;
Atom gamescopeHDRTonemapSourceMetadata;
Atom gamescopeHDRTonemapOperator;
Atom gamescopeForceWindowsFullscreen;
Atom gamescopeColorLut3DOverride;
Atom gamescopeColorShaperLutOverride;
Atom gamescopeColorSDRGamutWideness;
Atom gamescopeColorNightMode; // amount, hue, saturation
Atom gamescopeColorManagementDisable;
Atom gamescopeColorAppWantsHDRFeedback;
Atom gamescopeColorAppHDRMetadataFeedback;
Atom gamescopeColorSliderInUse;
Atom gamescopeColorChromaticAdaptationMode;
Atom gamescopeColorMuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT];
Atom gamescopeColorMuraScale[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT];
Atom gamescopeColorMuraCorrectionDisabled[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT];
Atom gamescopeCreateXWaylandServer;
Atom gamescopeCreateXWaylandServerFeedback;
Atom gamescopeDestroyXWaylandServer;
Atom gamescopeReshadeEffect;
Atom gamescopeReshadeTechniqueIdx;
Atom gamescopeDisplayRefreshRateFeedback;
Atom gamescopeDisplayDynamicRefreshBasedOnGamePresence;
Atom wineHwndStyle;
Atom wineHwndStyleEx;
Atom clipboard;
Atom primarySelection;
Atom targets;
} atoms;
bool HasQueuedEvents();
void Dispatch();
int GetFD() final
{
return XConnectionNumber( dpy );
}
void OnPollIn() final
{
Dispatch();
}
void OnPollHangUp() final
{
xwm_log.errorf( "XWayland server hung up! This is fatal. Aborting..." );
abort();
}
};