FreeRDP
Loading...
Searching...
No Matches
SdlRailWindow Class Reference

#include <sdl_rail_window.hpp>

Data Structures

struct  LoopEndActions

Public Member Functions

 SdlRailWindow (uint64_t id, const SDL_Rect &rect)
 SdlRailWindow (SdlRailWindow &&)=delete
 SdlRailWindow (const SdlRailWindow &)=delete
SdlRailWindow & operator= (const SdlRailWindow &)=delete
SdlRailWindow & operator= (SdlRailWindow &&)=delete
uint64_t id () const
SDL_WindowID sdlId () const
SDL_Window * window () const
SDL_Renderer * renderer () const
void updateWindowRect (const SDL_Rect &rect)
SDL_Rect windowRect () const
void setLocalMoveActive (bool active)
bool localMoveActive () const
bool localMoveSizeChanged () const
SDL_Point localMoveServerPos () const
void adoptLocalGeometry (const SDL_Rect &rect)
void setResizeAnchor (bool right, bool bottom)
void markDeleted ()
void releaseWindow ()
bool isDeleted () const
bool geomApplyPending () const
void clearGeomApplyPending ()
void armLoopEnd ()
bool loopEndPending () const
void deferMaximize ()
void deferSnap (const SDL_Rect &serverRect)
void clearLoopEnd ()
LoopEndActions takeLoopEnd ()
bool takeWmOverride (SDL_Rect &outer)
void setVisibilityRects (std::vector< SDL_Rect > rects)
void setVisibleOffset (SDL_Point offset)
void setMinMaxSize (SDL_Point minSize, SDL_Point maxSize)
void setResizeMargins (int left, int top, int right, int bottom)
SDL_Rect resizeMargins () const
void setFrameMargins (const SDL_Rect &m)
SDL_Rect frameMargins () const
bool takeUnconfirmedReport (SDL_Rect &rect)
void noteDisplayChange ()
bool takeDisplayChange (bool now)
bool deferMaximizeUntilEcho ()
bool takeMaximizeAfterEcho ()
void setOwner (uint64_t ownerId)
uint64_t owner () const
bool isPopup () const
bool isFullscreen () const
bool activatable () const
bool isLayered () const
void setShadowAnchored (bool anchored)
void setFrame (bool frame)
bool isFrame () const
SDL_Rect insets () const
SDL_Rect outerRect () const
SDL_Point serverOrigin () const
void notePlaced ()
bool placedRel (SDL_Point &rel) const
void placePopup (const SDL_Rect &vis, const SDL_Rect &parentRect)
void commitPlacement ()
SDL_Rect serverRect (const SDL_Rect &outer) const
void setLocalShift (const SDL_Point &shift)
void setStyle (uint32_t style, uint32_t exStyle)
void setTitle (const std::string &title)
void setAppId (const std::string &appId)
void setVisible (bool visible)
void setIcon (const SdlRailIcon &icon)
bool takeSurfaceChange (uint32_t surfaceId)
void updateGfxSurface (const void *data, uint32_t stride, uint32_t width, uint32_t height, const RECTANGLE_16 *damage, uint32_t nbDamage, uint32_t format)
void invalidateAll ()
bool railMaximized () const
void setRailMaximized (bool m)
void setServerMaximized (bool m)
bool railMinimized () const
void setRailMinimized (bool m)
void setServerMinimized (bool m)
void noteLocalRestore ()
bool takeRestoreRetry ()
void markGeometryDirty ()
bool geometryFrozen () const
bool awaitingRestoreRect () const
bool insetsStale () const
bool effectivelyMaximized () const
bool stateTransitionPending () const
bool reconcile (SDL_Window *parent, const SDL_Rect &parentRect)
bool paint (SDL_Surface *primary, SDL_PixelFormat fallbackFormat, const std::vector< SDL_Rect > &damage, SDL_Window *parent, const SDL_Rect &parentRect)

Detailed Description

A single RemoteApp window, backed by a borderless SDL window.

Geometry is server-authoritative: _windowRect mirrors the server's WINDOW_ORDER offset/size and the local SDL window is moved/resized to follow it.

Definition at line 49 of file sdl_rail_window.hpp.


Data Structure Documentation

◆ SdlRailWindow::LoopEndActions

struct SdlRailWindow::LoopEndActions

Definition at line 99 of file sdl_rail_window.hpp.

Data Fields
bool maximize = false
bool snap = false
SDL_Rect snapRect = { 0, 0, 0, 0 }

Constructor & Destructor Documentation

◆ SdlRailWindow()

SdlRailWindow::SdlRailWindow ( uint64_t id,
const SDL_Rect & rect )

Definition at line 91 of file sdl_rail_window.cpp.

91 : _id(id), _windowRect(rect)
92{
93}

Member Function Documentation

◆ activatable()

bool SdlRailWindow::activatable ( ) const
nodiscard

Definition at line 523 of file sdl_rail_window.cpp.

524{
525 std::unique_lock lock(_gfxLock);
526 return (!_isPopup || _fullscreen) && ((_exStyle & WS_EX_NOACTIVATE) == 0);
527}

◆ adoptLocalGeometry()

void SdlRailWindow::adoptLocalGeometry ( const SDL_Rect & rect)

Definition at line 204 of file sdl_rail_window.cpp.

205{
206 /* Adopt local geometry so the server's echoing WINDOW_ORDER is a no-op (not a size snap). */
207 std::unique_lock lock(_gfxLock);
208 /* A completed local move settles geometry via the completion path, not the reporter. */
209 _geomApplyPending = false;
210 /* Translate visible offset by move delta. */
211 if (_visOffsetSet)
212 {
213 _visOffset.x += rect.x - _windowRect.x;
214 _visOffset.y += rect.y - _windowRect.y;
215 }
216 if (!SDL_RectsEqual(&rect, &_windowRect))
217 {
218 if (_reported.size() >= kMaxReported)
219 _reported.erase(_reported.begin());
220 _reported.push_back(rect);
221 armDeadline(_reportCheckAt, kReportConfirmMs);
222 }
223 _windowRect = rect;
224 _geometryDirty = false;
225 /* A resize drag ends here; the server surface still has the pre-drag size. */
226 _awaitingFrameUntil =
227 (_localMoveActive && _localMoveIsResize) ? (SDL_GetTicks() + kAwaitServerFrameMs) : 0;
228 _localMoveActive = false;
229 _needsFullBlit = true;
230 /* Repaint real content (clear placeholder). */
231 if (_hasGfx)
232 _gfxDamage.assign(1, SDL_Rect{ 0, 0, static_cast<int>(_gfxW), static_cast<int>(_gfxH) });
233}

◆ armLoopEnd()

