20#include <freerdp/config.h>
22#include <winpr/assert.h>
24#include <freerdp/client/rail.h>
25#include <freerdp/client/cliprdr.h>
26#include <freerdp/client/disp.h>
27#include <freerdp/client/rdpgfx.h>
28#include <freerdp/channels/rdpgfx.h>
29#include <freerdp/channels/rdpewa.h>
31#include "sdl_channels.hpp"
32#include "sdl_context.hpp"
33#include "sdl_disp.hpp"
35void sdl_OnChannelConnectedEventHandler(
void* context,
const ChannelConnectedEventArgs* e)
37 auto sdl = get_context(context);
42 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
44 auto rail =
reinterpret_cast<RailClientContext*
>(e->pInterface);
47 if (!
sdl->getRailChannelContext().init(rail))
48 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize RAIL channel");
50 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
52 auto clip =
reinterpret_cast<CliprdrClientContext*
>(e->pInterface);
55 if (!
sdl->getClipboardChannelContext().init(clip))
56 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize clipboard channel");
58 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
60 auto disp =
reinterpret_cast<DispClientContext*
>(e->pInterface);
63 if (!
sdl->getDisplayChannelContext().init(disp))
64 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize display channel");
67 freerdp_client_OnChannelConnectedEventHandler(context, e);
68 if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
72 auto gfx =
reinterpret_cast<RdpgfxClientContext*
>(e->pInterface);
73 auto ctx =
static_cast<rdpContext*
>(context);
75 gfx->UpdateWindowFromSurface = SdlRail::UpdateWindowFromSurface;
79void sdl_OnChannelDisconnectedEventHandler(
void* context,
const ChannelDisconnectedEventArgs* e)
81 auto sdl = get_context(context);
91 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
93 auto rail =
reinterpret_cast<RailClientContext*
>(e->pInterface);
94 sdl->getRailChannelContext().uninit(rail);
95 rail->custom =
nullptr;
97 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
99 auto clip =
reinterpret_cast<CliprdrClientContext*
>(e->pInterface);
100 if (!
sdl->getClipboardChannelContext().uninit(clip))
101 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to uninitialize clipboard channel");
102 clip->custom =
nullptr;
104 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
106 auto disp =
reinterpret_cast<DispClientContext*
>(e->pInterface);
107 if (!
sdl->getDisplayChannelContext().uninit(disp))
108 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to uninitialize display channel");
109 disp->custom =
nullptr;
112 freerdp_client_OnChannelDisconnectedEventHandler(context, e);
115void sdl_OnUserNotificationEventHandler(
void* context,
const UserNotificationEventArgs* e)
117 WINPR_UNUSED(context);
119 WINPR_ASSERT(e->e.Sender);
121 if (strcmp(e->e.Sender, RDPEWA_CHANNEL_NAME) != 0)
124 if (e->cancelPreviousNotification)
131 uint32_t timeoutMS = 0;
134 auto ud =
new struct userdata;
136 ud->message = e->message;
138 ud->sender = e->e.Sender;
139 ud->timeoutMS = e->timeoutMS;
144 auto ed =
static_cast<struct userdata*
>(userdata);
146 auto parent = SDL_GetMouseFocus();
148 parent = SDL_GetKeyboardFocus();
149 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, ed->sender.c_str(),
150 ed->message.c_str(), parent);
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.