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 89 of file sdl_rail_window.cpp.

89 : _id(id), _windowRect(rect)
90{
91}

Member Function Documentation

◆ activatable()

bool SdlRailWindow::activatable ( ) const
nodiscard

Definition at line 464 of file sdl_rail_window.cpp.

465{
466 std::unique_lock lock(_gfxLock);
467 return (!_isPopup || _fullscreen) && ((_exStyle & WS_EX_NOACTIVATE) == 0);
468}

◆ adoptLocalGeometry()

void SdlRailWindow::adoptLocalGeometry ( const SDL_Rect & rect)

Definition at line 202 of file sdl_rail_window.cpp.

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

◆ armLoopEnd()

void SdlRailWindow::armLoopEnd ( )

Definition at line 285 of file sdl_rail_window.cpp.

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

◆ 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 279 of file sdl_rail_window.cpp.

280{
281 std::unique_lock lock(_gfxLock);
282 _geomApplyPending = false;
283}

◆ clearLoopEnd()

void SdlRailWindow::clearLoopEnd ( )

Definition at line 310 of file sdl_rail_window.cpp.

311{
312 std::unique_lock lock(_gfxLock);
313 _loopEnd = {};
314}

◆ commitPlacement()

void SdlRailWindow::commitPlacement ( )

Definition at line 666 of file sdl_rail_window.cpp.

667{
668 if (!_pendingRel)
669 return;
670 _placedRel = _pendingRel;
671 _pendingRel.reset();
672}

◆ deferMaximize()

void SdlRailWindow::deferMaximize ( )

Definition at line 297 of file sdl_rail_window.cpp.

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

◆ deferMaximizeUntilEcho()

bool SdlRailWindow::deferMaximizeUntilEcho ( )
nodiscard

Definition at line 422 of file sdl_rail_window.cpp.

423{
424 std::unique_lock lock(_gfxLock);
425 if (_reported.empty())
426 return false;
427 _maximizeAfterEcho = true;
428 return true;
429}

◆ deferSnap()

void SdlRailWindow::deferSnap ( const SDL_Rect & serverRect)

Definition at line 303 of file sdl_rail_window.cpp.

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

◆ effectivelyMaximized()

bool SdlRailWindow::effectivelyMaximized ( ) const
nodiscard

Definition at line 1294 of file sdl_rail_window.cpp.

1295{
1296 return _maxState.rail ||
1297 (_win && (SDL_GetWindowFlags(_win->window()) & SDL_WINDOW_MAXIMIZED) != 0);
1298}

◆ frameMargins()

SDL_Rect SdlRailWindow::frameMargins ( ) const
nodiscard

Definition at line 388 of file sdl_rail_window.cpp.

389{
390 std::unique_lock lock(_gfxLock);
391 return _frameMargins;
392}

◆ geomApplyPending()

bool SdlRailWindow::geomApplyPending ( ) const
nodiscard

Definition at line 273 of file sdl_rail_window.cpp.

274{
275 std::unique_lock lock(_gfxLock);
276 return _geomApplyPending;
277}

◆ 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 96 of file sdl_rail_window.cpp.

97{
98 return _id;
99}

◆ insets()

SDL_Rect SdlRailWindow::insets ( ) const
nodiscard

Definition at line 554 of file sdl_rail_window.cpp.

555{
556 std::unique_lock lock(_gfxLock);
557 return _appliedInsets;
558}

◆ insetsStale()

bool SdlRailWindow::insetsStale ( ) const
nodiscard

Definition at line 1282 of file sdl_rail_window.cpp.

1283{
1284 std::unique_lock lock(_gfxLock);
1285 return _wasMaximized != effectivelyMaximized();
1286}

◆ invalidateAll()

void SdlRailWindow::invalidateAll ( )

Definition at line 1191 of file sdl_rail_window.cpp.

1192{
1193 std::unique_lock lock(_gfxLock);
1194 _needsFullBlit = true;
1195 if (_hasGfx)
1196 _gfxDamage.assign(1, SDL_Rect{ 0, 0, static_cast<int>(_gfxW), static_cast<int>(_gfxH) });
1197}

◆ isDeleted()

bool SdlRailWindow::isDeleted ( ) const
nodiscard

Definition at line 267 of file sdl_rail_window.cpp.

268{
269 std::unique_lock lock(_gfxLock);
270 return _deleted;
271}