void SdlRailWindow::armLoopEnd ( )

Definition at line 287 of file sdl_rail_window.cpp.

288{
289 std::unique_lock lock(_gfxLock);
290 _loopEnd.pending = true;
291}

◆ awaitingRestoreRect()

bool SdlRailWindow::awaitingRestoreRect ( ) const
inlinenodiscard

Definition at line 213 of file sdl_rail_window.hpp.

214 {
215 std::unique_lock lock(_gfxLock);
216 return restoreRectPending();
217 }

◆ clearGeomApplyPending()

void SdlRailWindow::clearGeomApplyPending ( )

Definition at line 281 of file sdl_rail_window.cpp.

282{
283 std::unique_lock lock(_gfxLock);
284 _geomApplyPending = false;
285}

◆ clearLoopEnd()

void SdlRailWindow::clearLoopEnd ( )

Definition at line 312 of file sdl_rail_window.cpp.

313{
314 std::unique_lock lock(_gfxLock);
315 _loopEnd = {};
316}

◆ commitPlacement()

void SdlRailWindow::commitPlacement ( )

Definition at line 725 of file sdl_rail_window.cpp.

726{
727 if (!_pendingRel)
728 return;
729 _placedRel = _pendingRel;
730 _pendingRel.reset();
731}

◆ deferMaximize()

void SdlRailWindow::deferMaximize ( )

Definition at line 299 of file sdl_rail_window.cpp.

300{
301 std::unique_lock lock(_gfxLock);
302 _loopEnd.maximize = true;
303}

◆ deferMaximizeUntilEcho()

bool SdlRailWindow::deferMaximizeUntilEcho ( )
nodiscard

Definition at line 481 of file sdl_rail_window.cpp.

482{
483 std::unique_lock lock(_gfxLock);
484 if (_reported.empty())
485 return false;
486 _maximizeAfterEcho = true;
487 return true;
488}

◆ deferSnap()

void SdlRailWindow::deferSnap ( const SDL_Rect & serverRect)

Definition at line 305 of file sdl_rail_window.cpp.

306{
307 std::unique_lock lock(_gfxLock);
308 _loopEnd.snap = true;
309 _loopEnd.snapRect = serverRect;
310}

◆ effectivelyMaximized()

bool SdlRailWindow::effectivelyMaximized ( ) const
nodiscard

Definition at line 1353 of file sdl_rail_window.cpp.

1354{
1355 return _maxState.rail ||
1356 (_win && (SDL_GetWindowFlags(_win->window()) & SDL_WINDOW_MAXIMIZED) != 0);
1357}

◆ frameMargins()

SDL_Rect SdlRailWindow::frameMargins ( ) const
nodiscard

Definition at line 447 of file sdl_rail_window.cpp.

448{
449 std::unique_lock lock(_gfxLock);
450 return _frameMargins;
451}

◆ geomApplyPending()

bool SdlRailWindow::geomApplyPending ( ) const
nodiscard

Definition at line 275 of file sdl_rail_window.cpp.

276{
277 std::unique_lock lock(_gfxLock);
278 return _geomApplyPending;
279}

◆ geometryFrozen()

bool SdlRailWindow::geometryFrozen ( ) const
inlinenodiscard

Definition at line 208 of file sdl_rail_window.hpp.

209 {
210 return _maxState.rail || _maxState.server || _minState.rail || _minState.server;
211 }

◆ id()

uint64_t SdlRailWindow::id ( ) const
nodiscard

Definition at line 98 of file sdl_rail_window.cpp.

99{
100 return _id;
101}

◆ insets()

SDL_Rect SdlRailWindow::insets ( ) const
nodiscard

Definition at line 613 of file sdl_rail_window.cpp.

614{
615 std::unique_lock lock(_gfxLock);
616 return _appliedInsets;
617}

◆ insetsStale()

bool SdlRailWindow::insetsStale ( ) const
nodiscard

Definition at line 1341 of file sdl_rail_window.cpp.

1342{
1343 std::unique_lock lock(_gfxLock);
1344 return _wasMaximized != effectivelyMaximized();
1345}

◆ invalidateAll()

void SdlRailWindow::invalidateAll ( )

Definition at line 1250 of file sdl_rail_window.cpp.

1251{
1252 std::unique_lock lock(_gfxLock);
1253 _needsFullBlit = true;
1254 if (_hasGfx)
1255 _gfxDamage.assign(1, SDL_Rect{ 0, 0, static_cast<int>(_gfxW), static_cast<int>(_gfxH) });
1256}

◆ isDeleted()

bool SdlRailWindow::isDeleted ( ) const
nodiscard

Definition at line 269 of file sdl_rail_window.cpp.

270{
271 std::unique_lock lock(_gfxLock);
272 return _deleted;
273}

◆ isFrame()

bool SdlRailWindow::isFrame ( ) const
nodiscard

Definition at line 547 of file sdl_rail_window.cpp.

548{
549 std::unique_lock lock(_gfxLock);
550 return _frame;
551}

◆ isFullscreen()

bool SdlRailWindow::isFullscreen ( ) const
nodiscard

Definition at line 517 of file sdl_rail_window.cpp.

518{
519 std::unique_lock lock(_gfxLock);
520 return _fullscreen;
521}

◆ isLayered()

bool SdlRailWindow::isLayered ( ) const
nodiscard

Definition at line 529 of file sdl_rail_window.cpp.

530{
531 std::unique_lock lock(_gfxLock);
532 return _layered;
533}

◆ isPopup()

bool SdlRailWindow::isPopup ( ) const
nodiscard

Definition at line 511 of file sdl_rail_window.cpp.

512{
513 std::unique_lock lock(_gfxLock);
514 return _isPopup;
515}

◆ localMoveActive()

bool SdlRailWindow::localMoveActive ( ) const
nodiscard

Definition at line 186 of file sdl_rail_window.cpp.

187{
188 std::unique_lock lock(_gfxLock);
189 return _localMoveActive;
190}

◆ localMoveServerPos()

SDL_Point SdlRailWindow::localMoveServerPos ( ) const
nodiscard

Definition at line 198 of file sdl_rail_window.cpp.

199{
200 std::unique_lock lock(_gfxLock);
201 return _localMoveServerPos;
202}

◆ localMoveSizeChanged()

bool SdlRailWindow::localMoveSizeChanged ( ) const
nodiscard

Definition at line 192 of file sdl_rail_window.cpp.

193{
194 std::unique_lock lock(_gfxLock);
195 return _localMoveSizeChanged;
196}

◆ loopEndPending()

bool SdlRailWindow::loopEndPending ( ) const
nodiscard

Definition at line 293 of file sdl_rail_window.cpp.

