FreeRDP
Loading...
Searching...
No Matches
sdl_rail_platform.hpp
1
19#pragma once
20
21#include <cstdint>
22#include <vector>
23
24#include <SDL3/SDL.h>
25
26enum class RailPlatformKind
27{
28 None,
29 X11,
30 Wayland,
31 Win32
32};
33
34/* Window resize band integration mechanism. */
35enum class RailBandMechanism
36{
37 None,
38 FrameExtents, /* X11 _GTK_FRAME_EXTENTS, published before the resize */
39 NativeFrame /* Win32 sizing frame: the OS adds it outside the client area */
40};
41
42/* Drag and resize execution model. */
43enum class RailDragModel
44{
45 None, /* the server drags the window itself */
46 WmMoveResize, /* X11 _NET_WM_MOVERESIZE, ends with the button release */
47 CompositorResize, /* Wayland xdg_toplevel move/resize, the client only tracks the size */
48 ModalLoop /* Win32 SC_MOVE/SC_SIZE loop, blocks until the drag ends */
49};
50
55{
56 RailPlatformKind kind = RailPlatformKind::None;
57 bool supportsWindowPositions = true;
58 bool supportsTransparentWindows = true;
59 bool supportsRestack = false;
60 RailBandMechanism band = RailBandMechanism::None;
61 RailDragModel drag = RailDragModel::None;
62};
63
64/* Detected capabilities of the running SDL video backend (cached). */
65[[nodiscard]] const RailPlatformCaps& railPlatformCaps();
66
67/* Active drag edges for RAIL_WMSZ_*. */
69{
70 bool left = false;
71 bool right = false;
72 bool top = false;
73 bool bottom = false;
74};
75[[nodiscard]] RailEdges railEdges(uint16_t moveType);
76
77/* Per-window setup before the first drag (Wayland: bind the seat for the press serial). */
78void railPlatformPrepareWindow(SDL_Window* window);
79
80/* Place a window by its client rect where SDL cannot (Win32 native frame); false otherwise. */
81bool railPlatformSetWindowRect(SDL_Window* window, const SDL_Rect& rect);
82
83/* ModalLoop: redraw on the native loop's ticks; resize at start (RAIL_WMSZ_* edge) and end
84 * of a native-frame resize. A default handler unregisters. */
86{
87 void* userdata = nullptr;
88 void (*redraw)(void* userdata) = nullptr;
89 void (*resize)(void* userdata, SDL_WindowID id, int moveType, bool end) = nullptr;
90};
91void railPlatformSetNativeLoopHandler(const RailNativeLoopHandler& handler);
92
93/* Declare the band outside the content (x=L y=T w=R h=B) the way caps.band says. */
94bool railPlatformSetBand(SDL_Window* window, const SDL_Rect& insets);
95
96/* Restack windows top-to-bottom without activating them. */
97bool railPlatformRestack(const std::vector<SDL_Window*>& topToBottom);
98
99/* Start a local move (RAIL_WMSZ_MOVE) or resize (RAIL_WMSZ_* edge) the way caps.drag says. */
100bool railPlatformBeginDrag(SDL_Window* window, uint16_t moveType);
101
102/* ModalLoop platforms: run the native drag; blocks until it ends, so call it unlocked. */
103void railPlatformRunModalDrag(SDL_Window* window, uint16_t moveType);
104
105/* The WM kept the left button release of the drag; hand one to SDL. */
106bool railPlatformReleaseButton(SDL_Window* window);
107
108/* Put a reattached owned window back above its owner without activating it. */
109bool railPlatformRaiseOwned(SDL_Window* window);
110
111void railPlatformEndDrag(SDL_Window* window);