◆ isFrame()

bool SdlRailWindow::isFrame ( ) const
nodiscard

Definition at line 488 of file sdl_rail_window.cpp.

489{
490 std::unique_lock lock(_gfxLock);
491 return _frame;
492}

◆ isFullscreen()

bool SdlRailWindow::isFullscreen ( ) const
nodiscard

Definition at line 458 of file sdl_rail_window.cpp.

459{
460 std::unique_lock lock(_gfxLock);
461 return _fullscreen;
462}

◆ isLayered()

bool SdlRailWindow::isLayered ( ) const
nodiscard

Definition at line 470 of file sdl_rail_window.cpp.

471{
472 std::unique_lock lock(_gfxLock);
473 return _layered;
474}

◆ isPopup()

bool SdlRailWindow::isPopup ( ) const
nodiscard

Definition at line 452 of file sdl_rail_window.cpp.

453{
454 std::unique_lock lock(_gfxLock);
455 return _isPopup;
456}

◆ localMoveActive()

bool SdlRailWindow::localMoveActive ( ) const
nodiscard

Definition at line 184 of file sdl_rail_window.cpp.

185{
186 std::unique_lock lock(_gfxLock);
187 return _localMoveActive;
188}

◆ localMoveServerPos()

SDL_Point SdlRailWindow::localMoveServerPos ( ) const
nodiscard

Definition at line 196 of file sdl_rail_window.cpp.

197{
198 std::unique_lock lock(_gfxLock);
199 return _localMoveServerPos;
200}

◆ localMoveSizeChanged()

bool SdlRailWindow::localMoveSizeChanged ( ) const
nodiscard

Definition at line 190 of file sdl_rail_window.cpp.

191{
192 std::unique_lock lock(_gfxLock);
193 return _localMoveSizeChanged;
194}

◆ loopEndPending()

bool SdlRailWindow::loopEndPending ( ) const
nodiscard

Definition at line 291 of file sdl_rail_window.cpp.

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

◆ markDeleted()

void SdlRailWindow::markDeleted ( )

Definition at line 239 of file sdl_rail_window.cpp.

240{
241 std::unique_lock lock(_gfxLock);
242 _deleted = true;
243}

◆ 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 407 of file sdl_rail_window.cpp.

408{
409 std::unique_lock lock(_gfxLock);
410 armDeadline(_displayCheckAt, kDisplaySettleMs);
411}

◆ noteLocalRestore()

void SdlRailWindow::noteLocalRestore ( )

Definition at line 1230 of file sdl_rail_window.cpp.

1231{
1232 std::unique_lock lock(_gfxLock);
1233 _restoreRetried = false;
1234 armDeadline(_localRestoreUntil, kAwaitRestoreRectMs);
1235}

◆ notePlaced()

void SdlRailWindow::notePlaced ( )

Definition at line 614 of file sdl_rail_window.cpp.

615{
616 std::unique_lock lock(_gfxLock);
617 placeRequested();
618}

◆ outerRect()

SDL_Rect SdlRailWindow::outerRect ( ) const
nodiscard

Definition at line 561 of file sdl_rail_window.cpp.

562{
563 std::unique_lock lock(_gfxLock);
564 SDL_Rect r = addInsets(_windowRect, _appliedInsets);
565 r.x += _localShift.x;
566 r.y += _localShift.y;
567 return r;
568}

◆ owner()

uint64_t SdlRailWindow::owner ( ) const
nodiscard

Definition at line 446 of file sdl_rail_window.cpp.

447{
448 std::unique_lock lock(_gfxLock);
449 return _ownerId;
450}

◆ 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 1300 of file sdl_rail_window.cpp.

1303{
1304 if (!reconcile(parent, parentRect))
1305 return false;
1306
1307 auto ok = false;
1308 auto legacy = false;
1309 {
1310 std::unique_lock lock(_gfxLock);
1311 if (_hasGfx)
1312 ok = paintGfx(fallbackFormat);
1313 else
1314 legacy = true;
1315 }
1316 if (legacy)
1317 ok = paintLegacy(primary, damage);
1318
1319 /* Map in the same pass as the first frame, else the window defers a frame (menu lag). */
1320 if (_gfxPresented && !_mapped && !_minState.rail)
1321 {
1322 _mapped = true;
1323 WLog_DBG(TAG, "map id=0x%08" PRIx32 " %s", static_cast<uint32_t>(_id), role());
1324 SDL_ShowWindow(_win->window());
1325 /* Reassert target position after show to override stale events. */
1326 if (_isPopup && parent)
1327 {
1328 std::unique_lock lock(_gfxLock);
1329 const SDL_Rect vis = targetOuterRect();
1330 placePopup(vis, parentRect);
1331 }
1332 if (((!_isPopup && !_layered) || _fullscreen) && ((_exStyle & WS_EX_NOACTIVATE) == 0))
1333 _win->raise(); /* Bring app and fullscreen windows to front. */
1334 }
1335 return ok;
1336}
#define TAG