294{
295 std::unique_lock lock(_gfxLock);
296 return _loopEnd.pending;
297}

◆ markDeleted()

void SdlRailWindow::markDeleted ( )

Definition at line 241 of file sdl_rail_window.cpp.

242{
243 std::unique_lock lock(_gfxLock);
244 _deleted = true;
245}

◆ markGeometryDirty()

void SdlRailWindow::markGeometryDirty ( )
inline

Definition at line 202 of file sdl_rail_window.hpp.

203 {
204 std::unique_lock lock(_gfxLock);
205 _geometryDirty = true;
206 }

◆ noteDisplayChange()

void SdlRailWindow::noteDisplayChange ( )

Definition at line 466 of file sdl_rail_window.cpp.

467{
468 std::unique_lock lock(_gfxLock);
469 armDeadline(_displayCheckAt, kDisplaySettleMs);
470}

◆ noteLocalRestore()

void SdlRailWindow::noteLocalRestore ( )

Definition at line 1289 of file sdl_rail_window.cpp.

1290{
1291 std::unique_lock lock(_gfxLock);
1292 _restoreRetried = false;
1293 armDeadline(_localRestoreUntil, kAwaitRestoreRectMs);
1294}

◆ notePlaced()

void SdlRailWindow::notePlaced ( )

Definition at line 673 of file sdl_rail_window.cpp.

674{
675 std::unique_lock lock(_gfxLock);
676 placeRequested();
677}

◆ outerRect()

SDL_Rect SdlRailWindow::outerRect ( ) const
nodiscard

Definition at line 620 of file sdl_rail_window.cpp.

621{
622 std::unique_lock lock(_gfxLock);
623 SDL_Rect r = addInsets(_windowRect, _appliedInsets);
624 r.x += _localShift.x;
625 r.y += _localShift.y;
626 return r;
627}

◆ owner()

uint64_t SdlRailWindow::owner ( ) const
nodiscard

Definition at line 505 of file sdl_rail_window.cpp.

506{
507 std::unique_lock lock(_gfxLock);
508 return _ownerId;
509}

◆ paint()

bool SdlRailWindow::paint ( SDL_Surface * primary,
SDL_PixelFormat fallbackFormat,
const std::vector< SDL_Rect > & damage,
SDL_Window * parent,
const SDL_Rect & parentRect )

Definition at line 1359 of file sdl_rail_window.cpp.

1362{
1363 if (!reconcile(parent, parentRect))
1364 return false;
1365
1366 auto ok = false;
1367 auto legacy = false;
1368 {
1369 std::unique_lock lock(_gfxLock);
1370 if (_hasGfx)
1371 ok = paintGfx(fallbackFormat);
1372 else
1373 legacy = true;
1374 }
1375 if (legacy)
1376 ok = paintLegacy(primary, damage);
1377
1378 /* Map in the same pass as the first frame, else the window defers a frame (menu lag). */
1379 if (_gfxPresented && !_mapped && !_minState.rail)
1380 {
1381 _mapped = true;
1382 WLog_DBG(TAG, "map id=0x%08" PRIx32 " %s", static_cast<uint32_t>(_id), role());
1383 SDL_ShowWindow(_win->window());
1384 /* Reassert target position after show to override stale events. */
1385 if (_isPopup && parent)
1386 {
1387 std::unique_lock lock(_gfxLock);
1388 const SDL_Rect vis = targetOuterRect();
1389 placePopup(vis, parentRect);
1390 }
1391 if (((!_isPopup && !_layered) || _fullscreen) && ((_exStyle & WS_EX_NOACTIVATE) == 0))
1392 _win->raise(); /* Bring app and fullscreen windows to front. */
1393 }
1394 return ok;
1395}
#define TAG

◆ placedRel()

bool SdlRailWindow::placedRel ( SDL_Point & rel) const
nodiscard

Definition at line 733 of file sdl_rail_window.cpp.

734{
735 std::unique_lock lock(_gfxLock);
736 /* Only while moving: a resting popup may sit elsewhere (off screen), map it as on X11. */
737 if (!_placedRel || (SDL_GetTicks() - _requestedAt >= kMoveActiveMs))
738 return false;
739 rel = *_placedRel;
740 return true;
741}

◆ placePopup()

void SdlRailWindow::placePopup ( const SDL_Rect & vis,
const SDL_Rect & parentRect )

Definition at line 698 of file sdl_rail_window.cpp.

699{
700 const SDL_Point rel = { vis.x - parentRect.x, vis.y - parentRect.y };
701 const bool wayland = !railPlatformCaps().supportsWindowPositions;
702 const bool moved = (rel.x != _requestedRel.x) || (rel.y != _requestedRel.y);
703 if (wayland)
704 {
705 _requestedRel = rel;
706 _requestedAt = SDL_GetTicks();
707 }
708 if (!SDL_SetWindowPosition(_win->window(), rel.x, rel.y))
709 {
710 WLog_VRB(TAG, "popup reposition unsupported id=0x%08" PRIx32 ": %s",
711 static_cast<uint32_t>(_id), SDL_GetError());
712 return;
713 }
714 if (!wayland)
715 return;
716 _needsFullBlit = true; /* Wayland applies move on next surface commit */
717 if (!moved || !_mapped)
718 return;
719 _placeInFlight = true;
720 if (SDL_AddTimer(static_cast<Uint32>(kPlaceWaitMs + 1), placeWaitTimer, nullptr) == 0)
721 WLog_WARN(TAG, "popup placement timer failed: %s", SDL_GetError());
722}

◆ railMaximized()

bool SdlRailWindow::railMaximized ( ) const
inlinenodiscard

Definition at line 178 of file sdl_rail_window.hpp.

179 {
180 return _maxState.rail;
181 }

◆ railMinimized()

bool SdlRailWindow::railMinimized ( ) const
inlinenodiscard

Definition at line 188 of file sdl_rail_window.hpp.

189 {
190 return _minState.rail;
191 }

◆ reconcile()

bool SdlRailWindow::reconcile ( SDL_Window * parent,
const SDL_Rect & parentRect )

Definition at line 889 of file sdl_rail_window.cpp.

