52 SdlRailWindow(uint64_t
id,
const SDL_Rect& rect);
53 SdlRailWindow(SdlRailWindow&&) =
delete;
54 SdlRailWindow(
const SdlRailWindow&) =
delete;
55 SdlRailWindow& operator=(
const SdlRailWindow&) =
delete;
56 SdlRailWindow& operator=(SdlRailWindow&&) =
delete;
59 [[nodiscard]] uint64_t id()
const;
60 [[nodiscard]] SDL_WindowID sdlId()
const;
61 [[nodiscard]] SDL_Window* window()
const;
62 [[nodiscard]] SDL_Renderer* renderer()
const;
67 void updateWindowRect(
const SDL_Rect& rect);
69 [[nodiscard]] SDL_Rect windowRect()
const;
72 void setLocalMoveActive(
bool active);
73 [[nodiscard]]
bool localMoveActive()
const;
75 [[nodiscard]]
bool localMoveSizeChanged()
const;
77 [[nodiscard]] SDL_Point localMoveServerPos()
const;
78 void adoptLocalGeometry(
const SDL_Rect& rect);
80 void setResizeAnchor(
bool right,
bool bottom);
87 [[nodiscard]]
bool isDeleted()
const;
90 [[nodiscard]]
bool geomApplyPending()
const;
91 void clearGeomApplyPending();
95 [[nodiscard]]
bool loopEndPending()
const;
97 void deferSnap(
const SDL_Rect& serverRect);
101 bool maximize =
false;
103 SDL_Rect snapRect = { 0, 0, 0, 0 };
108 [[nodiscard]]
bool takeWmOverride(SDL_Rect& outer);
111 void setVisibilityRects(std::vector<SDL_Rect> rects);
113 void setVisibleOffset(SDL_Point offset);
116 void setMinMaxSize(SDL_Point minSize, SDL_Point maxSize);
119 void setResizeMargins(
int left,
int top,
int right,
int bottom);
120 [[nodiscard]] SDL_Rect resizeMargins()
const;
122 void setFrameMargins(
const SDL_Rect& m);
123 [[nodiscard]] SDL_Rect frameMargins()
const;
124 [[nodiscard]]
bool takeUnconfirmedReport(SDL_Rect& rect);
125 void noteDisplayChange();
126 [[nodiscard]]
bool takeDisplayChange(
bool now);
127 [[nodiscard]]
bool deferMaximizeUntilEcho();
128 [[nodiscard]]
bool takeMaximizeAfterEcho();
131 void setOwner(uint64_t ownerId);
132 [[nodiscard]] uint64_t owner()
const;
134 [[nodiscard]]
bool isPopup()
const;
136 [[nodiscard]]
bool isFullscreen()
const;
138 [[nodiscard]]
bool activatable()
const;
140 [[nodiscard]]
bool isLayered()
const;
142 void setShadowAnchored(
bool anchored);
143 void setFrame(
bool frame);
144 [[nodiscard]]
bool isFrame()
const;
146 [[nodiscard]] SDL_Rect insets()
const;
148 [[nodiscard]] SDL_Rect outerRect()
const;
150 [[nodiscard]] SDL_Point serverOrigin()
const;
153 [[nodiscard]]
bool placedRel(SDL_Point& rel)
const;
154 void placePopup(
const SDL_Rect& vis,
const SDL_Rect& parentRect);
155 void commitPlacement();
157 [[nodiscard]] SDL_Rect serverRect(
const SDL_Rect& outer)
const;
158 void setLocalShift(
const SDL_Point& shift);
160 void setStyle(uint32_t style, uint32_t exStyle);
161 void setTitle(
const std::string& title);
163 void setAppId(
const std::string& appId);
164 void setVisible(
bool visible);
171 [[nodiscard]]
bool takeSurfaceChange(uint32_t surfaceId);
172 void updateGfxSurface(
const void* data, uint32_t stride, uint32_t width, uint32_t height,
173 const RECTANGLE_16* damage, uint32_t nbDamage, uint32_t format);
175 void invalidateAll();
178 [[nodiscard]]
bool railMaximized()
const
180 return _maxState.rail;
182 void setRailMaximized(
bool m)
184 std::unique_lock lock(_gfxLock);
187 void setServerMaximized(
bool m);
188 [[nodiscard]]
bool railMinimized()
const
190 return _minState.rail;
192 void setRailMinimized(
bool m)
194 std::unique_lock lock(_gfxLock);
197 void setServerMinimized(
bool m);
198 void noteLocalRestore();
199 [[nodiscard]]
bool takeRestoreRetry();
202 void markGeometryDirty()
204 std::unique_lock lock(_gfxLock);
205 _geometryDirty =
true;
208 [[nodiscard]]
bool geometryFrozen()
const
210 return _maxState.rail || _maxState.server || _minState.rail || _minState.server;
213 [[nodiscard]]
bool awaitingRestoreRect()
const
215 std::unique_lock lock(_gfxLock);
216 return restoreRectPending();
219 [[nodiscard]]
bool insetsStale()
const;
221 [[nodiscard]]
bool effectivelyMaximized()
const;
223 [[nodiscard]]
bool stateTransitionPending()
const
226 std::unique_lock lock(_gfxLock);
227 return _maxState.dirty || _minState.dirty || (_maxState.rail != _maxState.server) ||
228 (_minState.rail != _minState.server);
232 bool reconcile(SDL_Window* parent,
const SDL_Rect& parentRect);
234 bool paint(SDL_Surface* primary, SDL_PixelFormat fallbackFormat,
235 const std::vector<SDL_Rect>& damage, SDL_Window* parent,
const SDL_Rect& parentRect);
242 std::atomic<bool> rail{
false };
243 std::atomic<bool> server{
false };
246 void setServerState(StateSync& s,
bool m);
248 bool applyServerState(StateSync& s,
const char* what,
bool (*enter)(SDL_Window*));
250 [[nodiscard]]
bool restoreRectPending()
const;
251 void setAppliedInsets(
const SDL_Rect& insets);
252 [[nodiscard]]
bool styleResizable()
const;
254 [[nodiscard]]
bool honorsAlpha()
const
256 return _isPopup && !_layered;
259 [[nodiscard]]
const char* role()
const
262 return _layered ?
"overlay-layered" :
"overlay";
263 return _layered ?
"layered" : (_isPopup ?
"popup" :
"app");
265 [[nodiscard]]
bool isFullDisplaySize()
const;
267 [[nodiscard]] SDL_Rect bandMargins()
const;
268 [[nodiscard]] SDL_Rect bandInsets()
const;
269 [[nodiscard]] SDL_Point blitOffset()
const;
270 [[nodiscard]] SDL_Rect targetOuterRect()
const;
271 bool create(SDL_Window* parent,
const SDL_Rect& parentRect);
272 bool paintGfx(SDL_PixelFormat format);
273 bool paintLegacy(SDL_Surface* primary,
const std::vector<SDL_Rect>& damage);
274 void placeRequested();
275 [[nodiscard]]
bool holdForPlacement();
278 std::unique_ptr<SdlWindow> _win;
279 SDL_Rect _windowRect;
280 SDL_Point _localShift = { 0, 0 };
282 uint32_t _exStyle = 0;
284 bool _shadowSuppressLogged =
false;
285 bool _everResizable =
false;
286 uint64_t _ownerId = 0;
287 SDL_Rect _resizeMargins = { 0, 0, 0, 0 };
288 SDL_Rect _frameMargins = { 0, 0, 0, 0 };
290 SDL_Rect _appliedInsets = { 0, 0, 0, 0 };
291 bool _wasMaximized =
false;
292 SDL_Point _minSize = { 0, 0 };
293 SDL_Point _maxSize = { 0, 0 };
294 bool _minMaxDirty =
false;
295 bool _isPopup =
false;
296 bool _fullscreen =
false;
297 bool _layered =
false;
298 bool _overlay =
false;
299 bool _popupClassified =
false;
300 bool _shadowAnchored =
false;
302 bool _parentApplied =
false;
305 std::string _title =
"RdpRailWindow";
307 bool _iconDirty =
false;
308 bool _visible =
false;
309 bool _geometryDirty =
true;
310 bool _titleDirty =
false;
312 bool _appIdDirty =
false;
313 bool _topmost =
false;
314 bool _topmostDirty =
false;
315 bool _styleDirty =
false;
316 bool _painted =
false;
317 bool _gfxPresented =
false;
318 bool _mapped =
false;
319 bool _localMoveActive =
false;
320 bool _localMoveIsResize =
false;
321 bool _localMoveSizeChanged =
false;
322 SDL_Point _localMoveServerPos = { 0, 0 };
326 bool pending =
false;
327 bool maximize =
false;
329 SDL_Rect snapRect = { 0, 0, 0, 0 };
331 bool _geomApplyPending =
false;
332 std::vector<SDL_Rect> _reported;
333 uint64_t _reportCheckAt = 0;
334 uint64_t _displayCheckAt = 0;
335 bool _maximizeAfterEcho =
false;
336 bool _wmRefused =
false;
337 SDL_Rect _wmRefusedOuter = { 0, 0, 0, 0 };
338 bool _resizeAnchorRight =
false;
339 bool _resizeAnchorBottom =
false;
341 uint64_t _awaitingFrameUntil = 0;
343 uint64_t _awaitRestoreUntil = 0;
345 uint64_t _localRestoreUntil = 0;
346 bool _restoreRetried =
false;
347 bool _restoreRetry =
false;
349 SDL_Point _gfxVisOrigin = { 0, 0 };
350 SDL_Rect _extentsApplied = { 0, 0, 0, 0 };
353 mutable std::mutex _gfxLock;
354 std::vector<SDL_Rect> _visRects;
355 SDL_Point _visOffset = { 0, 0 };
356 bool _visOffsetSet =
false;
357 bool _visDirty =
false;
358 bool _deleted =
false;
359 std::vector<uint8_t> _gfxBuffer;
360 uint32_t _gfxStride = 0;
361 uint32_t _surfaceId = 0;
364 bool _hasGfx =
false;
366 bool _gfxHasAlpha =
false;
368 std::vector<SDL_Rect> _gfxDamage;
374 bool _needsFullBlit =
true;
375 SDL_Point _requestedRel = { 0, 0 };
376 Uint64 _requestedAt = 0;
377 std::optional<SDL_Point> _pendingRel;
378 std::optional<SDL_Point> _placedRel;
379 bool _placeInFlight =
false;