◆ placedRel()

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

Definition at line 674 of file sdl_rail_window.cpp.

675{
676 std::unique_lock lock(_gfxLock);
677 /* Only while moving: a resting popup may sit elsewhere (off screen), map it as on X11. */
678 if (!_placedRel || (SDL_GetTicks() - _requestedAt >= kMoveActiveMs))
679 return false;
680 rel = *_placedRel;
681 return true;
682}

◆ placePopup()

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

Definition at line 639 of file sdl_rail_window.cpp.

640{
641 const SDL_Point rel = { vis.x - parentRect.x, vis.y - parentRect.y };
642 const bool wayland = !railPlatformCaps().supportsWindowPositions;
643 const bool moved = (rel.x != _requestedRel.x) || (rel.y != _requestedRel.y);
644 if (wayland)
645 {
646 _requestedRel = rel;
647 _requestedAt = SDL_GetTicks();
648 }
649 if (!SDL_SetWindowPosition(_win->window(), rel.x, rel.y))
650 {
651 WLog_VRB(TAG, "popup reposition unsupported id=0x%08" PRIx32 ": %s",
652 static_cast<uint32_t>(_id), SDL_GetError());
653 return;
654 }
655 if (!wayland)
656 return;
657 _needsFullBlit = true; /* Wayland applies move on next surface commit */
658 if (!moved || !_mapped)
659 return;
660 _placeInFlight = true;
661 if (SDL_AddTimer(static_cast<Uint32>(kPlaceWaitMs + 1), placeWaitTimer, nullptr) == 0)
662 WLog_WARN(TAG, "popup placement timer failed: %s", SDL_GetError());
663}

◆ 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 830 of file sdl_rail_window.cpp.

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

◆ releaseWindow()

void SdlRailWindow::releaseWindow ( )

Definition at line 245 of file sdl_rail_window.cpp.

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

◆ renderer()

SDL_Renderer * SdlRailWindow::renderer ( ) const
nodiscard

Definition at line 111 of file sdl_rail_window.cpp.

112{
113 return _win ? _win->renderer() : nullptr;
114}

◆ resizeMargins()

SDL_Rect SdlRailWindow::resizeMargins ( ) const
nodiscard

Definition at line 376 of file sdl_rail_window.cpp.

377{
378 std::unique_lock lock(_gfxLock);
379 return _resizeMargins;
380}

◆ sdlId()

SDL_WindowID SdlRailWindow::sdlId ( ) const
nodiscard

Definition at line 101 of file sdl_rail_window.cpp.

102{
103 return _win ? _win->id() : 0;
104}

◆ serverOrigin()

SDL_Point SdlRailWindow::serverOrigin ( ) const
nodiscard

Definition at line 684 of file sdl_rail_window.cpp.

685{
686 std::unique_lock lock(_gfxLock);
687 /* Derive server coordinate from blit offset to match on-screen pixels. */
688 const SDL_Point dst = blitOffset();
689 return { _windowRect.x - dst.x, _windowRect.y - dst.y };
690}

◆ serverRect()

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

Definition at line 570 of file sdl_rail_window.cpp.

571{
572 SDL_Rect r = stripInsets(outer, insets());
573 r.x -= _localShift.x;
574 r.y -= _localShift.y;
575 return r;
576}

◆ setAppId()

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

Definition at line 724 of file sdl_rail_window.cpp.

725{
726 std::unique_lock lock(_gfxLock);
727 _appId = appId;
728 _appIdDirty = !appId.empty();
729}

◆ setFrame()

void SdlRailWindow::setFrame ( bool frame)

Definition at line 482 of file sdl_rail_window.cpp.

483{
484 std::unique_lock lock(_gfxLock);
485 _frame = frame;
486}

◆ setFrameMargins()