890{
891 std::unique_lock lock(_gfxLock);
892
893 /* Hidden windows get no local SDL window. Layered windows (e.g. docks) need GFX content and
894 * vis-rects to show; this hides empty DWM snap overlays. */
895 const bool popupReady = !_isPopup || _hasGfx;
896 /* Suppress server shadow frames and unparented full-display overlays. */
897 const bool unplaceable =
898 _frame || (_overlay && !railPlatformCaps().supportsWindowPositions && isFullDisplaySize());
899 /* Layered window is shown only when anchored to an adjoining visible popup or overlay. */
900 const bool drawable =
901 _visible && (_windowRect.w > 0) && (_windowRect.h > 0) && popupReady && !unplaceable &&
902 (!_layered || (_hasGfx && !_visRects.empty() && (_shadowAnchored || _overlay)));
903
904 if (!drawable)
905 {
906 /* Log standalone layered windows suppressed by popup shadow heuristic. */
907 if (_layered && _hasGfx && !_visRects.empty() && !_shadowAnchored && !_overlay &&
908 !_shadowSuppressLogged)
909 {
910 _shadowSuppressLogged = true;
911 WLog_DBG(TAG,
912 "shadow-rule suppressed id=0x%08" PRIx32 " %dx%d style=0x%08" PRIx32
913 " ex=0x%08" PRIx32,
914 static_cast<uint32_t>(_id), _windowRect.w, _windowRect.h, _style, _exStyle);
915 }
916 if (_win)
917 {
918 if ((SDL_GetWindowFlags(_win->window()) & SDL_WINDOW_HIDDEN) == 0)
919 {
920 WLog_DBG(TAG, "hide id=0x%08" PRIx32 " %s", static_cast<uint32_t>(_id), role());
921 SDL_HideWindow(_win->window());
922 _appIdDirty = !_appId.empty(); /* SDL destroys the Wayland toplevel on hide */
923 }
924 _mapped = false;
925 }
926 if (_isPopup && !_visible)
927 {
928 _gfxPresented = false;
929 _hasGfx = false;
930 }
931 return false;
932 }
933
934 if (!_win)
935 {
936 if (!create(parent, parentRect))
937 return false;
938 _geometryDirty = false;
939 /* Shown + raised in paint() after the first frame (created hidden). */
940 }
941
942 /* create() returned false on failure, so _win is non-null from here down. */
943 if (_topmostDirty)
944 {
945 _topmostDirty = false;
946 /* X11 only; Wayland has no protocol for this, the call still returns true. */
947 if (!_isPopup && !_layered)
948 std::ignore = SDL_SetWindowAlwaysOnTop(_win->window(), _topmost);
949 }
950
951 /* Resizability first: SDL refuses to maximize a non-resizable window. */
952 if (_styleDirty)
953 {
954 _win->resizeable(styleResizable());
955 _styleDirty = false;
956 /* Insets refresh on geometry updates to avoid flicker. */
957 }
958
959 /* State first: maximized/minimized gates the geometry apply below. */
960 /* Hold geometry sync until server sends restored rect to prevent re-maximizing. */
961 if (applyServerState(_maxState, "maximize", SDL_MaximizeWindow))
962 armDeadline(_awaitRestoreUntil, kAwaitRestoreRectMs);
963 /* Still minimized after our SC_RESTORE: ask once more, then follow the server. */
964 if ((_localRestoreUntil != 0) && (SDL_GetTicks() >= _localRestoreUntil))
965 {
966 _localRestoreUntil = 0;
967 if (_minState.server && !_minState.rail && !_restoreRetried)
968 {
969 _restoreRetried = true;
970 _restoreRetry = true;
971 armDeadline(_localRestoreUntil, kAwaitRestoreRectMs);
972 }
973 else if (_minState.server != _minState.rail)
974 _minState.dirty = true;
975 }
976 std::ignore = applyServerState(_minState, "minimize", SDL_MinimizeWindow);
977 const bool restorePending = restoreRectPending();
978
979 /* Update insets across maximize transitions outside active drag grab. */
980 const bool maxed = effectivelyMaximized();
981 const SDL_Rect band = bandInsets();
982 if ((maxed != _wasMaximized) && !_localMoveActive && !restorePending)
983 {
984 setAppliedInsets(band);
985 if (!maxed)
986 _geometryDirty = true;
987 _wasMaximized = maxed;
988 }
989
990 /* X11: set frame extents before the resize (KWin needs that), not while restoring. */
991 if ((railPlatformCaps().band == RailBandMechanism::FrameExtents) && !restorePending &&
992 !SDL_RectsEqual(&band, &_extentsApplied) && railPlatformSetBand(_win->window(), band))
993 {
994 _extentsApplied = band;
995 }
996 const bool wmOwnsGeometry =
997 _localMoveActive || geometryFrozen() || _fullscreen || restorePending;
998 /* Clamp min size hints to target bounds so stale hints do not block programmatic resize.
999 * Defer size hints and programmatic resize during active WM move/resize grab. */
1000 if ((_minMaxDirty || _geometryDirty) && !wmOwnsGeometry)
1001 {
1002 const SDL_Rect vis = targetOuterRect();
1003 const int bandW = band.x + band.w;
1004 const int bandH = band.y + band.h;
1005 /* Convert server track size hints (which include server margins) to outer window bounds. */
1006 const SDL_Rect& m = _resizeMargins;
1007 const int padW = bandW - m.x - m.w;
1008 const int padH = bandH - m.y - m.h;
1009 const auto toOuter = [](int track, int pad)
1010 { return (track > 0) ? std::max(1, track + pad) : 0; };
1011 const int minW = toOuter(_minSize.x, padW);
1012 const int minH = toOuter(_minSize.y, padH);
1013 SDL_SetWindowMinimumSize(_win->window(), std::clamp(minW, 0, vis.w),
1014 std::clamp(minH, 0, vis.h));
1015 int maxW = toOuter(_maxSize.x, padW);
1016 int maxH = toOuter(_maxSize.y, padH);
1017 /* Wayland: cap to the usable area - an oversized window cannot be dragged into reach. */
1018 SDL_Rect usable{};
1019 if (!railPlatformCaps().supportsWindowPositions &&
1020 SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &usable))
1021 {
1022 const int capW = usable.w + bandW;
1023 const int capH = usable.h + bandH;
1024 if ((maxW == 0) || (maxW > capW))
1025 maxW = capW;
1026 if ((maxH == 0) || (maxH > capH))
1027 maxH = capH;
1028 }
1029 SDL_SetWindowMaximumSize(_win->window(), maxW, maxH);
1030 _minMaxDirty = false;
1031 }
1032
1033 /* Skip geometry apply when maximized, minimized or WM-dragged. */
1034 if (_geometryDirty && !wmOwnsGeometry)
1035 {
1036 const SDL_Rect vis = targetOuterRect();
1037 /* Record applied insets so server coordinate mapping strips the exact offset. */
1038 setAppliedInsets(band);
1039 int cw = 0;
1040 int ch = 0;
1041 SDL_GetWindowSize(_win->window(), &cw, &ch);
1042 bool applied = false;
1043 bool placed = false; /* railPlatformSetWindowRect set position and size at once */
1044 /* Apply position and size if changed. */
1045 if (_isPopup && parent)
1046 {
1047 placePopup(vis, parentRect);
1048 applied = true;
1049 }
1050 else if (railPlatformCaps().supportsWindowPositions &&
1051 !(_isPopup && SDL_GetWindowParent(_win->window())))
1052 {
1053 int cx = 0;
1054 int cy = 0;
1055 SDL_GetWindowPosition(_win->window(), &cx, &cy);
1056 if ((cx != vis.x) || (cy != vis.y))
1057 {
1058 placed = railPlatformSetWindowRect(_win->window(), vis);
1059 if (!placed)
1060 SDL_SetWindowPosition(_win->window(), vis.x, vis.y);
1061 applied = true;
1062 }
1063 }
1064 if ((cw != vis.w) || (ch != vis.h))
1065 {
1066 if (!placed && !railPlatformSetWindowRect(_win->window(), vis))
1067 std::ignore = _win->resize({ vis.w, vis.h });
1068 applied = true;
1069 /* Settle window resize via SDL_SyncWindow before reading back geometry to avoid
1070 * adopting transient dimensions while configure events are in flight. */
1071 if (railPlatformCaps().supportsWindowPositions && !_isPopup && !_localMoveActive &&
1072 !_loopEnd.pending)
1073 {
1074 const bool settled = SDL_SyncWindow(_win->window());
1075 int aw = 0;
1076 int ah = 0;
1077 SDL_GetWindowSize(_win->window(), &aw, &ah);
1078 if (settled && ((aw != vis.w) || (ah != vis.h)))
1079 {
1080 /* Adopt WM size while preserving server origin. */
1081 _wmRefusedOuter = { vis.x, vis.y, aw, ah };
1082 _wmRefused = true;
1083 applied = false; /* Geometry refused by WM; do not await echo. */
1084 }
1085 }
1086 }
1087 _geometryDirty = false;
1088 /* Echo filtering is only tracked for top-level app windows. */
1089 _geomApplyPending = applied && !_isPopup;
1090 }
1091 /* Make dialog transient for owner. */
1092 /* Attach only to a shown owner: SDL hides child windows with their parent. */
1093 if (!_isPopup && parent && !_parentApplied &&
1094 ((SDL_GetWindowFlags(parent) & SDL_WINDOW_HIDDEN) == 0))
1095 {
1096 if (SDL_SetWindowParent(_win->window(), parent))
1097 {
1098 _parentApplied = true;
1099 /* Reattached after the owner was shown again: the owner was mapped on top. */
1100 if (((SDL_GetWindowFlags(_win->window()) & SDL_WINDOW_HIDDEN) == 0) &&
1101 !railPlatformRaiseOwned(_win->window()))
1102 WLog_WARN(TAG, "raising dialog id=0x%08" PRIx32 " failed",
1103 static_cast<uint32_t>(_id));
1104 }
1105 }
1106 if (_titleDirty)
1107 {
1108 if (!_isPopup)
1109 SDL_SetWindowTitle(_win->window(), _title.c_str());
1110 _titleDirty = false;
1111 }
1112 if (_appIdDirty)
1113 {
1114 /* The app_id can arrive after the window was created, and SDL sets its own on every show:
1115 * apply ours again, retrying until the xdg_toplevel exists. */
1116 if ((_isPopup && !_fullscreen) || !sdl::utils::isWaylandDriver() ||
1117 sdl_wayland_set_app_id(_win->window(), _appId.c_str()))
1118 _appIdDirty = false;
1119 }
1120 if (_iconDirty)
1121 {
1122 if (!_isPopup && !_icon.bgra.empty())
1123 {
1124 SDL_Surface* s = SDL_CreateSurfaceFrom(
1125 static_cast<int>(_icon.w), static_cast<int>(_icon.h), SDL_PIXELFORMAT_BGRA32,
1126 _icon.bgra.data(), static_cast<int>(_icon.w * 4));
1127 if (s)
1128 {
1129 if (!SDL_SetWindowIcon(_win->window(), s))
1130 WLog_WARN(TAG, "SDL_SetWindowIcon failed for window 0x%08" PRIx32 ": %s",
1131 static_cast<uint32_t>(_id), SDL_GetError());
1132 SDL_DestroySurface(s);
1133 }
1134 }
1135 _iconDirty = false;
1136 }
1137
1138 /* Defer show until first frame; this runs every reconcile, so skip the call once visible. */
1139 if (!_minState.rail && _gfxPresented &&
1140 (SDL_GetWindowFlags(_win->window()) & SDL_WINDOW_HIDDEN))
1141 {
1142 /* If transient-for owner was closed or hidden, show dialog standalone. */
1143 SDL_Window* owner = _isPopup ? nullptr : SDL_GetWindowParent(_win->window());
1144 if (owner && ((SDL_GetWindowFlags(owner) & SDL_WINDOW_HIDDEN) != 0))
1145 {
1146 if (SDL_SetWindowParent(_win->window(), nullptr))
1147 _parentApplied = false; /* reattach once the owner is shown again */
1148 else
1149 WLog_WARN(TAG, "detaching dialog id=0x%08" PRIx32 " failed: %s",
1150 static_cast<uint32_t>(_id), SDL_GetError());
1151 }
1152 SDL_ShowWindow(_win->window());
1153 }
1154 return true;
1155}

