Skip to main content
The context is the central state object for an RDP client session. Every piece of connection state — settings, channels, GDI surface, input, update callbacks — lives on or is reachable from the context. FreeRDP provides two related types:

Lifecycle

1

Fill in entry points

Populate an RDP_CLIENT_ENTRY_POINTS struct with the sizes and callbacks for your client.
2

Allocate the context

freerdp_client_context_new() allocates the context using the size specified in ep.ContextSize, calls global init, then calls ClientNew.
3

Use the context

Access context->settings, context->instance, etc. to configure and drive the session.
4

Free the context

freerdp_client_context_free() calls ClientFree, tears down channels, and releases all memory.
If you are not using the higher-level freerdp_client_context_new() wrapper, you can allocate a bare freerdp instance with freerdp_new(), set instance->ContextSize, and then call freerdp_context_new() / freerdp_context_free() directly. The client-common wrapper is recommended for new code.

rdpContext Fields

The rdpContext struct is defined in include/freerdp/freerdp.h. Its key members are:
freerdp*
Back-pointer to the owning freerdp (rdp_freerdp) instance. Set by freerdp_context_new(). Use this to reach instance-level callbacks from context callbacks.
rdpSettings*
Pointer to the RDP settings for this session. Owned by the internal rdpRdp object; do not free separately. Use the freerdp_settings_* accessor functions to read and write values.
rdpChannels*
Virtual channel manager. Used internally to route channel data; clients typically interact with it through channel plug-in callbacks.
rdpInput*
Input interface. Send keyboard, mouse, and touch events to the remote server through this. Owned by rdpRdp.
rdpUpdate*
Update/display interface. Register BeginPaint, EndPaint, DesktopResize callbacks here in PostConnect.
rdpGdi*
GDI (graphics device interface) state. Allocated by gdi_init() during PostConnect; freed by gdi_free() during PostDisconnect.
rdpCache*
Bitmap/glyph/pointer cache. Managed internally.
rdpGraphics*
Graphics registration (bitmap/pointer/glyph codecs). Managed internally.
wPubSub*
Publish/subscribe bus. Use PubSub_SubscribeChannelConnected and PubSub_SubscribeChannelDisconnected here in PreConnect to react to dynamic channel events.
wLog*
WLog logger associated with this context.
UINT32
Last error code recorded on this context. Use freerdp_get_last_error() to read it.

rdpClientContext Fields

rdpClientContext (defined in include/freerdp/client.h) embeds rdpContext as its first member and adds client-specific fields:
rdpContext
Must be the first field. The embedded base context. Cast between rdpContext* and rdpClientContext* freely.
HANDLE
Handle to the client thread created by freerdp_client_start().
INT32
Last known mouse cursor position (client coordinates).
BOOL
Whether the local mouse is currently captured/grabbed by the RDP window.
FreeRDP_TouchContact[10]
Active touch contacts (up to FREERDP_MAX_TOUCH_CONTACTS = 10). Updated by freerdp_client_handle_touch().
FreeRDP_PenDevice[10]
Active pen devices (up to FREERDP_MAX_PEN_DEVICES = 10). Updated by freerdp_client_handle_pen().

Context Extension Pattern

The idiomatic FreeRDP pattern for carrying application-specific data is to embed rdpClientContext as the first member of your own struct, then tell FreeRDP about the larger size via ep.ContextSize.

ClientNew / ClientFree Callbacks

These callbacks are set on RDP_CLIENT_ENTRY_POINTS and called by FreeRDP during context allocation and deallocation:

Common Client Functions

Full Example