void SdlRailWindow::setFrameMargins ( const SDL_Rect & m)

Definition at line 382 of file sdl_rail_window.cpp.

383{
384 std::unique_lock lock(_gfxLock);
385 _frameMargins = m;
386}

◆ setIcon()

void SdlRailWindow::setIcon ( const SdlRailIcon & icon)

Definition at line 737 of file sdl_rail_window.cpp.

738{
739 std::unique_lock lock(_gfxLock);
740 _icon = icon;
741 _iconDirty = true;
742}

◆ setLocalMoveActive()

void SdlRailWindow::setLocalMoveActive ( bool active)

Definition at line 165 of file sdl_rail_window.cpp.

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

◆ setLocalShift()

void SdlRailWindow::setLocalShift ( const SDL_Point & shift)

Definition at line 578 of file sdl_rail_window.cpp.

579{
580 std::unique_lock lock(_gfxLock);
581 _localShift = shift;
582}

◆ setMinMaxSize()

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

Definition at line 354 of file sdl_rail_window.cpp.

355{
356 std::unique_lock lock(_gfxLock);
357 _minSize = { std::max(0, minSize.x), std::max(0, minSize.y) };
358 _maxSize = { std::max(0, maxSize.x), std::max(0, maxSize.y) };
359 _minMaxDirty = true;
360 /* Re-apply geometry on min/max change. */
361 _geometryDirty = true;
362}

◆ setOwner()

void SdlRailWindow::setOwner ( uint64_t ownerId)

Definition at line 440 of file sdl_rail_window.cpp.

441{
442 std::unique_lock lock(_gfxLock);
443 _ownerId = ownerId;
444}

◆ 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 176 of file sdl_rail_window.cpp.

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

◆ setResizeMargins()

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

Definition at line 364 of file sdl_rail_window.cpp.

365{
366 std::unique_lock lock(_gfxLock);
367 const SDL_Rect m = { left, top, right, bottom };
368 if (SDL_RectsEqual(&m, &_resizeMargins))
369 return;
370 _resizeMargins = m;
371 /* Margins usually arrive after the first frame; the window must regrow to cover them. */
372 if (!railMaximized())
373 _geometryDirty = true;
374}

◆ setServerMaximized()

void SdlRailWindow::setServerMaximized ( bool m)

Definition at line 1209 of file sdl_rail_window.cpp.

1210{
1211 setServerState(_maxState, m);
1212}

◆ setServerMinimized()

void SdlRailWindow::setServerMinimized ( bool m)

Definition at line 1214 of file sdl_rail_window.cpp.

1215{
1216 {
1217 std::unique_lock lock(_gfxLock);
1218 /* Late minimize of a window the user already restored. */
1219 if (m && (_localRestoreUntil != 0) && (SDL_GetTicks() < _localRestoreUntil))
1220 {
1221 _minState.server = true;
1222 return;
1223 }
1224 if (!m)
1225 _localRestoreUntil = 0;
1226 }
1227 setServerState(_minState, m);
1228}

◆ setShadowAnchored()

void SdlRailWindow::setShadowAnchored ( bool anchored)

Definition at line 476 of file sdl_rail_window.cpp.

477{
478 std::unique_lock lock(_gfxLock);
479 _shadowAnchored = anchored;
480}

◆ setStyle()

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

Definition at line 692 of file sdl_rail_window.cpp.

693{
694 std::unique_lock lock(_gfxLock);
695 const bool wasTopmost = _topmost;
696 _style = style;
697 _exStyle = exStyle;
698 _topmost = (exStyle & WS_EX_TOPMOST) != 0;
699 if (_topmost != wasTopmost)
700 _topmostDirty = true;
701 if (!_everResizable && ((style & (WS_THICKFRAME | WS_MAXIMIZEBOX)) != 0))
702 {
703 _everResizable = true;
704 _styleDirty = true;
705 }
706 /* Classify popup and layered window types once on creation. */
707 if (!_popupClassified)
708 {
709 const auto classification = classifySdlRailWindowStyle(style, exStyle, _ownerId != 0);
710 _isPopup = classification.popup;
711 _layered = classification.layered;
712 _overlay = classification.overlay;
713 _popupClassified = true;
714 }
715}

◆ setTitle()

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

Definition at line 717 of file sdl_rail_window.cpp.