◆ releaseWindow()

void SdlRailWindow::releaseWindow ( )

Definition at line 247 of file sdl_rail_window.cpp.

248{
249 std::unique_lock lock(_gfxLock);
250 if (!_win)
251 return;
252 WLog_DBG(TAG, "release id=0x%08" PRIx32 " %s%s", static_cast<uint32_t>(_id), role(),
253 _deleted ? "" : " (SDL parent gone, re-created on next pass)");
254 _win.reset();
255 _appIdDirty = !_appId.empty();
256 /* Back to the "never created" state: create() + first frame + map run again. */
257 _mapped = false;
258 _painted = false;
259 _gfxPresented = false;
260 _needsFullBlit = true;
261 _geometryDirty = true;
262 _parentApplied = false;
263 _fullscreen = false;
264 _appliedInsets = { 0, 0, 0, 0 };
265 _extentsApplied = { 0, 0, 0, 0 };
266 _lastWinW = _lastWinH = _lastGfxW = _lastGfxH = 0;
267}

◆ renderer()

SDL_Renderer * SdlRailWindow::renderer ( ) const
nodiscard

Definition at line 113 of file sdl_rail_window.cpp.

114{
115 return _win ? _win->renderer() : nullptr;
116}

◆ resizeMargins()

SDL_Rect SdlRailWindow::resizeMargins ( ) const
nodiscard

Definition at line 435 of file sdl_rail_window.cpp.

436{
437 std::unique_lock lock(_gfxLock);
438 return _resizeMargins;
439}

◆ sdlId()

SDL_WindowID SdlRailWindow::sdlId ( ) const
nodiscard

Definition at line 103 of file sdl_rail_window.cpp.

104{
105 return _win ? _win->id() : 0;
106}

◆ serverOrigin()

SDL_Point SdlRailWindow::serverOrigin ( ) const
nodiscard

Definition at line 743 of file sdl_rail_window.cpp.

744{
745 std::unique_lock lock(_gfxLock);
746 /* Derive server coordinate from blit offset to match on-screen pixels. */
747 const SDL_Point dst = blitOffset();
748 return { _windowRect.x - dst.x, _windowRect.y - dst.y };
749}

◆ serverRect()

SDL_Rect SdlRailWindow::serverRect ( const SDL_Rect & outer) const
nodiscard

Definition at line 629 of file sdl_rail_window.cpp.

630{
631 SDL_Rect r = stripInsets(outer, insets());
632 r.x -= _localShift.x;
633 r.y -= _localShift.y;
634 return r;
635}

◆ setAppId()

void SdlRailWindow::setAppId ( const std::string & appId)

Definition at line 783 of file sdl_rail_window.cpp.

784{
785 std::unique_lock lock(_gfxLock);
786 _appId = appId;
787 _appIdDirty = !appId.empty();
788}

◆ setFrame()

void SdlRailWindow::setFrame ( bool frame)

Definition at line 541 of file sdl_rail_window.cpp.

542{
543 std::unique_lock lock(_gfxLock);
544 _frame = frame;
545}

◆ setFrameMargins()

void SdlRailWindow::setFrameMargins ( const SDL_Rect & m)

Definition at line 441 of file sdl_rail_window.cpp.

442{
443 std::unique_lock lock(_gfxLock);
444 _frameMargins = m;
445}

◆ setIcon()

void SdlRailWindow::setIcon ( const SdlRailIcon & icon)

Definition at line 796 of file sdl_rail_window.cpp.

797{
798 std::unique_lock lock(_gfxLock);
799 _icon = icon;
800 _iconDirty = true;
801}

◆ setLocalMoveActive()

void SdlRailWindow::setLocalMoveActive ( bool active)

Definition at line 167 of file sdl_rail_window.cpp.

168{
169 std::unique_lock lock(_gfxLock);
170 _localMoveActive = active;
171 if (active)
172 {
173 _localMoveIsResize = false; /* default to move; setResizeAnchor marks a resize */
174 _localMoveSizeChanged = false;
175 }
176}

◆ setLocalShift()

void SdlRailWindow::setLocalShift ( const SDL_Point & shift)

Definition at line 637 of file sdl_rail_window.cpp.

638{
639 std::unique_lock lock(_gfxLock);
640 _localShift = shift;
641}

◆ setMinMaxSize()

void SdlRailWindow::setMinMaxSize ( SDL_Point minSize,
SDL_Point maxSize )

Definition at line 413 of file sdl_rail_window.cpp.

414{
415 std::unique_lock lock(_gfxLock);
416 _minSize = { std::max(0, minSize.x), std::max(0, minSize.y) };
417 _maxSize = { std::max(0, maxSize.x), std::max(0, maxSize.y) };
418 _minMaxDirty = true;
419 /* Re-apply geometry on min/max change. */
420 _geometryDirty = true;
421}

◆ setOwner()

void SdlRailWindow::setOwner ( uint64_t ownerId)

Definition at line 499 of file sdl_rail_window.cpp.

500{
501 std::unique_lock lock(_gfxLock);
502 _ownerId = ownerId;
503}

◆ setRailMaximized()

void SdlRailWindow::setRailMaximized ( bool m)
inline

Definition at line 182 of file sdl_rail_window.hpp.

183 {
184 std::unique_lock lock(_gfxLock);
185 _maxState.rail = m;
186 }

◆ setRailMinimized()

void SdlRailWindow::setRailMinimized ( bool m)
inline

Definition at line 192 of file sdl_rail_window.hpp.

193 {
194 std::unique_lock lock(_gfxLock);
195 _minState.rail = m;
196 }

◆ setResizeAnchor()

void SdlRailWindow::setResizeAnchor ( bool right,
bool bottom )

Definition at line 178 of file sdl_rail_window.cpp.

179{
180 std::unique_lock lock(_gfxLock);
181 _resizeAnchorRight = right;
182 _resizeAnchorBottom = bottom;
183 _localMoveIsResize = true;
184}

◆ setResizeMargins()

void SdlRailWindow::setResizeMargins ( int left,
int top,
int right,
int bottom )

Definition at line 423 of file sdl_rail_window.cpp.

424{
425 std::unique_lock lock(_gfxLock);
426 const SDL_Rect m = { left, top, right, bottom };
427 if (SDL_RectsEqual(&m, &_resizeMargins))
428 return;
429 _resizeMargins = m;
430 /* Margins usually arrive after the first frame; the window must regrow to cover them. */
431 if (!railMaximized())
432 _geometryDirty = true;
433}

◆ setServerMaximized()

void SdlRailWindow::setServerMaximized ( bool m)

Definition at line 1268 of file sdl_rail_window.cpp.

1269{
1270 setServerState(_maxState, m);
1271}

◆ setServerMinimized()

void SdlRailWindow::setServerMinimized ( bool m)

Definition at line 1273 of file sdl_rail_window.cpp.

1274{
1275 {
1276 std::unique_lock lock(_gfxLock);
1277 /* Late minimize of a window the user already restored. */
1278 if (m && (_localRestoreUntil != 0) && (SDL_GetTicks() < _localRestoreUntil))
1279 {
1280 _minState.server = true;
1281 return;
1282 }
1283 if (!m)
1284 _localRestoreUntil = 0;
1285 }
1286 setServerState(_minState, m);
1287}

◆ setShadowAnchored()

void SdlRailWindow::setShadowAnchored ( bool anchored)

Definition at line 535 of file sdl_rail_window.cpp.

536{
537 std::unique_lock lock(_gfxLock);
538 _shadowAnchored = anchored;
539}

◆ setStyle()

void SdlRailWindow::setStyle ( uint32_t style,
uint32_t exStyle )

Definition at line 751 of file sdl_rail_window.cpp.