718{
719 std::unique_lock lock(_gfxLock);
720 _title = title;
721 _titleDirty = true;
722}

◆ setVisibilityRects()

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

Definition at line 334 of file sdl_rail_window.cpp.

335{
336 std::unique_lock lock(_gfxLock);
337 _visRects = std::move(rects);
338 _visDirty = true;
339}

◆ setVisible()

void SdlRailWindow::setVisible ( bool visible)

Definition at line 731 of file sdl_rail_window.cpp.

732{
733 std::unique_lock lock(_gfxLock);
734 _visible = visible;
735}

◆ setVisibleOffset()

void SdlRailWindow::setVisibleOffset ( SDL_Point offset)

Definition at line 341 of file sdl_rail_window.cpp.

342{
343 std::unique_lock lock(_gfxLock);
344 /* Freeze visible offset during local move. */
345 if (_localMoveActive)
346 return;
347 if (_visOffsetSet && (offset.x == _visOffset.x) && (offset.y == _visOffset.y))
348 return;
349 _visOffset = offset;
350 _visOffsetSet = true;
351 _visDirty = true;
352}

◆ 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 413 of file sdl_rail_window.cpp.

414{
415 std::unique_lock lock(_gfxLock);
416 if ((_displayCheckAt == 0) || (!now && (SDL_GetTicks() < _displayCheckAt)))
417 return false;
418 _displayCheckAt = 0;
419 return true;
420}

◆ takeLoopEnd()

SdlRailWindow::LoopEndActions SdlRailWindow::takeLoopEnd ( )
nodiscard

Definition at line 316 of file sdl_rail_window.cpp.

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

◆ takeMaximizeAfterEcho()

bool SdlRailWindow::takeMaximizeAfterEcho ( )
nodiscard

Definition at line 431 of file sdl_rail_window.cpp.

432{
433 std::unique_lock lock(_gfxLock);
434 if (!_maximizeAfterEcho || !_reported.empty())
435 return false;
436 _maximizeAfterEcho = false;
437 return true;
438}

◆ takeRestoreRetry()

bool SdlRailWindow::takeRestoreRetry ( )
nodiscard

Definition at line 1237 of file sdl_rail_window.cpp.

1238{
1239 std::unique_lock lock(_gfxLock);
1240 return std::exchange(_restoreRetry, false);
1241}

◆ takeSurfaceChange()

bool SdlRailWindow::takeSurfaceChange ( uint32_t surfaceId)
nodiscard

Definition at line 1098 of file sdl_rail_window.cpp.

1099{
1100 std::unique_lock lock(_gfxLock);
1101 if (_surfaceId == surfaceId)
1102 return false;
1103 _surfaceId = surfaceId;
1104 return true;
1105}

◆ takeUnconfirmedReport()

bool SdlRailWindow::takeUnconfirmedReport ( SDL_Rect & rect)
nodiscard

Definition at line 394 of file sdl_rail_window.cpp.

395{
396 std::unique_lock lock(_gfxLock);
397 if ((_reportCheckAt == 0) || (SDL_GetTicks() < _reportCheckAt))
398 return false;
399 _reportCheckAt = 0;
400 if (_reported.empty())
401 return false;
402 rect = _reported.back();
403 _reported.clear();
404 return true;
405}

◆ takeWmOverride()

bool SdlRailWindow::takeWmOverride ( SDL_Rect & outer)
nodiscard

Definition at line 324 of file sdl_rail_window.cpp.

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

◆ 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 1107 of file sdl_rail_window.cpp.