752{
753 std::unique_lock lock(_gfxLock);
754 const bool wasTopmost = _topmost;
755 _style = style;
756 _exStyle = exStyle;
757 _topmost = (exStyle & WS_EX_TOPMOST) != 0;
758 if (_topmost != wasTopmost)
759 _topmostDirty = true;
760 if (!_everResizable && ((style & (WS_THICKFRAME | WS_MAXIMIZEBOX)) != 0))
761 {
762 _everResizable = true;
763 _styleDirty = true;
764 }
765 /* Classify popup and layered window types once on creation. */
766 if (!_popupClassified)
767 {
768 const auto classification = classifySdlRailWindowStyle(style, exStyle, _ownerId != 0);
769 _isPopup = classification.popup;
770 _layered = classification.layered;
771 _overlay = classification.overlay;
772 _popupClassified = true;
773 }
774}

◆ setTitle()

void SdlRailWindow::setTitle ( const std::string & title)

Definition at line 776 of file sdl_rail_window.cpp.

777{
778 std::unique_lock lock(_gfxLock);
779 _title = title;
780 _titleDirty = true;
781}

◆ setVisibilityRects()

void SdlRailWindow::setVisibilityRects ( std::vector< SDL_Rect > rects)

Definition at line 380 of file sdl_rail_window.cpp.

381{
382 /* The rects of a region do not overlap and painting relies on that: each rect is blitted on
383 * its own, so overlapping ones cost their number times the window area per frame. */
384 if (!rectsAreDisjoint(rects))
385 {
386 SDL_Rect extents{};
387 for (const auto& r : rects)
388 {
389 SDL_Rect u{};
390 if (SDL_GetRectUnion(&extents, &r, &u))
391 extents = u;
392 }
393 rects.assign(1, extents);
394 }
395 std::unique_lock lock(_gfxLock);
396 _visRects = std::move(rects);
397 _visDirty = true;
398}

◆ setVisible()

void SdlRailWindow::setVisible ( bool visible)

Definition at line 790 of file sdl_rail_window.cpp.

791{
792 std::unique_lock lock(_gfxLock);
793 _visible = visible;
794}

◆ setVisibleOffset()

void SdlRailWindow::setVisibleOffset ( SDL_Point offset)

Definition at line 400 of file sdl_rail_window.cpp.

401{
402 std::unique_lock lock(_gfxLock);
403 /* Freeze visible offset during local move. */
404 if (_localMoveActive)
405 return;
406 if (_visOffsetSet && (offset.x == _visOffset.x) && (offset.y == _visOffset.y))
407 return;
408 _visOffset = offset;
409 _visOffsetSet = true;
410 _visDirty = true;
411}

◆ stateTransitionPending()

bool SdlRailWindow::stateTransitionPending ( ) const
inlinenodiscard

Definition at line 223 of file sdl_rail_window.hpp.

224 {
225 /* _maxState/_minState are written under _gfxLock on the RDP thread. */
226 std::unique_lock lock(_gfxLock);
227 return _maxState.dirty || _minState.dirty || (_maxState.rail != _maxState.server) ||
228 (_minState.rail != _minState.server);
229 }

◆ takeDisplayChange()

bool SdlRailWindow::takeDisplayChange ( bool now)
nodiscard

Definition at line 472 of file sdl_rail_window.cpp.

473{
474 std::unique_lock lock(_gfxLock);
475 if ((_displayCheckAt == 0) || (!now && (SDL_GetTicks() < _displayCheckAt)))
476 return false;
477 _displayCheckAt = 0;
478 return true;
479}

◆ takeLoopEnd()

SdlRailWindow::LoopEndActions SdlRailWindow::takeLoopEnd ( )
nodiscard

Definition at line 318 of file sdl_rail_window.cpp.

319{
320 std::unique_lock lock(_gfxLock);
321 const LoopEndActions actions{ _loopEnd.maximize, _loopEnd.snap, _loopEnd.snapRect };
322 _loopEnd = {};
323 return actions;
324}

◆ takeMaximizeAfterEcho()

bool SdlRailWindow::takeMaximizeAfterEcho ( )
nodiscard

Definition at line 490 of file sdl_rail_window.cpp.

491{
492 std::unique_lock lock(_gfxLock);
493 if (!_maximizeAfterEcho || !_reported.empty())
494 return false;
495 _maximizeAfterEcho = false;
496 return true;
497}

◆ takeRestoreRetry()

bool SdlRailWindow::takeRestoreRetry ( )
nodiscard

Definition at line 1296 of file sdl_rail_window.cpp.

1297{
1298 std::unique_lock lock(_gfxLock);
1299 return std::exchange(_restoreRetry, false);
1300}

◆ takeSurfaceChange()

bool SdlRailWindow::takeSurfaceChange ( uint32_t surfaceId)
nodiscard

Definition at line 1157 of file sdl_rail_window.cpp.

1158{
1159 std::unique_lock lock(_gfxLock);
1160 if (_surfaceId == surfaceId)
1161 return false;
1162 _surfaceId = surfaceId;
1163 return true;
1164}

◆ takeUnconfirmedReport()

bool SdlRailWindow::takeUnconfirmedReport ( SDL_Rect & rect)
nodiscard

Definition at line 453 of file sdl_rail_window.cpp.

454{
455 std::unique_lock lock(_gfxLock);
456 if ((_reportCheckAt == 0) || (SDL_GetTicks() < _reportCheckAt))
457 return false;
458 _reportCheckAt = 0;
459 if (_reported.empty())
460 return false;
461 rect = _reported.back();
462 _reported.clear();
463 return true;
464}

◆ takeWmOverride()

bool SdlRailWindow::takeWmOverride ( SDL_Rect & outer)
nodiscard

Definition at line 326 of file sdl_rail_window.cpp.

327{
328 std::unique_lock lock(_gfxLock);
329 if (!_wmRefused)
330 return false;
331 outer = _wmRefusedOuter;
332 _wmRefused = false;
333 return true;
334}

◆ updateGfxSurface()

void SdlRailWindow::updateGfxSurface ( const void * data,
uint32_t stride,
uint32_t width,
uint32_t height,
const RECTANGLE_16 * damage,
uint32_t nbDamage,
uint32_t format )

Definition at line 1166 of file sdl_rail_window.cpp.