1110{
1111 std::unique_lock lock(_gfxLock);
1112 /* The copies below are byte-for-byte; gdi_CreateSurface yields nothing else. */
1113 WINPR_ASSERT((format == PIXEL_FORMAT_BGRA32) || (format == PIXEL_FORMAT_BGRX32));
1114 /* Deep-copy GDI pixels to prevent UAF. */
1115 const size_t bytes = static_cast<size_t>(stride) * height;
1116 if (!data || (bytes == 0) || (width == 0) || (height == 0))
1117 {
1118 if (_hasGfx)
1119 WLog_DBG(TAG, "gfx cleared id=0x%08" PRIx32 " (surface unmapped)",
1120 static_cast<uint32_t>(_id));
1121 _gfxBuffer.clear();
1122 _hasGfx = false;
1123 _gfxDamage.clear();
1124 _gfxStride = stride;
1125 _gfxW = width;
1126 _gfxH = height;
1127 _gfxVisOrigin = { 0, 0 };
1128 return;
1129 }
1130
1131 const auto* src = static_cast<const uint8_t*>(data);
1132 /* Geometry/stride change, first frame, or no damage rects: full copy + repaint. */
1133 const bool full = !_hasGfx || (_gfxBuffer.size() != bytes) || (_gfxStride != stride) ||
1134 (_gfxW != width) || (_gfxH != height) || (nbDamage == 0);
1135 if (full)
1136 {
1137 const SDL_Rect bounds{ 0, 0, static_cast<int>(width), static_cast<int>(height) };
1138 /* Check _hasGfx first to avoid redundant full-surface blank checks once content exists. */
1139 if (!_hasGfx && regionIsBlank(src, stride, bounds))
1140 return;
1141 _gfxBuffer.assign(src, src + bytes);
1142 _gfxDamage.assign(1, SDL_Rect{ 0, 0, static_cast<int>(width), static_cast<int>(height) });
1143 _needsFullBlit = true;
1144 /* Blend real alpha, force opaque otherwise. */
1145 _gfxHasAlpha = honorsAlpha() &&
1146 regionHasAlpha(_gfxBuffer.data(), stride,
1147 { 0, 0, static_cast<int>(width), static_cast<int>(height) });
1148 }
1149 else
1150 {
1151 const SDL_Rect bounds{ 0, 0, static_cast<int>(width), static_cast<int>(height) };
1152 for (uint32_t i = 0; i < nbDamage; i++)
1153 {
1154 const SDL_Rect r{ damage[i].left, damage[i].top, damage[i].right - damage[i].left,
1155 damage[i].bottom - damage[i].top };
1156 SDL_Rect clip{};
1157 if (!SDL_GetRectIntersection(&r, &bounds, &clip))
1158 continue;
1159 std::ignore = freerdp_image_copy_no_overlap(
1160 _gfxBuffer.data(), PIXEL_FORMAT_BGRA32, stride, static_cast<UINT32>(clip.x),
1161 static_cast<UINT32>(clip.y), static_cast<UINT32>(clip.w),
1162 static_cast<UINT32>(clip.h), src, PIXEL_FORMAT_BGRA32, stride,
1163 static_cast<UINT32>(clip.x), static_cast<UINT32>(clip.y), nullptr,
1164 FREERDP_FLIP_NONE);
1165 _gfxDamage.push_back(clip);
1166 /* Alpha may first appear in a later incremental frame (e.g. a menu fading in). */
1167 if (honorsAlpha() && !_gfxHasAlpha && regionHasAlpha(_gfxBuffer.data(), stride, clip))
1168 _gfxHasAlpha = true;
1169 }
1170 /* A hidden window accumulates rects without ever painting; collapse to one full repaint. */
1171 if (_gfxDamage.size() > 32)
1172 _gfxDamage.assign(1,
1173 SDL_Rect{ 0, 0, static_cast<int>(width), static_cast<int>(height) });
1174 }
1175 if ((_gfxW != width) || (_gfxH != height))
1176 {
1177 _resizeAnchorRight = false;
1178 _resizeAnchorBottom = false;
1179 _needsFullBlit = true;
1180 /* Invalidate surface origin until visibility rect matching new dimensions arrives. */
1181 _gfxVisOrigin = { 0, 0 };
1182 }
1183 _hasGfx = true;
1184 _gfxStride = stride;
1185 _gfxW = width;
1186 _gfxH = height;
1187 WLog_VRB(TAG, "gfx id=0x%08" PRIx32 " %ux%u full=%d nDamage=%u", static_cast<uint32_t>(_id),
1188 width, height, full ? 1 : 0, nbDamage);
1189}

◆ updateWindowRect()

void SdlRailWindow::updateWindowRect ( const SDL_Rect & rect)

Definition at line 116 of file sdl_rail_window.cpp.

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

◆ window()

SDL_Window * SdlRailWindow::window ( ) const
nodiscard

Definition at line 106 of file sdl_rail_window.cpp.

107{
108 return _win ? _win->window() : nullptr;
109}

◆ windowRect()

SDL_Rect SdlRailWindow::windowRect ( ) const
nodiscard

Definition at line 233 of file sdl_rail_window.cpp.

234{
235 std::unique_lock lock(_gfxLock);
236 return _windowRect;
237}

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