1169{
1170 std::unique_lock lock(_gfxLock);
1171 /* The copies below are byte-for-byte; gdi_CreateSurface yields nothing else. */
1172 WINPR_ASSERT((format == PIXEL_FORMAT_BGRA32) || (format == PIXEL_FORMAT_BGRX32));
1173 /* Deep-copy GDI pixels to prevent UAF. */
1174 const size_t bytes = static_cast<size_t>(stride) * height;
1175 if (!data || (bytes == 0) || (width == 0) || (height == 0))
1176 {
1177 if (_hasGfx)
1178 WLog_DBG(TAG, "gfx cleared id=0x%08" PRIx32 " (surface unmapped)",
1179 static_cast<uint32_t>(_id));
1180 _gfxBuffer.clear();
1181 _hasGfx = false;
1182 _gfxDamage.clear();
1183 _gfxStride = stride;
1184 _gfxW = width;
1185 _gfxH = height;
1186 _gfxVisOrigin = { 0, 0 };
1187 return;
1188 }
1189
1190 const auto* src = static_cast<const uint8_t*>(data);
1191 /* Geometry/stride change, first frame, or no damage rects: full copy + repaint. */
1192 const bool full = !_hasGfx || (_gfxBuffer.size() != bytes) || (_gfxStride != stride) ||
1193 (_gfxW != width) || (_gfxH != height) || (nbDamage == 0);
1194 if (full)
1195 {
1196 const SDL_Rect bounds{ 0, 0, static_cast<int>(width), static_cast<int>(height) };
1197 /* Check _hasGfx first to avoid redundant full-surface blank checks once content exists. */
1198 if (!_hasGfx && regionIsBlank(src, stride, bounds))
1199 return;
1200 _gfxBuffer.assign(src, src + bytes);
1201 _gfxDamage.assign(1, SDL_Rect{ 0, 0, static_cast<int>(width), static_cast<int>(height) });
1202 _needsFullBlit = true;
1203 /* Blend real alpha, force opaque otherwise. */
1204 _gfxHasAlpha = honorsAlpha() &&
1205 regionHasAlpha(_gfxBuffer.data(), stride,
1206 { 0, 0, static_cast<int>(width), static_cast<int>(height) });
1207 }
1208 else
1209 {
1210 const SDL_Rect bounds{ 0, 0, static_cast<int>(width), static_cast<int>(height) };
1211 for (uint32_t i = 0; i < nbDamage; i++)
1212 {
1213 const SDL_Rect r{ damage[i].left, damage[i].top, damage[i].right - damage[i].left,
1214 damage[i].bottom - damage[i].top };
1215 SDL_Rect clip{};
1216 if (!SDL_GetRectIntersection(&r, &bounds, &clip))
1217 continue;
1218 std::ignore = freerdp_image_copy_no_overlap(
1219 _gfxBuffer.data(), PIXEL_FORMAT_BGRA32, stride, static_cast<UINT32>(clip.x),
1220 static_cast<UINT32>(clip.y), static_cast<UINT32>(clip.w),
1221 static_cast<UINT32>(clip.h), src, PIXEL_FORMAT_BGRA32, stride,
1222 static_cast<UINT32>(clip.x), static_cast<UINT32>(clip.y), nullptr,
1223 FREERDP_FLIP_NONE);
1224 _gfxDamage.push_back(clip);
1225 /* Alpha may first appear in a later incremental frame (e.g. a menu fading in). */
1226 if (honorsAlpha() && !_gfxHasAlpha && regionHasAlpha(_gfxBuffer.data(), stride, clip))
1227 _gfxHasAlpha = true;
1228 }
1229 /* A hidden window accumulates rects without ever painting; collapse to one full repaint. */
1230 if (_gfxDamage.size() > 32)
1231 _gfxDamage.assign(1,
1232 SDL_Rect{ 0, 0, static_cast<int>(width), static_cast<int>(height) });
1233 }
1234 if ((_gfxW != width) || (_gfxH != height))
1235 {
1236 _resizeAnchorRight = false;
1237 _resizeAnchorBottom = false;
1238 _needsFullBlit = true;
1239 /* Invalidate surface origin until visibility rect matching new dimensions arrives. */
1240 _gfxVisOrigin = { 0, 0 };
1241 }
1242 _hasGfx = true;
1243 _gfxStride = stride;
1244 _gfxW = width;
1245 _gfxH = height;
1246 WLog_VRB(TAG, "gfx id=0x%08" PRIx32 " %ux%u full=%d nDamage=%u", static_cast<uint32_t>(_id),
1247 width, height, full ? 1 : 0, nbDamage);
1248}

◆ updateWindowRect()

void SdlRailWindow::updateWindowRect ( const SDL_Rect & rect)

Definition at line 118 of file sdl_rail_window.cpp.

119{
120 std::unique_lock lock(_gfxLock);
121 /* Minimized, Windows parks the window off screen; keep the rect to restore to. */
122 if (_minState.server)
123 return;
124 _awaitRestoreUntil = 0; /* Server geometry received. */
125 if (_localMoveActive)
126 {
127 /* Adopt server size change during local move. */
128 if (!_localMoveIsResize && ((rect.w != _windowRect.w) || (rect.h != _windowRect.h)))
129 {
130 WLog_DBG(TAG, "size adopted mid-move id=0x%08" PRIx32 " %dx%d -> %dx%d at %d,%d",
131 static_cast<uint32_t>(_id), _windowRect.w, _windowRect.h, rect.w, rect.h,
132 rect.x, rect.y);
133 _windowRect.w = rect.w;
134 _windowRect.h = rect.h;
135 /* Record server re-anchor position. */
136 _localMoveServerPos = { rect.x, rect.y };
137 _localMoveSizeChanged = true;
138 _painted = false;
139 }
140 return;
141 }
142 /* Accept post-move geometry echoes. */
143 if (SDL_RectsEqual(&rect, &_windowRect))
144 {
145 _reported.clear();
146 return;
147 }
148 /* The echo of an older report can arrive after a newer one was sent. */
149 const auto echo = std::find_if(_reported.begin(), _reported.end(),
150 [&](const SDL_Rect& r) { return SDL_RectsEqual(&r, &rect); });
151 if (echo != _reported.end())
152 {
153 WLog_DBG(TAG, "late echo id=0x%08" PRIx32 " %dx%d ignored", static_cast<uint32_t>(_id),
154 rect.w, rect.h);
155 _reported.erase(_reported.begin(), echo + 1);
156 return;
157 }
158 _reported.clear();
159 /* A resize recreates the render target, so the content needs a full re-copy. */
160 if ((rect.w != _windowRect.w) || (rect.h != _windowRect.h))
161 _painted = false;
162 _windowRect = rect;
163 /* Mark dirty even if frozen/maximized so pending restore rect applies upon unfreeze. */
164 _geometryDirty = true;
165}

◆ window()

SDL_Window * SdlRailWindow::window ( ) const
nodiscard

Definition at line 108 of file sdl_rail_window.cpp.

109{
110 return _win ? _win->window() : nullptr;
111}

◆ windowRect()

SDL_Rect SdlRailWindow::windowRect ( ) const
nodiscard

Definition at line 235 of file sdl_rail_window.cpp.

236{
237 std::unique_lock lock(_gfxLock);
238 return _windowRect;
239}

The documentation for this class was generated from the following files: