[client] make settings opaque

This commit is contained in:
akallabeth 2023-10-13 09:48:44 +02:00 committed by akallabeth
parent 1f236ade7a
commit 4e438d1c3e
39 changed files with 1443 additions and 902 deletions

View File

@ -22,7 +22,7 @@ UINT client_rail_server_start_cmd(RailClientContext* context)
clientStatus.flags = TS_RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE;
if (settings->AutoReconnectionEnabled)
if (freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled))
clientStatus.flags |= TS_RAIL_CLIENTSTATUS_AUTORECONNECT;
clientStatus.flags |= TS_RAIL_CLIENTSTATUS_ZORDER_SYNC;
@ -35,7 +35,7 @@ UINT client_rail_server_start_cmd(RailClientContext* context)
if (status != CHANNEL_RC_OK)
return status;
if (settings->RemoteAppLanguageBarSupported)
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteAppLanguageBarSupported))
{
RAIL_LANGBAR_INFO_ORDER langBarInfo;
langBarInfo.languageBarStatus = 0x00000008; /* TF_SFT_HIDDEN */
@ -68,25 +68,31 @@ UINT client_rail_server_start_cmd(RailClientContext* context)
sysparam.params |= SPI_MASK_SET_WORK_AREA;
sysparam.workArea.left = 0;
sysparam.workArea.top = 0;
sysparam.workArea.right = settings->DesktopWidth;
sysparam.workArea.bottom = settings->DesktopHeight;
sysparam.workArea.right = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
sysparam.workArea.bottom = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
sysparam.dragFullWindows = FALSE;
status = context->ClientSystemParam(context, &sysparam);
if (status != CHANNEL_RC_OK)
return status;
if (settings->RemoteApplicationFile && settings->RemoteApplicationCmdLine)
const char* RemoteApplicationFile =
freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationFile);
const char* RemoteApplicationCmdLine =
freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationCmdLine);
if (RemoteApplicationFile && RemoteApplicationCmdLine)
{
_snprintf(argsAndFile, ARRAYSIZE(argsAndFile), "%s %s", settings->RemoteApplicationCmdLine,
settings->RemoteApplicationFile);
_snprintf(argsAndFile, ARRAYSIZE(argsAndFile), "%s %s", RemoteApplicationCmdLine,
RemoteApplicationFile);
exec.RemoteApplicationArguments = argsAndFile;
}
else if (settings->RemoteApplicationFile)
exec.RemoteApplicationArguments = settings->RemoteApplicationFile;
else if (RemoteApplicationFile)
exec.RemoteApplicationArguments = RemoteApplicationFile;
else
exec.RemoteApplicationArguments = settings->RemoteApplicationCmdLine;
exec.RemoteApplicationProgram = settings->RemoteApplicationProgram;
exec.RemoteApplicationWorkingDir = settings->ShellWorkingDirectory;
exec.RemoteApplicationArguments = RemoteApplicationCmdLine;
exec.RemoteApplicationProgram =
freerdp_settings_get_string(settings, FreeRDP_RemoteApplicationProgram);
exec.RemoteApplicationWorkingDir =
freerdp_settings_get_string(settings, FreeRDP_ShellWorkingDirectory);
return context->ClientExecute(context, &exec);
}

View File

@ -176,7 +176,8 @@ static BOOL android_desktop_resize(rdpContext* context)
WINPR_ASSERT(context->instance);
freerdp_callback("OnGraphicsResize", "(JIII)V", (jlong)context->instance,
context->settings->DesktopWidth, context->settings->DesktopHeight,
freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopHeight),
freerdp_settings_get_uint32(context->settings, FreeRDP_ColorDepth));
return TRUE;
}
@ -300,8 +301,9 @@ static BOOL android_post_connect(freerdp* instance)
update->BeginPaint = android_begin_paint;
update->EndPaint = android_end_paint;
update->DesktopResize = android_desktop_resize;
freerdp_callback("OnSettingsChanged", "(JIII)V", (jlong)instance, settings->DesktopWidth,
settings->DesktopHeight,
freerdp_callback("OnSettingsChanged", "(JIII)V", (jlong)instance,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight),
freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth));
freerdp_callback("OnConnectionSuccess", "(J)V", (jlong)instance);
return TRUE;

View File

@ -92,10 +92,12 @@ static DWORD WINAPI mac_client_thread(void *param);
NSScreen *screen = [[NSScreen screens] objectAtIndex:0];
NSRect screenFrame = [screen frame];
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
settings->DesktopWidth = screenFrame.size.width;
settings->DesktopHeight = screenFrame.size.height;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, screenFrame.size.width))
return -1;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, screenFrame.size.height))
return -1;
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
}
else
@ -103,8 +105,8 @@ static DWORD WINAPI mac_client_thread(void *param);
[self exitFullScreenModeWithOptions:nil];
}
mfc->client_height = settings->DesktopHeight;
mfc->client_width = settings->DesktopWidth;
mfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
mfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
if (!(mfc->common.thread =
CreateThread(NULL, 0, mac_client_thread, (void *)context, 0, &mfc->mainThreadId)))
@ -849,14 +851,16 @@ BOOL mac_pre_connect(freerdp *instance)
settings = instance->context->settings;
WINPR_ASSERT(settings);
if (!settings->ServerHostname)
if (!freerdp_settings_get_string(settings, FreeRDP_ServerHostname))
{
WLog_ERR(TAG, "error: server hostname was not specified with /v:<server>[:port]");
return FALSE;
}
settings->OsMajorType = OSMAJORTYPE_MACINTOSH;
settings->OsMinorType = OSMINORTYPE_MACINTOSH;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_MACINTOSH))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_MACINTOSH))
return FALSE;
PubSub_SubscribeChannelConnected(instance->context->pubSub, mac_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
mac_OnChannelDisconnectedEventHandler);
@ -1003,26 +1007,32 @@ static BOOL mac_authenticate_raw(freerdp *instance, char **username, char **pass
{
case AUTH_SMARTCARD_PIN:
pinOnly = TRUE;
title = [NSString stringWithFormat:@"%@:%u",
[NSString stringWithCString:settings->ServerHostname
encoding:NSUTF8StringEncoding],
settings -> ServerPort];
title = [NSString
stringWithFormat:@"%@:%u",
[NSString stringWithCString:freerdp_settings_get_string(
settings, FreeRDP_ServerHostname)
encoding:NSUTF8StringEncoding],
settings -> ServerPort];
break;
case AUTH_TLS:
case AUTH_RDP:
case AUTH_NLA:
title = [NSString stringWithFormat:@"%@:%u",
[NSString stringWithCString:settings->ServerHostname
encoding:NSUTF8StringEncoding],
settings -> ServerPort];
title = [NSString
stringWithFormat:@"%@:%u",
[NSString stringWithCString:freerdp_settings_get_string(
settings, FreeRDP_ServerHostname)
encoding:NSUTF8StringEncoding],
settings -> ServerPort];
break;
case GW_AUTH_HTTP:
case GW_AUTH_RDG:
case GW_AUTH_RPC:
title = [NSString stringWithFormat:@"%@:%u",
[NSString stringWithCString:settings->GatewayHostname
encoding:NSUTF8StringEncoding],
settings -> GatewayPort];
title = [NSString
stringWithFormat:@"%@:%u",
[NSString stringWithCString:freerdp_settings_get_string(
settings, FreeRDP_GatewayHostname)
encoding:NSUTF8StringEncoding],
settings -> GatewayPort];
break;
default:
return FALSE;
@ -1359,8 +1369,8 @@ BOOL mac_end_paint(rdpContext *context)
ww = mfc->client_width;
wh = mfc->client_height;
dw = mfc->common.context.settings->DesktopWidth;
dh = mfc->common.context.settings->DesktopHeight;
dw = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopWidth);
dh = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopHeight);
if ((!context) || (!context->gdi))
return FALSE;
@ -1374,7 +1384,8 @@ BOOL mac_end_paint(rdpContext *context)
newDrawRect.size.width = invalid->w;
newDrawRect.size.height = invalid->h;
if (mfc->common.context.settings->SmartSizing && (ww != dw || wh != dh))
if (freerdp_settings_get_bool(mfc->common.context.settings, FreeRDP_SmartSizing) &&
(ww != dw || wh != dh))
{
newDrawRect.origin.y = newDrawRect.origin.y * wh / dh - 1;
newDrawRect.size.height = newDrawRect.size.height * wh / dh + 1;
@ -1415,8 +1426,8 @@ BOOL mac_desktop_resize(rdpContext *context)
CGContextRef old_context = view->bitmap_context;
view->bitmap_context = NULL;
CGContextRelease(old_context);
mfc->width = settings->DesktopWidth;
mfc->height = settings->DesktopHeight;
mfc->width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
mfc->height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (!gdi_resize(context->gdi, mfc->width, mfc->height))
return FALSE;
@ -1430,8 +1441,8 @@ BOOL mac_desktop_resize(rdpContext *context)
mfc->client_height = mfc->height;
[view setFrameSize:NSMakeSize(mfc->width, mfc->height)];
EventArgsInit(&e, "mfreerdp");
e.width = settings->DesktopWidth;
e.height = settings->DesktopHeight;
e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
PubSub_OnResizeWindow(context->pubSub, context, &e);
return TRUE;
}

View File

@ -51,9 +51,12 @@ static int mfreerdp_client_start(rdpContext *context)
if (mfc->view == NULL)
{
// view not specified beforehand. Create view dynamically
mfc->view =
[[MRDPView alloc] initWithFrame:NSMakeRect(0, 0, context->settings->DesktopWidth,
context->settings->DesktopHeight)];
mfc->view = [[MRDPView alloc]
initWithFrame:NSMakeRect(
0, 0,
freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(context->settings,
FreeRDP_DesktopHeight))];
mfc->view_ownership = TRUE;
}
@ -117,10 +120,11 @@ static void mf_scale_mouse_coordinates(mfContext *mfc, UINT16 *px, UINT16 *py)
UINT16 y = *py;
UINT32 ww = mfc->client_width;
UINT32 wh = mfc->client_height;
UINT32 dw = mfc->common.context.settings->DesktopWidth;
UINT32 dh = mfc->common.context.settings->DesktopHeight;
UINT32 dw = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopWidth);
UINT32 dh = freerdp_settings_get_uint32(mfc->common.context.settings, FreeRDP_DesktopHeight);
if (!mfc->common.context.settings->SmartSizing || ((ww == dw) && (wh == dh)))
if (!freerdp_settings_get_bool(mfc->common.context.settings, FreeRDP_SmartSizing) ||
((ww == dw) && (wh == dh)))
{
y = y + mfc->yCurrentScroll;
x = x + mfc->xCurrentScroll;

View File

@ -46,13 +46,16 @@ BOOL sdlDispContext::settings_changed()
if (_lastSentHeight != _targetHeight)
return TRUE;
if (_lastSentDesktopOrientation != settings->DesktopOrientation)
if (_lastSentDesktopOrientation !=
freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation))
return TRUE;
if (_lastSentDesktopScaleFactor != settings->DesktopScaleFactor)
if (_lastSentDesktopScaleFactor !=
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor))
return TRUE;
if (_lastSentDeviceScaleFactor != settings->DeviceScaleFactor)
if (_lastSentDeviceScaleFactor !=
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor))
return TRUE;
/* TODO
if (_fullscreen != _sdl->fullscreen)
@ -70,9 +73,9 @@ BOOL sdlDispContext::update_last_sent()
_lastSentWidth = _targetWidth;
_lastSentHeight = _targetHeight;
_lastSentDesktopOrientation = settings->DesktopOrientation;
_lastSentDesktopScaleFactor = settings->DesktopScaleFactor;
_lastSentDeviceScaleFactor = settings->DeviceScaleFactor;
_lastSentDesktopOrientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
_lastSentDesktopScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
_lastSentDeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
// TODO _fullscreen = _sdl->fullscreen;
return TRUE;
}
@ -96,9 +99,12 @@ BOOL sdlDispContext::sendResize()
if (!settings_changed())
return TRUE;
if (_sdl->fullscreen && (settings->MonitorCount > 0))
const UINT32 mcount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount);
if (_sdl->fullscreen && (mcount > 0))
{
if (sendLayout(settings->MonitorDefArray, settings->MonitorCount) != CHANNEL_RC_OK)
auto monitors = static_cast<const rdpMonitor*>(
freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray));
if (sendLayout(monitors, mcount) != CHANNEL_RC_OK)
return FALSE;
}
else
@ -108,9 +114,10 @@ BOOL sdlDispContext::sendResize()
layout.Top = layout.Left = 0;
layout.Width = _targetWidth;
layout.Height = _targetHeight;
layout.Orientation = settings->DesktopOrientation;
layout.DesktopScaleFactor = settings->DesktopScaleFactor;
layout.DeviceScaleFactor = settings->DeviceScaleFactor;
layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
layout.DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
layout.PhysicalWidth = _targetWidth;
layout.PhysicalHeight = _targetHeight;
@ -155,7 +162,7 @@ void sdlDispContext::OnActivated(void* context, const ActivatedEventArgs* e)
sdlDisp->_waitingResize = FALSE;
if (sdlDisp->_activated && !settings->Fullscreen)
if (sdlDisp->_activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
sdlDisp->set_window_resizable();
@ -178,7 +185,7 @@ void sdlDispContext::OnGraphicsReset(void* context, const GraphicsResetEventArgs
sdlDisp->_waitingResize = FALSE;
if (sdlDisp->_activated && !settings->Fullscreen)
if (sdlDisp->_activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
sdlDisp->set_window_resizable();
sdlDisp->sendResize();
@ -195,7 +202,7 @@ void sdlDispContext::OnTimer(void* context, const TimerEventArgs* e)
if (!sdl_disp_check_context(context, &sdl, &sdlDisp, &settings))
return;
if (!sdlDisp->_activated || settings->Fullscreen)
if (!sdlDisp->_activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
return;
sdlDisp->sendResize();
@ -255,8 +262,10 @@ UINT sdlDispContext::sendLayout(const rdpMonitor* monitors, size_t nmonitors)
break;
}
layout->DesktopScaleFactor = settings->DesktopScaleFactor;
layout->DeviceScaleFactor = settings->DeviceScaleFactor;
layout->DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout->DeviceScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
}
WINPR_ASSERT(_disp);
@ -353,7 +362,7 @@ UINT sdlDispContext::DisplayControlCaps(UINT32 maxNumMonitors, UINT32 maxMonitor
maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
_activated = TRUE;
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
return CHANNEL_RC_OK;
WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable");
@ -373,7 +382,7 @@ BOOL sdlDispContext::init(DispClientContext* disp)
_disp = disp;
disp->custom = this;
if (settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
{
disp->DisplayControlCaps = sdlDispContext::DisplayControlCaps;
}
@ -401,8 +410,8 @@ sdlDispContext::sdlDispContext(SdlContext* sdl) : _sdl(sdl)
auto settings = _sdl->context()->settings;
auto pubSub = _sdl->context()->pubSub;
_lastSentWidth = _targetWidth = settings->DesktopWidth;
_lastSentHeight = _targetHeight = settings->DesktopHeight;
_lastSentWidth = _targetWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
_lastSentHeight = _targetHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
PubSub_SubscribeActivated(pubSub, sdlDispContext::OnActivated);
PubSub_SubscribeGraphicsReset(pubSub, sdlDispContext::OnGraphicsReset);
PubSub_SubscribeTimer(pubSub, sdlDispContext::OnTimer);

View File

@ -530,7 +530,8 @@ static BOOL sdl_desktop_resize(rdpContext* context)
WINPR_ASSERT(settings);
gdi = context->gdi;
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
return FALSE;
return sdl_create_primary(sdl);
}
@ -574,9 +575,11 @@ static BOOL sdl_pre_connect(freerdp* instance)
WINPR_ASSERT(settings);
/* Optional OS identifier sent to server */
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_SDL;
/* settings->OrderSupport is initialized at this point.
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_SDL))
return FALSE;
/* OrderSupport is initialized at this point.
* Only override it if you plan to implement custom order
* callbacks or deactiveate certain features. */
/* Register the channel listeners.
@ -600,8 +603,10 @@ static BOOL sdl_pre_connect(freerdp* instance)
!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
{
WLog_Print(sdl->log, WLOG_INFO, "Update size to %ux%u", maxWidth, maxHeight);
settings->DesktopWidth = maxWidth;
settings->DesktopHeight = maxHeight;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, maxWidth))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, maxHeight))
return FALSE;
}
}
else
@ -685,10 +690,11 @@ static BOOL sdl_create_windows(SdlContext* sdl)
Uint32 w = monitor->width;
Uint32 h = monitor->height;
if (!(settings->UseMultimon || settings->Fullscreen))
if (!(freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) ||
freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)))
{
w = settings->DesktopWidth;
h = settings->DesktopHeight;
w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
sdl_window_t window = {};
@ -703,12 +709,13 @@ static BOOL sdl_create_windows(SdlContext* sdl)
#endif
}
if (settings->Fullscreen && !settings->UseMultimon)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) &&
!freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
flags |= SDL_WINDOW_FULLSCREEN;
}
if (settings->UseMultimon)
if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
flags |= SDL_WINDOW_BORDERLESS;
}
@ -723,7 +730,7 @@ static BOOL sdl_create_windows(SdlContext* sdl)
if (!window.window)
goto fail;
if (settings->UseMultimon)
if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
int win_x;
int win_y;
@ -1093,7 +1100,8 @@ static BOOL sdl_post_connect(freerdp* instance)
context->update->SetKeyboardImeStatus = sdlInput::keyboard_set_ime_status;
sdl->update_resizeable(FALSE);
sdl->update_fullscreen(context->settings->Fullscreen || context->settings->UseMultimon);
sdl->update_fullscreen(freerdp_settings_get_bool(context->settings, FreeRDP_Fullscreen) ||
freerdp_settings_get_bool(context->settings, FreeRDP_UseMultimon));
return TRUE;
}
@ -1522,7 +1530,7 @@ int main(int argc, char* argv[])
if (status)
{
rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
if (settings->ListMonitors)
if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors))
sdl_list_monitors(sdl);
return rc;
}

View File

@ -87,12 +87,15 @@ static BOOL sdl_is_monitor_id_active(SdlContext* sdl, UINT32 id)
settings = sdl->context()->settings;
WINPR_ASSERT(settings);
if (!settings->NumMonitorIds)
const UINT32 NumMonitorIds = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
if (!NumMonitorIds)
return TRUE;
for (index = 0; index < settings->NumMonitorIds; index++)
for (index = 0; index < NumMonitorIds; index++)
{
if (settings->MonitorIds[index] == id)
auto cur = static_cast<const UINT32*>(
freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, index));
if (cur && (*cur == id))
return TRUE;
}
@ -111,23 +114,24 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH
*pMaxWidth = 0;
*pMaxHeight = 0;
for (size_t x = 0; x < settings->MonitorCount; x++)
for (size_t x = 0; x < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); x++)
{
const rdpMonitor* monitor = &settings->MonitorDefArray[x];
auto monitor = static_cast<const rdpMonitor*>(
freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, x));
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
*pMaxWidth = monitor->width;
*pMaxHeight = monitor->height;
}
else if (settings->Workarea)
else if (freerdp_settings_get_bool(settings, FreeRDP_Workarea))
{
SDL_Rect rect = {};
SDL_GetDisplayUsableBounds(monitor->orig_screen, &rect);
*pMaxWidth = rect.w;
*pMaxHeight = rect.h;
}
else if (settings->PercentScreen)
else if (freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) > 0)
{
SDL_Rect rect = {};
SDL_GetDisplayUsableBounds(monitor->orig_screen, &rect);
@ -135,16 +139,19 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH
*pMaxWidth = rect.w;
*pMaxHeight = rect.h;
if (settings->PercentScreenUseWidth)
*pMaxWidth = (rect.w * settings->PercentScreen) / 100;
if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth))
*pMaxWidth =
(rect.w * freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / 100;
if (settings->PercentScreenUseHeight)
*pMaxHeight = (rect.h * settings->PercentScreen) / 100;
if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight))
*pMaxHeight =
(rect.h * freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) / 100;
}
else if (settings->DesktopWidth && settings->DesktopHeight)
else if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) &&
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))
{
*pMaxWidth = settings->DesktopWidth;
*pMaxHeight = settings->DesktopHeight;
*pMaxWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
*pMaxHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
}
return TRUE;
@ -266,12 +273,14 @@ static BOOL sdl_detect_single_window(SdlContext* sdl, UINT32* pMaxWidth, UINT32*
rdpSettings* settings = sdl->context()->settings;
WINPR_ASSERT(settings);
if ((!settings->UseMultimon && !settings->SpanMonitors) ||
(settings->Workarea && !settings->RemoteApplicationMode))
if ((!freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) &&
!freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors)) ||
(freerdp_settings_get_bool(settings, FreeRDP_Workarea) &&
!freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode)))
{
/* If no monitors were specified on the command-line then set the current monitor as active
*/
if (!settings->NumMonitorIds)
if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) == 0)
{
const size_t id =
(sdl->windows.size() > 0) ? SDL_GetWindowDisplayIndex(sdl->windows[0].window) : 0;
@ -285,7 +294,8 @@ static BOOL sdl_detect_single_window(SdlContext* sdl, UINT32* pMaxWidth, UINT32*
* If the monitor is invalid then we will default back to current monitor
* later as a fallback. So, there is no need to validate command-line entry here.
*/
settings->NumMonitorIds = 1;
if (!freerdp_settings_set_uint32(settings, FreeRDP_NumMonitorIds, 1))
return FALSE;
}
// TODO: Fill monitor struct

View File

@ -71,7 +71,7 @@ BOOL sdl_scale_coordinates(SdlContext* sdl, Uint32 windowId, INT32* px, INT32* p
break;
}
if (sdl->context()->settings->SmartSizing)
if (freerdp_settings_get_bool(sdl->context()->settings, FreeRDP_SmartSizing))
{
if (!fromLocalToRDP)
{

View File

@ -99,7 +99,8 @@ static BOOL tf_desktop_resize(rdpContext* context)
WINPR_ASSERT(settings);
gdi = context->gdi;
return gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight);
return gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
}
/* This function is called to output a System BEEP */
@ -147,9 +148,11 @@ static BOOL tf_pre_connect(freerdp* instance)
WINPR_ASSERT(settings);
/* Optional OS identifier sent to server */
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_XSERVER;
/* settings->OrderSupport is initialized at this point.
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_XSERVER))
return FALSE;
/* OrderSupport is initialized at this point.
* Only override it if you plan to implement custom order
* callbacks or deactiveate certain features. */
/* Register the channel listeners.
@ -234,7 +237,7 @@ static DWORD WINAPI tf_client_thread_proc(LPVOID arg)
WINPR_ASSERT(instance->context);
WINPR_ASSERT(instance->context->settings);
if (instance->context->settings->AuthenticationOnly)
if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_AuthenticationOnly))
{
result = freerdp_get_last_error(instance->context);
freerdp_abort_connect_context(instance->context);

View File

@ -62,13 +62,16 @@ static BOOL wlf_disp_settings_changed(wlfDispContext* wlfDisp)
if (wlfDisp->lastSentHeight != wlfDisp->targetHeight)
return TRUE;
if (wlfDisp->lastSentDesktopOrientation != settings->DesktopOrientation)
if (wlfDisp->lastSentDesktopOrientation !=
freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation))
return TRUE;
if (wlfDisp->lastSentDesktopScaleFactor != settings->DesktopScaleFactor)
if (wlfDisp->lastSentDesktopScaleFactor !=
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor))
return TRUE;
if (wlfDisp->lastSentDeviceScaleFactor != settings->DeviceScaleFactor)
if (wlfDisp->lastSentDeviceScaleFactor !=
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor))
return TRUE;
if (wlfDisp->fullscreen != wlfDisp->wlc->fullscreen)
@ -89,9 +92,12 @@ static BOOL wlf_update_last_sent(wlfDispContext* wlfDisp)
wlfDisp->lastSentWidth = wlfDisp->targetWidth;
wlfDisp->lastSentHeight = wlfDisp->targetHeight;
wlfDisp->lastSentDesktopOrientation = settings->DesktopOrientation;
wlfDisp->lastSentDesktopScaleFactor = settings->DesktopScaleFactor;
wlfDisp->lastSentDeviceScaleFactor = settings->DeviceScaleFactor;
wlfDisp->lastSentDesktopOrientation =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation);
wlfDisp->lastSentDesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
wlfDisp->lastSentDeviceScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
wlfDisp->fullscreen = wlfDisp->wlc->fullscreen;
return TRUE;
}
@ -123,11 +129,11 @@ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp)
return TRUE;
/* TODO: Multimonitor support for wayland
if (wlc->fullscreen && (settings->MonitorCount > 0))
if (wlc->fullscreen && (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount > 0))
{
if (wlf_disp_sendLayout(wlfDisp->disp, settings->MonitorDefArray,
settings->MonitorCount) != CHANNEL_RC_OK)
return FALSE;
if (wlf_disp_sendLayout(wlfDisp->disp, setings->MonitorDefArray,
freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) !=
CHANNEL_RC_OK) return FALSE;
}
else
*/
@ -137,9 +143,10 @@ static BOOL wlf_disp_sendResize(wlfDispContext* wlfDisp)
layout.Top = layout.Left = 0;
layout.Width = wlfDisp->targetWidth;
layout.Height = wlfDisp->targetHeight;
layout.Orientation = settings->DesktopOrientation;
layout.DesktopScaleFactor = settings->DesktopScaleFactor;
layout.DeviceScaleFactor = settings->DeviceScaleFactor;
layout.Orientation = freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation);
layout.DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
layout.PhysicalWidth = wlfDisp->targetWidth;
layout.PhysicalHeight = wlfDisp->targetHeight;
@ -190,7 +197,7 @@ static void wlf_disp_OnActivated(void* context, const ActivatedEventArgs* e)
wlfDisp->waitingResize = FALSE;
if (wlfDisp->activated && !settings->Fullscreen)
if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
wlf_disp_set_window_resizable(wlfDisp);
@ -213,7 +220,7 @@ static void wlf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs
wlfDisp->waitingResize = FALSE;
if (wlfDisp->activated && !settings->Fullscreen)
if (wlfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
wlf_disp_set_window_resizable(wlfDisp);
wlf_disp_sendResize(wlfDisp);
@ -230,7 +237,7 @@ static void wlf_disp_OnTimer(void* context, const TimerEventArgs* e)
if (!wlf_disp_check_context(context, &wlc, &wlfDisp, &settings))
return;
if (!wlfDisp->activated || settings->Fullscreen)
if (!wlfDisp->activated || freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
return;
wlf_disp_sendResize(wlfDisp);
@ -253,8 +260,10 @@ wlfDispContext* wlf_disp_new(wlfContext* wlc)
return NULL;
ret->wlc = wlc;
ret->lastSentWidth = ret->targetWidth = settings->DesktopWidth;
ret->lastSentHeight = ret->targetHeight = settings->DesktopHeight;
ret->lastSentWidth = ret->targetWidth =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
ret->lastSentHeight = ret->targetHeight =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
PubSub_SubscribeActivated(pubSub, wlf_disp_OnActivated);
PubSub_SubscribeGraphicsReset(pubSub, wlf_disp_OnGraphicsReset);
PubSub_SubscribeTimer(pubSub, wlf_disp_OnTimer);
@ -342,8 +351,10 @@ UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, si
break;
}
layout->DesktopScaleFactor = settings->DesktopScaleFactor;
layout->DeviceScaleFactor = settings->DeviceScaleFactor;
layout->DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout->DeviceScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
}
ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, nmonitors, layouts);
@ -383,7 +394,7 @@ static UINT wlf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitor
maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
wlfDisp->activated = TRUE;
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
return CHANNEL_RC_OK;
WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable");
@ -405,7 +416,7 @@ BOOL wlf_disp_init(wlfDispContext* wlfDisp, DispClientContext* disp)
wlfDisp->disp = disp;
disp->custom = (void*)wlfDisp;
if (settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
{
disp->DisplayControlCaps = wlf_DisplayControlCaps;
}

View File

@ -331,7 +331,8 @@ BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev)
return FALSE;
WINPR_ASSERT(instance->context);
if (instance->context->settings->GrabKeyboard && ev->raw_key == KEY_RIGHTCTRL)
if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard) &&
ev->raw_key == KEY_RIGHTCTRL)
wlf_handle_ungrab_key(instance, ev);
input = instance->context->input;

View File

@ -101,7 +101,8 @@ static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
area.bottom = (UINT16)pointer->height;
if (!wlf_copy_image(ptr->data, pointer->width * 4, pointer->width, pointer->height, data, w * 4,
w, h, &area, context->settings->SmartSizing))
w, h, &area,
freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing)))
goto fail;
rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y);

View File

@ -91,9 +91,10 @@ static BOOL wl_update_buffer(wlfContext* context_w, INT32 ix, INT32 iy, INT32 iw
area.right = x + w;
area.bottom = y + h;
if (!wlf_copy_image(gdi->primary_buffer, gdi->stride, gdi->width, gdi->height, data, stride,
geometry.width, geometry.height, &area,
context_w->common.context.settings->SmartSizing))
if (!wlf_copy_image(
gdi->primary_buffer, gdi->stride, gdi->width, gdi->height, data, stride, geometry.width,
geometry.height, &area,
freerdp_settings_get_bool(context_w->common.context.settings, FreeRDP_SmartSizing)))
goto fail;
if (!wlf_scale_coordinates(&context_w->common.context, &x, &y, FALSE))
@ -161,7 +162,8 @@ static BOOL wl_resize_display(rdpContext* context)
rdpGdi* gdi = context->gdi;
rdpSettings* settings = context->settings;
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
return FALSE;
return wl_refresh_display(wlc);
@ -183,21 +185,27 @@ static BOOL wl_pre_connect(freerdp* instance)
settings = instance->context->settings;
WINPR_ASSERT(settings);
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_WAYLAND;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_WAYLAND))
return FALSE;
PubSub_SubscribeChannelConnected(instance->context->pubSub, wlf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
wlf_OnChannelDisconnectedEventHandler);
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
// Use the resolution of the first display output
output = UwacDisplayGetOutput(context->display, 0);
if ((output != NULL) && (UwacOutputGetResolution(output, &resolution) == UWAC_SUCCESS))
{
settings->DesktopWidth = (UINT32)resolution.width;
settings->DesktopHeight = (UINT32)resolution.height;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth,
(UINT32)resolution.width))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight,
(UINT32)resolution.height))
return FALSE;
}
else
{
@ -224,8 +232,9 @@ static BOOL wl_post_connect(freerdp* instance)
context = (wlfContext*)instance->context;
settings = instance->context->settings;
if (settings->WindowTitle)
title = settings->WindowTitle;
const char* wtitle = freerdp_settings_get_string(settings, FreeRDP_WindowTitle);
if (wtitle)
title = wtitle;
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
return FALSE;
@ -241,13 +250,15 @@ static BOOL wl_post_connect(freerdp* instance)
w = (UINT32)gdi->width;
h = (UINT32)gdi->height;
if (settings->SmartSizing && !context->fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && !context->fullscreen)
{
if (settings->SmartSizingWidth > 0)
w = settings->SmartSizingWidth;
const UINT32 sw = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth);
if (sw > 0)
w = sw;
if (settings->SmartSizingHeight > 0)
h = settings->SmartSizingHeight;
const UINT32 sh = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight);
if (sh > 0)
h = sh;
}
context->window = window = UwacCreateWindowShm(context->display, w, h, WL_SHM_FORMAT_XRGB8888);
@ -255,14 +266,19 @@ static BOOL wl_post_connect(freerdp* instance)
if (!window)
return FALSE;
UwacWindowSetFullscreenState(window, NULL, instance->context->settings->Fullscreen);
UwacWindowSetFullscreenState(
window, NULL, freerdp_settings_get_bool(instance->context->settings, FreeRDP_Fullscreen));
UwacWindowSetTitle(window, title);
UwacWindowSetAppId(window, app_id);
UwacWindowSetOpaqueRegion(context->window, 0, 0, w, h);
instance->context->update->EndPaint = wl_end_paint;
instance->context->update->DesktopResize = wl_resize_display;
freerdp_keyboard_init_ex(instance->context->settings->KeyboardLayout,
instance->context->settings->KeyboardRemappingList);
UINT32 KeyboardLayout =
freerdp_settings_get_uint32(instance->context->settings, FreeRDP_KeyboardLayout);
const char* KeyboardRemappingList =
freerdp_settings_get_string(instance->context->settings, FreeRDP_KeyboardRemappingList);
freerdp_keyboard_init_ex(KeyboardLayout, KeyboardRemappingList);
if (!(context->disp = wlf_disp_new(context)))
return FALSE;
@ -393,7 +409,7 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
break;
case UWAC_EVENT_KEYBOARD_ENTER:
if (instance->context->settings->GrabKeyboard)
if (freerdp_settings_get_bool(instance->context->settings, FreeRDP_GrabKeyboard))
UwacSeatInhibitShortcuts(event.keyboard_enter_leave.seat, true);
if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave))
@ -693,7 +709,7 @@ int main(int argc, char* argv[])
{
rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
if (settings->ListMonitors)
if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors))
wlf_list_monitors(wlc);
goto fail;
@ -759,7 +775,7 @@ BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fro
if (!context || !px || !py || !context->gdi)
return FALSE;
if (!context->settings->SmartSizing)
if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))
return TRUE;
gdi = context->gdi;

View File

@ -176,11 +176,14 @@ static BOOL wf_desktop_resize(rdpContext* context)
{
same = (wfc->primary == wfc->drawing) ? TRUE : FALSE;
wf_image_free(wfc->primary);
wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight,
context->gdi->dstFormat, NULL);
wfc->primary =
wf_image_new(wfc, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight),
context->gdi->dstFormat, NULL);
}
if (!gdi_resize_ex(context->gdi, settings->DesktopWidth, settings->DesktopHeight, 0,
if (!gdi_resize_ex(context->gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), 0,
context->gdi->dstFormat, wfc->primary->pdata, NULL))
return FALSE;
@ -189,9 +192,11 @@ static BOOL wf_desktop_resize(rdpContext* context)
if (wfc->fullscreen != TRUE)
{
if (wfc->hwnd && !settings->SmartSizing)
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x,
settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE);
if (wfc->hwnd && !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y,
SWP_NOMOVE);
}
else
{
@ -219,24 +224,28 @@ static BOOL wf_pre_connect(freerdp* instance)
context = instance->context;
wfc = (wfContext*)instance->context;
settings = context->settings;
settings->OsMajorType = OSMAJORTYPE_WINDOWS;
settings->OsMinorType = OSMINORTYPE_WINDOWS_NT;
wfc->fullscreen = settings->Fullscreen;
wfc->fullscreen_toggle = settings->ToggleFullscreen;
desktopWidth = settings->DesktopWidth;
desktopHeight = settings->DesktopHeight;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_WINDOWS))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_WINDOWS_NT))
return FALSE;
wfc->fullscreen = freerdp_settings_get_bool(settings, FreeRDP_Fullscreen);
wfc->fullscreen_toggle = freerdp_settings_get_bool(settings, FreeRDP_ToggleFullscreen);
desktopWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
desktopHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (wfc->percentscreen > 0)
{
desktopWidth = (GetSystemMetrics(SM_CXSCREEN) * wfc->percentscreen) / 100;
settings->DesktopWidth = desktopWidth;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, desktopWidth))
return FALSE;
desktopHeight = (GetSystemMetrics(SM_CYSCREEN) * wfc->percentscreen) / 100;
settings->DesktopHeight = desktopHeight;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, desktopHeight))
return FALSE;
}
if (wfc->fullscreen)
{
if (settings->UseMultimon)
if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
desktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
desktopHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
@ -252,12 +261,12 @@ static BOOL wf_pre_connect(freerdp* instance)
* otherwise the screen will crash when connecting to an XP desktop.*/
desktopWidth = (desktopWidth + 3) & (~3);
if (desktopWidth != settings->DesktopWidth)
if (desktopWidth != freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth))
{
freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, desktopWidth);
}
if (desktopHeight != settings->DesktopHeight)
if (desktopHeight != freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))
{
freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, desktopHeight);
}
@ -294,7 +303,7 @@ static void wf_add_system_menu(wfContext* wfc)
return;
}
if (wfc->common.context.settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_DynamicResolutionUpdate))
{
return;
}
@ -305,12 +314,12 @@ static void wf_add_system_menu(wfContext* wfc)
MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_DATA,
SYSCOMMAND_ID_SMARTSIZING, L"Smart sizing", wfc);
if (wfc->common.context.settings->SmartSizing)
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing))
{
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, MF_CHECKED);
}
if (wfc->common.context.settings->RemoteAssistanceMode)
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_RemoteAssistanceMode))
wf_append_item_to_system_menu(hMenu, MIIM_FTYPE | MIIM_ID | MIIM_STRING,
SYSCOMMAND_ID_REQUEST_CONTROL, L"Request control", wfc);
}
@ -320,18 +329,18 @@ static WCHAR* wf_window_get_title(rdpSettings* settings)
BOOL port;
WCHAR* windowTitle = NULL;
size_t size;
char* name;
WCHAR prefix[] = L"FreeRDP:";
if (!settings)
return NULL;
name = settings->ServerHostname;
const char* name = freerdp_settings_get_string(settings, FreeRDP_ServerHostname);
if (settings->WindowTitle)
return ConvertUtf8ToWCharAlloc(settings->WindowTitle, NULL);
if (freerdp_settings_get_string(settings, FreeRDP_WindowTitle))
return ConvertUtf8ToWCharAlloc(freerdp_settings_get_string(settings, FreeRDP_WindowTitle),
NULL);
port = (settings->ServerPort != 3389);
port = (freerdp_settings_get_uint32(settings, FreeRDP_ServerPort) != 3389);
size = strlen(name) + 16 + wcslen(prefix);
windowTitle = calloc(size, sizeof(WCHAR));
@ -341,7 +350,8 @@ static WCHAR* wf_window_get_title(rdpSettings* settings)
if (!port)
_snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S", prefix, name);
else
_snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S:%u", prefix, name, settings->ServerPort);
_snwprintf_s(windowTitle, size, _TRUNCATE, L"%s %S:%u", prefix, name,
freerdp_settings_get_uint32(settings, FreeRDP_ServerPort));
return windowTitle;
}
@ -368,7 +378,9 @@ static BOOL wf_post_connect(freerdp* instance)
wfc = (wfContext*)instance->context;
WINPR_ASSERT(wfc);
wfc->primary = wf_image_new(wfc, settings->DesktopWidth, settings->DesktopHeight, format, NULL);
wfc->primary =
wf_image_new(wfc, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), format, NULL);
if (!gdi_init_ex(instance, format, 0, wfc->primary->pdata, NULL))
return FALSE;
@ -378,7 +390,7 @@ static BOOL wf_post_connect(freerdp* instance)
gdi = instance->context->gdi;
if (!settings->SoftwareGdi)
if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
wf_gdi_register_update_callbacks(context->update);
}
@ -388,12 +400,15 @@ static BOOL wf_post_connect(freerdp* instance)
if (!wfc->window_title)
return FALSE;
if (settings->EmbeddedWindow)
settings->Decorations = FALSE;
if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow))
{
if (!freerdp_settings_set_bool(settings, FreeRDP_Decorations, FALSE))
return FALSE;
}
if (wfc->fullscreen)
dwStyle = WS_POPUP;
else if (!settings->Decorations)
else if (!freerdp_settings_get_bool(settings, FreeRDP_Decorations))
dwStyle = WS_CHILD | WS_BORDER;
else
dwStyle =
@ -408,8 +423,8 @@ static BOOL wf_post_connect(freerdp* instance)
wf_resize_window(wfc);
wf_add_system_menu(wfc);
BitBlt(wfc->primary->hdc, 0, 0, settings->DesktopWidth, settings->DesktopHeight, NULL, 0, 0,
BLACKNESS);
BitBlt(wfc->primary->hdc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), NULL, 0, 0, BLACKNESS);
wfc->drawing = wfc->primary;
EventArgsInit(&e, "wfreerdp");
e.embed = FALSE;
@ -428,7 +443,8 @@ static BOOL wf_post_connect(freerdp* instance)
context->update->EndPaint = wf_end_paint;
wf_register_pointer(context->graphics);
wfc->floatbar = wf_floatbar_new(wfc, wfc->hInstance, settings->Floatbar);
wfc->floatbar =
wf_floatbar_new(wfc, wfc->hInstance, freerdp_settings_get_bool(settings, FreeRDP_Floatbar));
return TRUE;
}
@ -518,9 +534,11 @@ static BOOL wf_authenticate_ex(freerdp* instance, char** username, char** passwo
if (_wcsnlen(PasswordW, ARRAYSIZE(PasswordW)) == 0)
{
if (!wfc->isConsole && wfc->common.context.settings->CredentialsFromStdin)
if (!wfc->isConsole &&
freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_CredentialsFromStdin))
WLog_ERR(TAG, "Flag for stdin read present but stdin is redirected; using GUI");
if (wfc->isConsole && wfc->common.context.settings->CredentialsFromStdin)
if (wfc->isConsole &&
freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_CredentialsFromStdin))
status = CredUICmdLinePromptForCredentialsW(titleW, NULL, 0, UserNameW,
ARRAYSIZE(UserNameW), PasswordW,
ARRAYSIZE(PasswordW), &fSave, dwFlags);
@ -662,14 +680,10 @@ static void wf_report_error(char* wszMessage, DWORD dwErrCode)
static DWORD wf_is_x509_certificate_trusted(const char* common_name, const char* subject,
const char* issuer, const char* fingerprint)
{
DWORD derPubKeyLen;
char* derPubKey;
HRESULT hr = CRYPT_E_NOT_FOUND;
DWORD dwChainFlags = CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT;
PCCERT_CONTEXT pCert = NULL;
HCERTSTORE hStore = NULL;
HCERTCHAINENGINE hChainEngine = NULL;
PCCERT_CHAIN_CONTEXT pChainContext = NULL;
@ -680,8 +694,8 @@ static DWORD wf_is_x509_certificate_trusted(const char* common_name, const char*
CERT_CHAIN_POLICY_STATUS PolicyStatus = { 0 };
CERT_CHAIN_ENGINE_CONFIG EngineConfig = { 0 };
derPubKeyLen = strlen(fingerprint);
derPubKey = calloc(derPubKeyLen, sizeof(char));
DWORD derPubKeyLen = strlen(fingerprint);
char* derPubKey = calloc(derPubKeyLen, sizeof(char));
if (NULL == derPubKey)
{
WLog_ERR(TAG, "Could not allocate derPubKey");
@ -1057,7 +1071,7 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
{
msg_ret = GetMessage(&msg, NULL, 0, 0);
if (settings->EmbeddedWindow)
if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow))
{
if ((msg.message == WM_SETFOCUS) && (msg.lParam == 1))
{
@ -1176,7 +1190,8 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh
// prevent infinite message loop
wfc->disablewindowtracking = TRUE;
if (settings->SmartSizing || settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
{
wfc->xCurrentScroll = 0;
wfc->yCurrentScroll = 0;
@ -1196,22 +1211,26 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh
BOOL horiz = wfc->xScrollVisible;
BOOL vert = wfc->yScrollVisible;
if (!horiz && client_width < settings->DesktopWidth)
if (!horiz && client_width < freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth))
{
horiz = TRUE;
}
else if (horiz &&
client_width >= settings->DesktopWidth /* - GetSystemMetrics(SM_CXVSCROLL)*/)
client_width >=
freerdp_settings_get_uint32(
settings, FreeRDP_DesktopWidth) /* - GetSystemMetrics(SM_CXVSCROLL)*/)
{
horiz = FALSE;
}
if (!vert && client_height < settings->DesktopHeight)
if (!vert && client_height < freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))
{
vert = TRUE;
}
else if (vert &&
client_height >= settings->DesktopHeight /* - GetSystemMetrics(SM_CYHSCROLL)*/)
client_height >=
freerdp_settings_get_uint32(
settings, FreeRDP_DesktopHeight) /* - GetSystemMetrics(SM_CYHSCROLL)*/)
{
vert = FALSE;
}
@ -1246,12 +1265,13 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh
// The horizontal scrolling range is defined by
// (bitmap_width) - (client_width). The current horizontal
// scroll value remains within the horizontal scrolling range.
wfc->xMaxScroll = MAX(settings->DesktopWidth - client_width, 0);
wfc->xMaxScroll =
MAX(freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) - client_width, 0);
wfc->xCurrentScroll = MIN(wfc->xCurrentScroll, wfc->xMaxScroll);
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMin = wfc->xMinScroll;
si.nMax = settings->DesktopWidth;
si.nMax = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
si.nPage = client_width;
si.nPos = wfc->xCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
@ -1262,12 +1282,13 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width, UINT32 client_heigh
// The vertical scrolling range is defined by
// (bitmap_height) - (client_height). The current vertical
// scroll value remains within the vertical scrolling range.
wfc->yMaxScroll = MAX(settings->DesktopHeight - client_height, 0);
wfc->yMaxScroll = MAX(
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) - client_height, 0);
wfc->yCurrentScroll = MIN(wfc->yCurrentScroll, wfc->yMaxScroll);
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMin = wfc->yMinScroll;
si.nMax = settings->DesktopHeight;
si.nMax = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
si.nPage = client_height;
si.nPos = wfc->yCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
@ -1346,20 +1367,22 @@ static void wfreerdp_client_free(freerdp* instance, rdpContext* context)
static int wfreerdp_client_start(rdpContext* context)
{
HWND hWndParent;
HINSTANCE hInstance;
wfContext* wfc = (wfContext*)context;
freerdp* instance;
WINPR_ASSERT(context);
WINPR_ASSERT(context->settings);
instance = context->instance;
freerdp* instance = context->instance;
WINPR_ASSERT(instance);
hInstance = GetModuleHandle(NULL);
hWndParent = (HWND)context->settings->ParentWindowId;
context->settings->EmbeddedWindow = (hWndParent) ? TRUE : FALSE;
rdpContext* settings = context->instance;
WINPR_ASSERT(settings);
HINSTANCE hInstance = GetModuleHandle(NULL);
HWND hWndParent = (HWND)freerdp_settings_get_uint32(context->settings, FreeRDP_ParentWindowId);
if (!freerdp_settings_set_bool(settings, FreeRDP_EmbeddedWindow, (hWndParent) ? TRUE : FALSE))
return -1;
wfc->hWndParent = hWndParent;
/* initial windows system item position where we will insert new menu item

View File

@ -284,7 +284,9 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
// Holding the CTRL key down while resizing the window will force the desktop aspect ratio.
LPRECT rect;
if ((settings->SmartSizing || settings->DynamicResolutionUpdate) && ctrl_down())
if ((freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate)) &&
ctrl_down())
{
rect = (LPRECT)wParam;
@ -294,23 +296,29 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
case WMSZ_RIGHT:
case WMSZ_BOTTOMRIGHT:
// Adjust height
rect->bottom = rect->top + settings->DesktopHeight * (rect->right - rect->left) /
settings->DesktopWidth;
rect->bottom =
rect->top + freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) *
(rect->right - rect->left) /
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
break;
case WMSZ_TOP:
case WMSZ_BOTTOM:
case WMSZ_TOPRIGHT:
// Adjust width
rect->right = rect->left + settings->DesktopWidth * (rect->bottom - rect->top) /
settings->DesktopHeight;
rect->right =
rect->left + freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) *
(rect->bottom - rect->top) /
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_TOPLEFT:
// adjust width
rect->left = rect->right - (settings->DesktopWidth * (rect->bottom - rect->top) /
settings->DesktopHeight);
rect->left =
rect->right - (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) *
(rect->bottom - rect->top) /
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
break;
}
}
@ -323,7 +331,7 @@ static void wf_send_resize(wfContext* wfc)
int targetHeight = wfc->client_height;
rdpSettings* settings = wfc->common.context.settings;
if (settings->DynamicResolutionUpdate && wfc->disp != NULL)
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate) && wfc->disp != NULL)
{
if (GetTickCount64() - wfc->lastSentDate > RESIZE_MIN_DELAY)
{
@ -333,8 +341,8 @@ static void wf_send_resize(wfContext* wfc)
targetWidth = windowRect.right - windowRect.left;
targetHeight = windowRect.bottom - windowRect.top;
}
if (settings->SmartSizingWidth != targetWidth ||
settings->SmartSizingHeight != targetHeight)
if (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) != targetWidth ||
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight) != targetHeight)
{
DISPLAY_CONTROL_MONITOR_LAYOUT layout = { 0 };
@ -342,9 +350,12 @@ static void wf_send_resize(wfContext* wfc)
layout.Top = layout.Left = 0;
layout.Width = targetWidth;
layout.Height = targetHeight;
layout.Orientation = settings->DesktopOrientation;
layout.DesktopScaleFactor = settings->DesktopScaleFactor;
layout.DeviceScaleFactor = settings->DeviceScaleFactor;
layout.Orientation =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopOrientation);
layout.DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout.DeviceScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
layout.PhysicalWidth = targetWidth;
layout.PhysicalHeight = targetHeight;
@ -353,8 +364,8 @@ static void wf_send_resize(wfContext* wfc)
{
WLog_ERR("", "SendMonitorLayout failed.");
}
settings->SmartSizingWidth = targetWidth;
settings->SmartSizingHeight = targetHeight;
freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingWidth, targetWidth);
freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingHeight, targetHeight);
}
wfc->lastSentDate = GetTickCount64();
}
@ -401,8 +412,9 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
break;
case WM_GETMINMAXINFO:
if (wfc->common.context.settings->SmartSizing ||
wfc->common.context.settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing) ||
(freerdp_settings_get_bool(wfc->common.context.settings,
FreeRDP_DynamicResolutionUpdate)))
{
processed = FALSE;
}
@ -418,8 +430,12 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
if (!wfc->fullscreen)
{
// add window decoration
minmax->ptMaxTrackSize.x = settings->DesktopWidth + wfc->diff.x;
minmax->ptMaxTrackSize.y = settings->DesktopHeight + wfc->diff.y;
minmax->ptMaxTrackSize.x =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) +
wfc->diff.x;
minmax->ptMaxTrackSize.y =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) +
wfc->diff.y;
}
}
@ -713,17 +729,21 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
{
if (wParam == SYSCOMMAND_ID_SMARTSIZING)
{
rdpSettings* settings = wfc->common.context.settings;
HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
freerdp_settings_set_bool(wfc->common.context.settings, FreeRDP_SmartSizing,
!wfc->common.context.settings->SmartSizing);
const BOOL rc = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing);
freerdp_settings_set_bool(settings, FreeRDP_SmartSizing, !rc);
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING,
wfc->common.context.settings->SmartSizing ? MF_CHECKED
: MF_UNCHECKED);
if (!wfc->common.context.settings->SmartSizing)
freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)
? MF_CHECKED
: MF_UNCHECKED);
if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
{
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1,
wfc->common.context.settings->DesktopWidth + wfc->diff.x,
wfc->common.context.settings->DesktopHeight + wfc->diff.y,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) +
wfc->diff.x,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) +
wfc->diff.y,
SWP_NOMOVE);
}
else
@ -829,15 +849,15 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSr
WINPR_ASSERT(settings);
if (!wfc->client_width)
wfc->client_width = settings->DesktopWidth;
wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
if (!wfc->client_height)
wfc->client_height = settings->DesktopHeight;
wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
ww = wfc->client_width;
wh = wfc->client_height;
dw = settings->DesktopWidth;
dh = settings->DesktopHeight;
dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (!ww)
ww = dw;
@ -845,7 +865,8 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSr
if (!wh)
wh = dh;
if (wfc->fullscreen || !settings->SmartSizing || (ww == dw && wh == dh))
if (wfc->fullscreen || !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
(ww == dw && wh == dh))
{
return BitBlt(hdc, x, y, w, h, wfc->primary->hdc, x1, y1, SRCCOPY);
}
@ -873,17 +894,17 @@ static BOOL wf_scale_mouse_pos(wfContext* wfc, INT32 x, INT32 y, UINT16* px, UIN
return FALSE;
if (!wfc->client_width)
wfc->client_width = settings->DesktopWidth;
wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
if (!wfc->client_height)
wfc->client_height = settings->DesktopHeight;
wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
ww = wfc->client_width;
wh = wfc->client_height;
dw = settings->DesktopWidth;
dh = settings->DesktopHeight;
dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) || ((ww == dw) && (wh == dh)))
{
x += wfc->xCurrentScroll;
y += wfc->yCurrentScroll;

View File

@ -699,7 +699,8 @@ wfFloatBar* wf_floatbar_new(wfContext* wfc, HINSTANCE window, DWORD flags)
if (!update_locked_state(floatbar))
goto fail;
if (!wf_floatbar_toggle_fullscreen(floatbar, wfc->common.context.settings->Fullscreen))
if (!wf_floatbar_toggle_fullscreen(
floatbar, freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Fullscreen)))
goto fail;
return floatbar;

View File

@ -222,8 +222,8 @@ BOOL wf_scale_rect(wfContext* wfc, RECT* source)
if (!settings)
return FALSE;
dw = settings->DesktopWidth;
dh = settings->DesktopHeight;
dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (!wfc->client_width)
wfc->client_width = dw;
@ -240,7 +240,8 @@ BOOL wf_scale_rect(wfContext* wfc, RECT* source)
if (!wh)
wh = dh;
if (wfc->common.context.settings->SmartSizing && (ww != dw || wh != dh))
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_SmartSizing) &&
(ww != dw || wh != dh))
{
source->bottom = source->bottom * wh / dh + 20;
source->top = source->top * wh / dh - 20;
@ -280,30 +281,34 @@ void wf_update_offset(wfContext* wfc)
if (wfc->fullscreen)
{
if (wfc->common.context.settings->UseMultimon)
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon))
{
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
wfc->offset_x = (w - settings->DesktopWidth) / 2;
wfc->offset_x = (w - freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) / 2;
if (wfc->offset_x < x)
wfc->offset_x = x;
wfc->offset_y = (h - settings->DesktopHeight) / 2;
wfc->offset_y = (h - freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) / 2;
if (wfc->offset_y < y)
wfc->offset_y = y;
}
else
{
wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) - settings->DesktopWidth) / 2;
wfc->offset_x = (GetSystemMetrics(SM_CXSCREEN) -
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) /
2;
if (wfc->offset_x < 0)
wfc->offset_x = 0;
wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) - settings->DesktopHeight) / 2;
wfc->offset_y = (GetSystemMetrics(SM_CYSCREEN) -
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)) /
2;
if (wfc->offset_y < 0)
wfc->offset_y = 0;
@ -323,7 +328,7 @@ void wf_resize_window(wfContext* wfc)
if (wfc->fullscreen)
{
if (wfc->common.context.settings->UseMultimon)
if (freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_UseMultimon))
{
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
@ -339,17 +344,17 @@ void wf_resize_window(wfContext* wfc)
GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
}
}
else if (!wfc->common.context.settings->Decorations)
else if (!freerdp_settings_get_bool(wfc->common.context.settings, FreeRDP_Decorations))
{
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD);
if (settings->EmbeddedWindow)
if (freerdp_settings_get_bool(settings, FreeRDP_EmbeddedWindow))
{
if (!wfc->client_height)
wfc->client_height = settings->DesktopHeight;
wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (!wfc->client_width)
wfc->client_width = settings->DesktopWidth;
wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
wf_update_canvas_diff(wfc);
/* Now resize to get full canvas size and room for caption and borders */
@ -360,11 +365,15 @@ void wf_resize_window(wfContext* wfc)
else
{
/* Now resize to get full canvas size and room for caption and borders */
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, settings->DesktopWidth, settings->DesktopHeight,
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight),
SWP_FRAMECHANGED);
wf_update_canvas_diff(wfc);
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x,
settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) + wfc->diff.x,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) + wfc->diff.y,
SWP_NOMOVE | SWP_FRAMECHANGED);
}
}
else
@ -374,10 +383,10 @@ void wf_resize_window(wfContext* wfc)
WS_MAXIMIZEBOX);
if (!wfc->client_height)
wfc->client_height = settings->DesktopHeight;
wfc->client_height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (!wfc->client_width)
wfc->client_width = settings->DesktopWidth;
wfc->client_width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
if (!wfc->client_x)
wfc->client_x = 10;
@ -388,10 +397,12 @@ void wf_resize_window(wfContext* wfc)
wf_update_canvas_diff(wfc);
/* Now resize to get full canvas size and room for caption and borders */
int width, height;
if (settings->SmartSizing && settings->SmartSizingWidth && settings->SmartSizingHeight)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) &&
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) &&
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight))
{
width = settings->SmartSizingWidth;
height = settings->SmartSizingHeight;
width = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth);
height = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight);
}
else
{
@ -400,10 +411,11 @@ void wf_resize_window(wfContext* wfc)
}
int xpos, ypos;
if ((settings->DesktopPosX != UINT32_MAX) && (settings->DesktopPosY != UINT32_MAX))
if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) &&
(freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX))
{
xpos = settings->DesktopPosX;
ypos = settings->DesktopPosY;
xpos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX);
ypos = freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY);
}
else
{
@ -804,7 +816,7 @@ static BOOL wf_gdi_surface_frame_marker(rdpContext* context,
return FALSE;
if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END &&
settings->FrameAcknowledge > 0)
freerdp_settings_get_uint32(settings, FreeRDP_FrameAcknowledge) > 0)
{
IFCALL(context->update->SurfaceFrameAcknowledge, context, surface_frame_marker->frameId);
}

View File

@ -59,7 +59,7 @@ int main(int argc, char* argv[])
{
rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
if (settings->ListMonitors)
if (freerdp_settings_get_bool(settings, FreeRDP_ListMonitors))
xf_list_monitors(xfc);
goto out;

View File

@ -74,7 +74,7 @@ void xf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven
}
else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
gdi_video_control_init(xfc->common.context.gdi, (VideoClientContext*)e->pInterface);
else
xf_video_control_init(xfc, (VideoClientContext*)e->pInterface);
@ -122,7 +122,7 @@ void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect
}
else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
gdi_video_control_uninit(xfc->common.context.gdi, (VideoClientContext*)e->pInterface);
else
xf_video_control_uninit(xfc, (VideoClientContext*)e->pInterface);

View File

@ -195,14 +195,17 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
return;
}
if (settings->DesktopWidth <= 0 || settings->DesktopHeight <= 0)
if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) <= 0 ||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) <= 0)
{
WLog_ERR(TAG, "the window dimensions are invalid");
return;
}
xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth;
yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight;
xScalingFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) / (double)xfc->scaledWidth;
yScalingFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) / (double)xfc->scaledHeight;
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, 0);
/* Black out possible space between desktop and window borders */
@ -277,8 +280,8 @@ BOOL xf_picture_transform_required(xfContext* xfc)
WINPR_ASSERT(settings);
if ((xfc->offset_x != 0) || (xfc->offset_y != 0) ||
(xfc->scaledWidth != (INT64)settings->DesktopWidth) ||
(xfc->scaledHeight != (INT64)settings->DesktopHeight))
(xfc->scaledWidth != (INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)) ||
(xfc->scaledHeight != (INT64)freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
{
return TRUE;
}
@ -336,8 +339,10 @@ static BOOL xf_desktop_resize(rdpContext* context)
XFreePixmap(xfc->display, xfc->primary);
WINPR_ASSERT(xfc->depth != 0);
if (!(xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, settings->DesktopWidth,
settings->DesktopHeight, xfc->depth)))
if (!(xfc->primary = XCreatePixmap(
xfc->display, xfc->drawable,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), xfc->depth)))
return FALSE;
if (same)
@ -346,36 +351,39 @@ static BOOL xf_desktop_resize(rdpContext* context)
#ifdef WITH_XRENDER
if (!settings->SmartSizing)
if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
{
xfc->scaledWidth = settings->DesktopWidth;
xfc->scaledHeight = settings->DesktopHeight;
xfc->scaledWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
xfc->scaledHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
#endif
if (!xfc->fullscreen)
{
xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth, settings->DesktopHeight);
xf_ResizeDesktopWindow(xfc, xfc->window,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
}
else
{
#ifdef WITH_XRENDER
if (!settings->SmartSizing)
if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
#endif
{
/* Update the saved width and height values the window will be
* resized to when toggling out of fullscreen */
xfc->savedWidth = settings->DesktopWidth;
xfc->savedHeight = settings->DesktopHeight;
xfc->savedWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
xfc->savedHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, 0);
XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, settings->DesktopWidth,
settings->DesktopHeight);
XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
}
return TRUE;
@ -461,7 +469,8 @@ static BOOL xf_sw_desktop_resize(rdpContext* context)
BOOL ret = FALSE;
xf_lock_x11(xfc);
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
goto out;
if (xfc->image)
@ -503,7 +512,8 @@ static BOOL xf_hw_desktop_resize(rdpContext* context)
xf_lock_x11(xfc);
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
goto out;
ret = xf_desktop_resize(context);
@ -543,18 +553,18 @@ static char* xf_window_get_title(rdpSettings* settings)
BOOL port;
char* windowTitle;
size_t size;
char* name;
const char* prefix = "FreeRDP:";
if (!settings)
return NULL;
name = settings->ServerHostname;
const char* name = freerdp_settings_get_string(settings, FreeRDP_ServerHostname);
const char* title = freerdp_settings_get_string(settings, FreeRDP_WindowTitle);
if (settings->WindowTitle)
return _strdup(settings->WindowTitle);
if (title)
return _strdup(title);
port = (settings->ServerPort != 3389);
port = (freerdp_settings_get_uint32(settings, FreeRDP_ServerPort) != 3389);
/* Just assume a window title is never longer than a filename... */
size = strnlen(name, MAX_PATH) + 16;
windowTitle = calloc(size, sizeof(char));
@ -565,7 +575,8 @@ static char* xf_window_get_title(rdpSettings* settings)
if (!port)
sprintf_s(windowTitle, size, "%s %s", prefix, name);
else
sprintf_s(windowTitle, size, "%s %s:%i", prefix, name, settings->ServerPort);
sprintf_s(windowTitle, size, "%s %s:%i", prefix, name,
freerdp_settings_get_uint32(settings, FreeRDP_ServerPort));
return windowTitle;
}
@ -580,8 +591,8 @@ BOOL xf_create_window(xfContext* xfc)
rdpSettings* settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
int width = settings->DesktopWidth;
int height = settings->DesktopHeight;
int width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
int height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
const XSetWindowAttributes empty = { 0 };
xfc->attribs = empty;
@ -649,13 +660,13 @@ BOOL xf_create_window(xfContext* xfc)
#ifdef WITH_XRENDER
if (settings->SmartSizing && !xfc->fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) && !xfc->fullscreen)
{
if (settings->SmartSizingWidth)
width = settings->SmartSizingWidth;
if (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) > 0)
width = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth);
if (settings->SmartSizingHeight)
height = settings->SmartSizingHeight;
if (freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight) > 0)
height = freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight);
xfc->scaledWidth = width;
xfc->scaledHeight = height;
@ -692,8 +703,10 @@ BOOL xf_create_window(xfContext* xfc)
WINPR_ASSERT(xfc->depth != 0);
if (!xfc->primary)
xfc->primary = XCreatePixmap(xfc->display, xfc->drawable, settings->DesktopWidth,
settings->DesktopHeight, xfc->depth);
xfc->primary =
XCreatePixmap(xfc->display, xfc->drawable,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight), xfc->depth);
xfc->drawing = xfc->primary;
@ -706,8 +719,9 @@ BOOL xf_create_window(xfContext* xfc)
XSetFunction(xfc->display, xfc->gc, GXcopy);
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, BlackPixelOfScreen(xfc->screen));
XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, settings->DesktopWidth,
settings->DesktopHeight);
XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
XFlush(xfc->display);
return TRUE;
@ -724,8 +738,10 @@ BOOL xf_create_image(xfContext* xfc)
WINPR_ASSERT(xfc->depth != 0);
xfc->image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
(char*)cgdi->primary_buffer, settings->DesktopWidth,
settings->DesktopHeight, xfc->scanline_pad, cgdi->stride);
(char*)cgdi->primary_buffer,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight),
xfc->scanline_pad, cgdi->stride);
xfc->image->byte_order = LSBFirst;
xfc->image->bitmap_bit_order = LSBFirst;
}
@ -800,7 +816,8 @@ void xf_toggle_fullscreen(xfContext* xfc)
xf_ungrab(xfc);
xfc->fullscreen = (xfc->fullscreen) ? FALSE : TRUE;
xfc->decorations = (xfc->fullscreen) ? FALSE : settings->Decorations;
xfc->decorations =
(xfc->fullscreen) ? FALSE : freerdp_settings_get_bool(settings, FreeRDP_Decorations);
xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen);
EventArgsInit(&e, "xfreerdp");
e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0;
@ -1078,7 +1095,7 @@ static void xf_button_map_init(xfContext* xfc)
x11_map[111] = 112;
/* query system for actual remapping */
if (xfc->common.context.settings->UnmapButtons)
if (freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_UnmapButtons))
{
xf_get_x11_button_map(xfc, x11_map);
}
@ -1145,12 +1162,16 @@ static BOOL xf_pre_connect(freerdp* instance)
channels = context->channels;
WINPR_ASSERT(channels);
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_NATIVE_XSERVER;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMajorType, OSMAJORTYPE_UNIX))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_OsMinorType, OSMINORTYPE_NATIVE_XSERVER))
return FALSE;
PubSub_SubscribeChannelConnected(context->pubSub, xf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(context->pubSub, xf_OnChannelDisconnectedEventHandler);
if (!settings->Username && !settings->CredentialsFromStdin && !settings->SmartcardLogon)
if (!freerdp_settings_get_string(settings, FreeRDP_Username) &&
!freerdp_settings_get_bool(settings, FreeRDP_CredentialsFromStdin) &&
!freerdp_settings_get_bool(settings, FreeRDP_SmartcardLogon))
{
char login_name[MAX_PATH] = { 0 };
ULONG size = sizeof(login_name) - 1;
@ -1160,7 +1181,8 @@ static BOOL xf_pre_connect(freerdp* instance)
if (!freerdp_settings_set_string(settings, FreeRDP_Username, login_name))
return FALSE;
WLog_INFO(TAG, "No user name set. - Using login name: %s", settings->Username);
WLog_INFO(TAG, "No user name set. - Using login name: %s",
freerdp_settings_get_string(settings, FreeRDP_Username));
}
}
@ -1185,8 +1207,10 @@ static BOOL xf_pre_connect(freerdp* instance)
}
if (maxWidth && maxHeight && !freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
{
settings->DesktopWidth = maxWidth;
settings->DesktopHeight = maxHeight;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, maxWidth))
return FALSE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, maxHeight))
return FALSE;
}
#ifdef WITH_XRENDER
@ -1195,18 +1219,26 @@ static BOOL xf_pre_connect(freerdp* instance)
* If /f is specified in combination with /smart-sizing:widthxheight then
* we run the session in the /smart-sizing dimensions scaled to full screen
*/
if (settings->Fullscreen && settings->SmartSizing && settings->SmartSizingWidth &&
settings->SmartSizingHeight)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) &&
freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) &&
(freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth) > 0) &&
(freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight) > 0))
{
settings->DesktopWidth = settings->SmartSizingWidth;
settings->DesktopHeight = settings->SmartSizingHeight;
if (!freerdp_settings_set_uint32(
settings, FreeRDP_DesktopWidth,
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingWidth)))
return FALSE;
if (!freerdp_settings_set_uint32(
settings, FreeRDP_DesktopHeight,
freerdp_settings_get_uint32(settings, FreeRDP_SmartSizingHeight)))
return FALSE;
}
#endif
xfc->fullscreen = settings->Fullscreen;
xfc->decorations = settings->Decorations;
xfc->grab_keyboard = settings->GrabKeyboard;
xfc->fullscreen_toggle = settings->ToggleFullscreen;
xfc->fullscreen = freerdp_settings_get_bool(settings, FreeRDP_Fullscreen);
xfc->decorations = freerdp_settings_get_bool(settings, FreeRDP_Decorations);
xfc->grab_keyboard = freerdp_settings_get_bool(settings, FreeRDP_GrabKeyboard);
xfc->fullscreen_toggle = freerdp_settings_get_bool(settings, FreeRDP_ToggleFullscreen);
if (!freerdp_settings_get_bool(settings, FreeRDP_AuthenticationOnly))
xf_button_map_init(xfc);
return TRUE;
@ -1329,7 +1361,7 @@ static BOOL xf_post_connect(freerdp* instance)
rdpUpdate* update = context->update;
WINPR_ASSERT(update);
if (settings->RemoteApplicationMode)
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode))
xfc->remote_app = TRUE;
if (!xf_create_window(xfc))
@ -1347,7 +1379,7 @@ static BOOL xf_post_connect(freerdp* instance)
if (!xf_register_pointer(context->graphics))
return FALSE;
if (!settings->SoftwareGdi)
if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
if (!xf_register_graphics(context->graphics))
{
@ -1359,28 +1391,30 @@ static BOOL xf_post_connect(freerdp* instance)
}
#ifdef WITH_XRENDER
xfc->scaledWidth = settings->DesktopWidth;
xfc->scaledHeight = settings->DesktopHeight;
xfc->scaledWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
xfc->scaledHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
xfc->offset_x = 0;
xfc->offset_y = 0;
#endif
if (!xfc->xrenderAvailable)
{
if (settings->SmartSizing)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
{
WLog_ERR(TAG, "XRender not available: disabling smart-sizing");
settings->SmartSizing = FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_SmartSizing, FALSE))
return FALSE;
}
if (settings->MultiTouchGestures)
if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
WLog_ERR(TAG, "XRender not available: disabling local multi-touch gestures");
settings->MultiTouchGestures = FALSE;
if (!freerdp_settings_set_bool(settings, FreeRDP_MultiTouchGestures, FALSE))
return FALSE;
}
}
if (settings->SoftwareGdi)
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
update->DesktopResize = xf_sw_desktop_resize;
else
update->DesktopResize = xf_hw_desktop_resize;
@ -1390,8 +1424,9 @@ static BOOL xf_post_connect(freerdp* instance)
update->SetKeyboardIndicators = xf_keyboard_set_indicators;
update->SetKeyboardImeStatus = xf_keyboard_set_ime_status;
const BOOL serverIsWindowsPlatform = (settings->OsMajorType == OSMAJORTYPE_WINDOWS);
if (settings->RedirectClipboard &&
const BOOL serverIsWindowsPlatform =
(freerdp_settings_get_uint32(settings, FreeRDP_OsMajorType) == OSMAJORTYPE_WINDOWS);
if (freerdp_settings_get_bool(settings, FreeRDP_RedirectClipboard) &&
!(xfc->clipboard = xf_clipboard_new(xfc, !serverIsWindowsPlatform)))
return FALSE;
@ -1407,8 +1442,8 @@ static BOOL xf_post_connect(freerdp* instance)
}
EventArgsInit(&e, "xfreerdp");
e.width = settings->DesktopWidth;
e.height = settings->DesktopHeight;
e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
PubSub_OnResizeWindow(context->pubSub, xfc, &e);
return TRUE;
}
@ -1536,7 +1571,7 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
goto end;
/* --authonly ? */
if (settings->AuthenticationOnly)
if (freerdp_settings_get_bool(settings, FreeRDP_AuthenticationOnly))
{
WLog_ERR(TAG, "Authentication only, exit status %" PRId32 "", !status);
goto disconnect;
@ -1723,7 +1758,8 @@ static void xf_ZoomingChangeEventHandler(void* context, const ZoomingChangeEvent
xfc->scaledWidth = w;
xfc->scaledHeight = h;
xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
xf_draw_screen(xfc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
}
static void xf_PanningChangeEventHandler(void* context, const PanningChangeEventArgs* e)
@ -1742,7 +1778,8 @@ static void xf_PanningChangeEventHandler(void* context, const PanningChangeEvent
xfc->offset_x += e->dx;
xfc->offset_y += e->dy;
xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
xf_draw_screen(xfc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
}
#endif
@ -1769,7 +1806,7 @@ static int xfreerdp_client_start(rdpContext* context)
xfContext* xfc = (xfContext*)context;
rdpSettings* settings = context->settings;
if (!settings->ServerHostname)
if (!freerdp_settings_get_string(settings, FreeRDP_ServerHostname))
{
WLog_ERR(TAG, "error: server hostname was not specified with /v:<server>[:port]");
return -1;

View File

@ -79,13 +79,16 @@ static BOOL xf_disp_settings_changed(xfDispContext* xfDisp)
if (xfDisp->lastSentHeight != xfDisp->targetHeight)
return TRUE;
if (xfDisp->lastSentDesktopOrientation != settings->DesktopOrientation)
if (xfDisp->lastSentDesktopOrientation !=
freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation))
return TRUE;
if (xfDisp->lastSentDesktopScaleFactor != settings->DesktopScaleFactor)
if (xfDisp->lastSentDesktopScaleFactor !=
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor))
return TRUE;
if (xfDisp->lastSentDeviceScaleFactor != settings->DeviceScaleFactor)
if (xfDisp->lastSentDeviceScaleFactor !=
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor))
return TRUE;
if (xfDisp->fullscreen != xfDisp->xfc->fullscreen)
@ -106,9 +109,12 @@ static BOOL xf_update_last_sent(xfDispContext* xfDisp)
xfDisp->lastSentWidth = xfDisp->targetWidth;
xfDisp->lastSentHeight = xfDisp->targetHeight;
xfDisp->lastSentDesktopOrientation = settings->DesktopOrientation;
xfDisp->lastSentDesktopScaleFactor = settings->DesktopScaleFactor;
xfDisp->lastSentDeviceScaleFactor = settings->DeviceScaleFactor;
xfDisp->lastSentDesktopOrientation =
freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
xfDisp->lastSentDesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
xfDisp->lastSentDeviceScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
xfDisp->fullscreen = xfDisp->xfc->fullscreen;
return TRUE;
}
@ -138,10 +144,13 @@ static BOOL xf_disp_sendResize(xfDispContext* xfDisp)
return TRUE;
xfDisp->lastSentDate = GetTickCount64();
if (xfc->fullscreen && (settings->MonitorCount > 0))
const UINT32 mcount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount);
if (xfc->fullscreen && (mcount > 0))
{
if (xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray, settings->MonitorCount) !=
CHANNEL_RC_OK)
const rdpMonitor* monitors =
freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray);
if (xf_disp_sendLayout(xfDisp->disp, monitors, mcount) != CHANNEL_RC_OK)
return FALSE;
}
else
@ -150,9 +159,10 @@ static BOOL xf_disp_sendResize(xfDispContext* xfDisp)
layout.Top = layout.Left = 0;
layout.Width = xfDisp->targetWidth;
layout.Height = xfDisp->targetHeight;
layout.Orientation = settings->DesktopOrientation;
layout.DesktopScaleFactor = settings->DesktopScaleFactor;
layout.DeviceScaleFactor = settings->DeviceScaleFactor;
layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
layout.DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
layout.PhysicalWidth = xfDisp->targetWidth / 75.0 * 25.4;
layout.PhysicalHeight = xfDisp->targetHeight / 75.0 * 25.4;
@ -246,7 +256,7 @@ static void xf_disp_OnGraphicsReset(void* context, const GraphicsResetEventArgs*
if (!xf_disp_check_context(context, &xfc, &xfDisp, &settings))
return;
if (xfDisp->activated && !settings->Fullscreen)
if (xfDisp->activated && !freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
xf_disp_set_window_resizable(xfDisp);
xf_disp_sendResize(xfDisp);
@ -315,8 +325,10 @@ xfDispContext* xf_disp_new(xfContext* xfc)
}
#endif
ret->lastSentWidth = ret->targetWidth = settings->DesktopWidth;
ret->lastSentHeight = ret->targetHeight = settings->DesktopHeight;
ret->lastSentWidth = ret->targetWidth =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
ret->lastSentHeight = ret->targetHeight =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
PubSub_SubscribeActivated(pubSub, xf_disp_OnActivated);
PubSub_SubscribeGraphicsReset(pubSub, xf_disp_OnGraphicsReset);
PubSub_SubscribeTimer(pubSub, xf_disp_OnTimer);
@ -406,8 +418,10 @@ UINT xf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, UIN
break;
}
layout->DesktopScaleFactor = settings->DesktopScaleFactor;
layout->DeviceScaleFactor = settings->DeviceScaleFactor;
layout->DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout->DeviceScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
}
ret = IFCALLRESULT(CHANNEL_RC_OK, disp->SendMonitorLayout, disp, nmonitors, layouts);
@ -444,8 +458,9 @@ BOOL xf_disp_handle_xevent(xfContext* xfc, const XEvent* event)
#endif
xf_detect_monitors(xfc, &maxWidth, &maxHeight);
return xf_disp_sendLayout(xfDisp->disp, settings->MonitorDefArray, settings->MonitorCount) ==
CHANNEL_RC_OK;
const rdpMonitor* monitors = freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray);
const UINT32 mcount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount);
return xf_disp_sendLayout(xfDisp->disp, monitors, mcount) == CHANNEL_RC_OK;
}
BOOL xf_disp_handle_configureNotify(xfContext* xfc, int width, int height)
@ -485,7 +500,7 @@ static UINT xf_DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors
maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
xfDisp->activated = TRUE;
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
return CHANNEL_RC_OK;
WLog_DBG(TAG, "DisplayControlCapsPdu: setting the window as resizable");
@ -507,12 +522,12 @@ BOOL xf_disp_init(xfDispContext* xfDisp, DispClientContext* disp)
xfDisp->disp = disp;
disp->custom = (void*)xfDisp;
if (settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
{
disp->DisplayControlCaps = xf_DisplayControlCaps;
#ifdef USABLE_XRANDR
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
/* ask X11 to notify us of screen changes */
XRRSelectInput(xfDisp->xfc->display, DefaultRootWindow(xfDisp->xfc->display),

View File

@ -294,8 +294,10 @@ void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y)
if (xf_picture_transform_required(xfc))
{
double xScalingFactor = xfc->scaledWidth / (double)settings->DesktopWidth;
double yScalingFactor = xfc->scaledHeight / (double)settings->DesktopHeight;
double xScalingFactor = xfc->scaledWidth / (double)freerdp_settings_get_uint32(
settings, FreeRDP_DesktopWidth);
double yScalingFactor = xfc->scaledHeight / (double)freerdp_settings_get_uint32(
settings, FreeRDP_DesktopHeight);
tx = ((tx + xfc->offset_x) * xScalingFactor);
ty = ((ty + xfc->offset_y) * yScalingFactor);
}
@ -319,8 +321,10 @@ void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)
rdpSettings* settings = xfc->common.context.settings;
if (xf_picture_transform_required(xfc))
{
double xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth;
double yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight;
double xScalingFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) /
(double)xfc->scaledWidth;
double yScalingFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) /
(double)xfc->scaledHeight;
*x = (int)((*x - xfc->offset_x) * xScalingFactor);
*y = (int)((*y - xfc->offset_y) * yScalingFactor);
}
@ -343,12 +347,13 @@ static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app)
settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
if (!app && (settings->SmartSizing || settings->MultiTouchGestures))
if (!app && (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)))
{
x = 0;
y = 0;
w = settings->DesktopWidth;
h = settings->DesktopHeight;
w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
else
{
@ -396,7 +401,7 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win
rdpInput* input = xfc->common.context.input;
WINPR_ASSERT(input);
if (!xfc->common.context.settings->MouseMotion)
if (!freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_MouseMotion))
{
if ((state & (Button1Mask | Button2Mask | Button3Mask)) == 0)
return TRUE;
@ -784,22 +789,25 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* even
xfc->offset_x = 0;
xfc->offset_y = 0;
if (settings->SmartSizing || settings->MultiTouchGestures)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
xfc->scaledWidth = xfc->window->width;
xfc->scaledHeight = xfc->window->height;
xf_draw_screen(xfc, 0, 0, settings->DesktopWidth, settings->DesktopHeight);
xf_draw_screen(xfc, 0, 0,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
}
else
{
xfc->scaledWidth = settings->DesktopWidth;
xfc->scaledHeight = settings->DesktopHeight;
xfc->scaledWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
xfc->scaledHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
#endif
}
if (settings->DynamicResolutionUpdate)
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
{
int alignedWidth, alignedHeight;
alignedWidth = (xfc->window->width / 2) * 2;
@ -1233,7 +1241,7 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event)
break;
default:
if (settings->SupportDisplayControl)
if (freerdp_settings_get_bool(settings, FreeRDP_SupportDisplayControl))
xf_disp_handle_xevent(xfc, event);
break;

View File

@ -930,7 +930,7 @@ static BOOL xf_gdi_surface_frame_marker(rdpContext* context,
case SURFACECMD_FRAMEACTION_END:
xfc->frame_begin = FALSE;
if (settings->FrameAcknowledge > 0)
if (freerdp_settings_get_uint32(settings, FreeRDP_FrameAcknowledge) > 0)
{
WINPR_ASSERT(xfc->common.context.update);
IFCALL(xfc->common.context.update->SurfaceFrameAcknowledge, context,

View File

@ -97,7 +97,8 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
}
else
#ifdef WITH_XRENDER
if (settings->SmartSizing || settings->MultiTouchGestures)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image, nXSrc, nYSrc, nXDst,
nYDst, dwidth, dheight);
@ -454,7 +455,7 @@ void xf_graphics_pipeline_init(xfContext* xfc, RdpgfxClientContext* gfx)
gdi_graphics_pipeline_init(gdi, gfx);
if (!settings->SoftwareGdi)
if (!freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
gfx->UpdateSurfaces = xf_UpdateSurfaces;
gfx->CreateSurface = xf_CreateSurface;

View File

@ -249,15 +249,21 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, rdpPointer*
if (!settings)
return FALSE;
const double xscale =
(settings->SmartSizing ? xfc->scaledWidth / (double)settings->DesktopWidth : 1);
const double yscale =
(settings->SmartSizing ? xfc->scaledHeight / (double)settings->DesktopHeight : 1);
const double xscale = (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)
? xfc->scaledWidth / (double)freerdp_settings_get_uint32(
settings, FreeRDP_DesktopWidth)
: 1);
const double yscale = (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing)
? xfc->scaledHeight / (double)freerdp_settings_get_uint32(
settings, FreeRDP_DesktopHeight)
: 1);
const UINT32 xTargetSize = MAX(1, pointer->width * xscale);
const UINT32 yTargetSize = MAX(1, pointer->height * yscale);
WLog_DBG(TAG, "scaled: %" PRIu32 "x%" PRIu32 ", desktop: %" PRIu32 "x%" PRIu32,
xfc->scaledWidth, xfc->scaledHeight, settings->DesktopWidth, settings->DesktopHeight);
xfc->scaledWidth, xfc->scaledHeight,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
for (UINT32 i = 0; i < xpointer->nCursors; i++)
{
if ((xpointer->cursorWidths[i] == xTargetSize) &&

View File

@ -101,7 +101,7 @@ static BOOL register_input_events(xfContext* xfc, Window window)
switch (class->type)
{
case XITouchClass:
if (settings->MultiTouchInput)
if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchInput))
{
const XITouchClassInfo* t = (const XITouchClassInfo*)class;
if (t->mode == XIDirectTouch)
@ -933,11 +933,11 @@ int xf_input_handle_event(xfContext* xfc, const XEvent* event)
settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
if (settings->MultiTouchInput)
if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchInput))
{
return xf_input_handle_event_remote(xfc, event);
}
else if (settings->MultiTouchGestures)
else if (freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
return xf_input_handle_event_local(xfc, event);
}

View File

@ -155,10 +155,11 @@ BOOL xf_keyboard_init(xfContext* xfc)
WINPR_ASSERT(settings);
xf_keyboard_clear(xfc);
xfc->KeyboardLayout = settings->KeyboardLayout;
xfc->KeyboardLayout =
freerdp_keyboard_init_ex(xfc->KeyboardLayout, settings->KeyboardRemappingList);
settings->KeyboardLayout = xfc->KeyboardLayout;
xfc->KeyboardLayout = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardLayout);
xfc->KeyboardLayout = freerdp_keyboard_init_ex(
xfc->KeyboardLayout, freerdp_settings_get_string(settings, FreeRDP_KeyboardRemappingList));
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, xfc->KeyboardLayout))
return FALSE;
if (!xf_keyboard_update_modifier_map(xfc))
return FALSE;
@ -597,7 +598,7 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
#if 0 /* set to 1 to enable multi touch gesture simulation via keyboard */
#ifdef WITH_XRENDER
if (!xfc->remote_app && xfc->settings->MultiTouchGestures)
if (!xfc->remote_app && freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_MultiTouchGestures))
{
rdpContext* ctx = &xfc->common.context;
@ -610,20 +611,24 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
switch (keysym)
{
case XK_0: /* Ctrl-Alt-0: Reset scaling and panning */
xfc->scaledWidth = xfc->sessionWidth;
xfc->scaledHeight = xfc->sessionHeight;
case XK_0: /* Ctrl-Alt-0: Reset scaling and panning */{
const UINT32 sessionWidth = freerdp_settings_get_uint32(xfc->common.context.settings, FreeRDP_DesktopWidth);
const UINT32 sessionHeight = freerdp_settings_get_uint32(xfc->common.context.settings, FreeRDP_DesktopHeight);
xfc->scaledWidth = sessionWidth;
xfc->scaledHeight = sessionHeight;
xfc->offset_x = 0;
xfc->offset_y = 0;
if (!xfc->fullscreen && (xfc->sessionWidth != xfc->window->width ||
xfc->sessionHeight != xfc->window->height))
if (!xfc->fullscreen && (sessionWidth != xfc->window->width ||
sessionHeight != xfc->window->height))
{
xf_ResizeDesktopWindow(xfc, xfc->window, xfc->sessionWidth, xfc->sessionHeight);
xf_ResizeDesktopWindow(xfc, xfc->window, sessionWidth, sessionHeight);
}
xf_draw_screen(xfc, 0, 0, xfc->sessionWidth, xfc->sessionHeight);
xf_draw_screen(xfc, 0, 0, sessionWidth, sessionHeight);
return TRUE;
}
case XK_1: /* Ctrl-Alt-1: Zoom in */
zdx = zdy = 10;

View File

@ -122,12 +122,14 @@ static BOOL xf_is_monitor_id_active(xfContext* xfc, UINT32 id)
settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
if (!settings->NumMonitorIds)
const UINT32 NumMonitorIds = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
if (NumMonitorIds == 0)
return TRUE;
for (index = 0; index < settings->NumMonitorIds; index++)
for (index = 0; index < NumMonitorIds; index++)
{
if (settings->MonitorIds[index] == id)
const UINT32* cur = freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, index);
if (cur && (*cur == id))
return TRUE;
}
@ -138,7 +140,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
{
BOOL rc = FALSE;
int nmonitors = 0;
int monitor_index = 0;
UINT32 monitor_index = 0;
BOOL primaryMonitorFound = FALSE;
VIRTUAL_SCREEN* vscreen = NULL;
rdpSettings* settings = NULL;
@ -159,15 +161,15 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
settings = xfc->common.context.settings;
vscreen = &xfc->vscreen;
*pMaxWidth = settings->DesktopWidth;
*pMaxHeight = settings->DesktopHeight;
*pMaxWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
*pMaxHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
if (settings->ParentWindowId)
if (freerdp_settings_get_uint64(settings, FreeRDP_ParentWindowId) > 0)
{
xfc->workArea.x = 0;
xfc->workArea.y = 0;
xfc->workArea.width = settings->DesktopWidth;
xfc->workArea.height = settings->DesktopHeight;
xfc->workArea.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
xfc->workArea.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
return TRUE;
}
@ -262,12 +264,14 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
without remote app, we force the number of monitors be 1 so later
the rest of the client don't end up using more monitors than the user desires.
*/
if ((!settings->UseMultimon && !settings->SpanMonitors) ||
(settings->Workarea && !settings->RemoteApplicationMode))
if ((!freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) &&
!freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors)) ||
(freerdp_settings_get_bool(settings, FreeRDP_Workarea) &&
!freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode)))
{
/* If no monitors were specified on the command-line then set the current monitor as active
*/
if (!settings->NumMonitorIds)
if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) == 0)
{
UINT32 id = current_monitor;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, &id, 1))
@ -278,7 +282,8 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
* If the monitor is invalid then we will default back to current monitor
* later as a fallback. So, there is no need to validate command-line entry here.
*/
settings->NumMonitorIds = 1;
if (!freerdp_settings_set_uint32(settings, FreeRDP_NumMonitorIds, 1))
goto fail;
}
/* WORKAROUND: With Remote Application Mode - using NET_WM_WORKAREA
@ -286,14 +291,15 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
* (the bottom of the window area is never updated). So, we just set
* the workArea to match the full Screen width/height.
*/
if (settings->RemoteApplicationMode || !xf_GetWorkArea(xfc))
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode) || !xf_GetWorkArea(xfc))
{
/*
if only 1 monitor is enabled, use monitor area
this is required in case of a screen composed of more than one monitor
but user did not enable multimonitor
*/
if ((settings->NumMonitorIds == 1) && (vscreen->nmonitors > current_monitor))
if ((freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) == 1) &&
(vscreen->nmonitors > current_monitor))
{
MONITOR_INFO* monitor = vscreen->monitors + current_monitor;
@ -314,17 +320,17 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
}
}
if (settings->Fullscreen)
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
*pMaxWidth = WidthOfScreen(xfc->screen);
*pMaxHeight = HeightOfScreen(xfc->screen);
}
else if (settings->Workarea)
else if (freerdp_settings_get_bool(settings, FreeRDP_Workarea))
{
*pMaxWidth = xfc->workArea.width;
*pMaxHeight = xfc->workArea.height;
}
else if (settings->PercentScreen)
else if (freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen))
{
/* If we have specific monitor information then limit the PercentScreen value
* to only affect the current monitor vs. the entire desktop
@ -339,16 +345,16 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
*pMaxHeight = vscreen->monitors[current_monitor].area.bottom -
vscreen->monitors[current_monitor].area.top + 1;
if (settings->PercentScreenUseWidth)
if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth))
*pMaxWidth = ((vscreen->monitors[current_monitor].area.right -
vscreen->monitors[current_monitor].area.left + 1) *
settings->PercentScreen) /
freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) /
100;
if (settings->PercentScreenUseHeight)
if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight))
*pMaxHeight = ((vscreen->monitors[current_monitor].area.bottom -
vscreen->monitors[current_monitor].area.top + 1) *
settings->PercentScreen) /
freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) /
100;
}
else
@ -356,28 +362,34 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
*pMaxWidth = xfc->workArea.width;
*pMaxHeight = xfc->workArea.height;
if (settings->PercentScreenUseWidth)
*pMaxWidth = (xfc->workArea.width * settings->PercentScreen) / 100;
if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth))
*pMaxWidth = (xfc->workArea.width *
freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) /
100;
if (settings->PercentScreenUseHeight)
*pMaxHeight = (xfc->workArea.height * settings->PercentScreen) / 100;
if (freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight))
*pMaxHeight = (xfc->workArea.height *
freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)) /
100;
}
}
else if (settings->DesktopWidth && settings->DesktopHeight)
else if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) &&
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight))
{
*pMaxWidth = settings->DesktopWidth;
*pMaxHeight = settings->DesktopHeight;
*pMaxWidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
*pMaxHeight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
}
/* Create array of all active monitors by taking into account monitors requested on the
* command-line */
{
int i;
UINT32 nr = 0;
if (settings->MonitorIds)
nr = settings->MonitorIds[0];
for (i = 0; i < vscreen->nmonitors; i++)
UINT32* ids = freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0);
if (ids)
nr = *ids;
for (UINT32 i = 0; i < vscreen->nmonitors; i++)
{
MONITOR_ATTRIBUTES* attrs;
@ -387,29 +399,37 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if (!vscreen->monitors)
goto fail;
settings->MonitorDefArray[nmonitors].x =
(vscreen->monitors[i].area.left *
(settings->PercentScreenUseWidth ? settings->PercentScreen : 100)) /
100;
settings->MonitorDefArray[nmonitors].y =
(vscreen->monitors[i].area.top *
(settings->PercentScreenUseHeight ? settings->PercentScreen : 100)) /
100;
settings->MonitorDefArray[nmonitors].width =
rdpMonitor* monitor = freerdp_settings_get_pointer_array_writable(
settings, FreeRDP_MonitorDefArray, nmonitors);
monitor->x = (vscreen->monitors[i].area.left *
(freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100)) /
100;
monitor->y = (vscreen->monitors[i].area.top *
(freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100)) /
100;
monitor->width =
((vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1) *
(settings->PercentScreenUseWidth ? settings->PercentScreen : 100)) /
(freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100)) /
100;
settings->MonitorDefArray[nmonitors].height =
monitor->height =
((vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1) *
(settings->PercentScreenUseWidth ? settings->PercentScreen : 100)) /
(freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100)) /
100;
settings->MonitorDefArray[nmonitors].orig_screen = i;
monitor->orig_screen = i;
#ifdef USABLE_XRANDR
if (useXRandr && rrmonitors)
{
Rotation rot, ret;
attrs = &settings->MonitorDefArray[nmonitors].attributes;
attrs = &monitor->attributes;
attrs->physicalWidth = rrmonitors[i].mwidth;
attrs->physicalHeight = rrmonitors[i].mheight;
ret = XRRRotations(xfc->display, i, &rot);
@ -420,9 +440,11 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if ((UINT32)i == nr)
{
settings->MonitorDefArray[nmonitors].is_primary = TRUE;
settings->MonitorLocalShiftX = settings->MonitorDefArray[nmonitors].x;
settings->MonitorLocalShiftY = settings->MonitorDefArray[nmonitors].y;
monitor->is_primary = TRUE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, monitor->x))
goto fail;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, monitor->y))
goto fail;
primaryMonitorFound = TRUE;
}
@ -443,60 +465,80 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
height = vscreen->monitors[current_monitor].area.bottom -
vscreen->monitors[current_monitor].area.top + 1L;
settings->MonitorDefArray[0].x = vscreen->monitors[current_monitor].area.left;
settings->MonitorDefArray[0].y = vscreen->monitors[current_monitor].area.top;
settings->MonitorDefArray[0].width = MIN(width, (INT64)(*pMaxWidth));
settings->MonitorDefArray[0].height = MIN(height, (INT64)(*pMaxHeight));
settings->MonitorDefArray[0].orig_screen = current_monitor;
rdpMonitor* monitor =
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, 0);
if (!monitor)
goto fail;
monitor->x = vscreen->monitors[current_monitor].area.left;
monitor->y = vscreen->monitors[current_monitor].area.top;
monitor->width = MIN(width, (INT64)(*pMaxWidth));
monitor->height = MIN(height, (INT64)(*pMaxHeight));
monitor->orig_screen = current_monitor;
nmonitors = 1;
}
settings->MonitorCount = nmonitors;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorCount, nmonitors))
goto fail;
/* If we have specific monitor information */
if (settings->MonitorCount)
if (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 0)
{
UINT32 i;
const rdpMonitor* cmonitor =
freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, 0);
if (!cmonitor)
goto fail;
/* Initialize bounding rectangle for all monitors */
int vX = settings->MonitorDefArray[0].x;
int vY = settings->MonitorDefArray[0].y;
int vR = vX + settings->MonitorDefArray[0].width;
int vB = vY + settings->MonitorDefArray[0].height;
int vX = cmonitor->x;
int vY = cmonitor->y;
int vR = vX + cmonitor->width;
int vB = vY + cmonitor->height;
xfc->fullscreenMonitors.top = xfc->fullscreenMonitors.bottom =
xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right =
settings->MonitorDefArray[0].orig_screen;
xfc->fullscreenMonitors.left = xfc->fullscreenMonitors.right = cmonitor->orig_screen;
/* Calculate bounding rectangle around all monitors to be used AND
* also set the Xinerama indices which define left/top/right/bottom monitors.
*/
for (i = 1; i < settings->MonitorCount; i++)
for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++)
{
rdpMonitor* monitor =
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, i);
/* does the same as gdk_rectangle_union */
int destX = MIN(vX, settings->MonitorDefArray[i].x);
int destY = MIN(vY, settings->MonitorDefArray[i].y);
int destR =
MAX(vR, settings->MonitorDefArray[i].x + settings->MonitorDefArray[i].width);
int destB =
MAX(vB, settings->MonitorDefArray[i].y + settings->MonitorDefArray[i].height);
int destX = MIN(vX, monitor->x);
int destY = MIN(vY, monitor->y);
int destR = MAX(vR, monitor->x + monitor->width);
int destB = MAX(vB, monitor->y + monitor->height);
if (vX != destX)
xfc->fullscreenMonitors.left = settings->MonitorDefArray[i].orig_screen;
xfc->fullscreenMonitors.left = monitor->orig_screen;
if (vY != destY)
xfc->fullscreenMonitors.top = settings->MonitorDefArray[i].orig_screen;
xfc->fullscreenMonitors.top = monitor->orig_screen;
if (vR != destR)
xfc->fullscreenMonitors.right = settings->MonitorDefArray[i].orig_screen;
xfc->fullscreenMonitors.right = monitor->orig_screen;
if (vB != destB)
xfc->fullscreenMonitors.bottom = settings->MonitorDefArray[i].orig_screen;
xfc->fullscreenMonitors.bottom = monitor->orig_screen;
vX = destX / ((settings->PercentScreenUseWidth ? settings->PercentScreen : 100) / 100.);
vY =
destY / ((settings->PercentScreenUseHeight ? settings->PercentScreen : 100) / 100.);
vR = destR / ((settings->PercentScreenUseWidth ? settings->PercentScreen : 100) / 100.);
vB =
destB / ((settings->PercentScreenUseHeight ? settings->PercentScreen : 100) / 100.);
vX = destX / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100) /
100.);
vY = destY / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100) /
100.);
vR = destR / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100) /
100.);
vB = destB / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100) /
100.);
}
vscreen->area.left = 0;
@ -504,7 +546,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
vscreen->area.top = 0;
vscreen->area.bottom = vB - vY - 1;
if (settings->Workarea)
if (freerdp_settings_get_bool(settings, FreeRDP_Workarea))
{
vscreen->area.top = xfc->workArea.y;
vscreen->area.bottom = xfc->workArea.height + xfc->workArea.y - 1;
@ -513,11 +555,13 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if (!primaryMonitorFound)
{
/* If we have a command line setting we should use it */
if (settings->NumMonitorIds)
if (freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds) > 0)
{
/* The first monitor is the first in the setting which should be used */
if (settings->MonitorIds)
monitor_index = settings->MonitorIds[0];
UINT32* ids =
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0);
if (ids)
monitor_index = *ids;
}
else
{
@ -529,27 +573,37 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
monitor_index = XScreenNumberOfScreen(screen);
}
int j = monitor_index;
UINT32 j = monitor_index;
rdpMonitor* pmonitor =
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, j);
/* If the "default" monitor is not 0,0 use it */
if (settings->MonitorDefArray[j].x != 0 || settings->MonitorDefArray[j].y != 0)
if ((pmonitor->x != 0) || (pmonitor->y != 0))
{
settings->MonitorDefArray[j].is_primary = TRUE;
settings->MonitorLocalShiftX = settings->MonitorDefArray[j].x;
settings->MonitorLocalShiftY = settings->MonitorDefArray[j].y;
pmonitor->is_primary = TRUE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, pmonitor->x))
goto fail;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, pmonitor->y))
goto fail;
}
else
{
/* Lets try to see if there is a monitor with a 0,0 coordinate and use it as a
* fallback*/
for (i = 0; i < settings->MonitorCount; i++)
for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount);
i++)
{
if (!primaryMonitorFound && settings->MonitorDefArray[i].x == 0 &&
settings->MonitorDefArray[i].y == 0)
rdpMonitor* monitor = freerdp_settings_get_pointer_array_writable(
settings, FreeRDP_MonitorDefArray, i);
if (!primaryMonitorFound && monitor->x == 0 && monitor->y == 0)
{
settings->MonitorDefArray[i].is_primary = TRUE;
settings->MonitorLocalShiftX = settings->MonitorDefArray[i].x;
settings->MonitorLocalShiftY = settings->MonitorDefArray[i].y;
monitor->is_primary = TRUE;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX,
monitor->x))
goto fail;
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY,
monitor->y))
goto fail;
primaryMonitorFound = TRUE;
}
}
@ -563,12 +617,14 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
* So, we make sure to translate our primary monitor's upper-left corner to 0,0 on the
* server.
*/
for (i = 0; i < settings->MonitorCount; i++)
for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++)
{
settings->MonitorDefArray[i].x =
settings->MonitorDefArray[i].x - settings->MonitorLocalShiftX;
settings->MonitorDefArray[i].y =
settings->MonitorDefArray[i].y - settings->MonitorLocalShiftY;
rdpMonitor* monitor =
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, i);
monitor->x =
monitor->x - freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftX);
monitor->y =
monitor->y - freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftY);
}
/* Set the desktop width and height according to the bounding rectangle around the active
@ -580,8 +636,11 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
/* some 2008 server freeze at logon if we announce support for monitor layout PDU with
* #monitors < 2. So let's announce it only if we have more than 1 monitor.
*/
if (settings->MonitorCount > 1)
settings->SupportMonitorLayoutPdu = TRUE;
if (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 1)
{
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMonitorLayoutPdu, TRUE))
goto fail;
}
rc = TRUE;
fail:

View File

@ -573,8 +573,9 @@ static xfRailIconCache* RailIconCache_New(rdpSettings* settings)
if (!cache)
return NULL;
cache->numCaches = settings->RemoteAppNumIconCaches;
cache->numCacheEntries = settings->RemoteAppNumIconCacheEntries;
cache->numCaches = freerdp_settings_get_uint32(settings, FreeRDP_RemoteAppNumIconCaches);
cache->numCacheEntries =
freerdp_settings_get_uint32(settings, FreeRDP_RemoteAppNumIconCacheEntries);
cache->entries = calloc(1ull * cache->numCaches * cache->numCacheEntries, sizeof(xfRailIcon));
if (!cache->entries)

View File

@ -78,7 +78,8 @@ static BOOL xfVideoShowSurface(VideoClientContext* video, const VideoSurface* su
#ifdef WITH_XRENDER
if (settings->SmartSizing || settings->MultiTouchGestures)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
XPutImage(xfc->display, xfc->primary, xfc->gc, xfSurface->image, 0, 0, surface->x,
surface->y, surface->w, surface->h);

View File

@ -185,8 +185,12 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
xfc->savedPosX = xfc->window->left;
xfc->savedPosY = xfc->window->top;
startX = (settings->DesktopPosX != UINT32_MAX) ? settings->DesktopPosX : 0;
startY = (settings->DesktopPosY != UINT32_MAX) ? settings->DesktopPosY : 0;
startX = (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX)
? freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX)
: 0;
startY = (freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX)
? freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY)
: 0;
}
else
{
@ -199,22 +203,26 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
/* Determine the x,y starting location for the fullscreen window */
if (fullscreen)
{
const rdpMonitor* firstMonitor =
freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, 0);
/* Initialize startX and startY with reasonable values */
startX = settings->MonitorDefArray[0].x;
startY = settings->MonitorDefArray[0].y;
startX = firstMonitor->x;
startY = firstMonitor->y;
/* Search all monitors to find the lowest startX and startY values */
for (i = 0; i < settings->MonitorCount; i++)
for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++)
{
startX = MIN(startX, settings->MonitorDefArray[i].x);
startY = MIN(startY, settings->MonitorDefArray[i].y);
const rdpMonitor* monitor =
freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, i);
startX = MIN(startX, monitor->x);
startY = MIN(startY, monitor->y);
}
/* Lastly apply any monitor shift(translation from remote to local coordinate system)
* to startX and startY values
*/
startX += settings->MonitorLocalShiftX;
startY += settings->MonitorLocalShiftY;
startX += freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftX);
startY += freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftY);
}
/*
@ -223,7 +231,8 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
- The window manager supports multiple monitor full screen
- The user requested to use a single monitor to render the remote desktop
*/
if (xfc->_NET_WM_FULLSCREEN_MONITORS != None || settings->MonitorCount == 1)
if (xfc->_NET_WM_FULLSCREEN_MONITORS != None ||
freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) == 1)
{
xf_ResizeDesktopWindow(xfc, window, width, height);
@ -249,7 +258,7 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
}
/* Set monitor bounds */
if (settings->MonitorCount > 1)
if (freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount) > 1)
{
xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_FULLSCREEN_MONITORS, 5,
xfc->fullscreenMonitors.top, xfc->fullscreenMonitors.bottom,
@ -494,7 +503,7 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig
rdpSettings* settings = xfc->common.context.settings;
WINPR_ASSERT(settings);
Window parentWindow = (Window)settings->ParentWindowId;
Window parentWindow = (Window)freerdp_settings_get_uint64(settings, FreeRDP_ParentWindowId);
window->width = width;
window->height = height;
window->decorations = xfc->decorations;
@ -544,8 +553,9 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig
{
classHints->res_name = "xfreerdp";
if (settings->WmClass)
classHints->res_class = settings->WmClass;
const char* WmClass = freerdp_settings_get_string(settings, FreeRDP_WmClass);
if (WmClass)
classHints->res_class = WmClass;
else
classHints->res_class = "xfreerdp";
@ -589,13 +599,16 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig
* monitor instead of the upper-left monitor for remote app mode (which uses all monitors).
* This extra call after the window is mapped will position the login window correctly
*/
if (settings->RemoteApplicationMode)
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteApplicationMode))
{
XMoveWindow(xfc->display, window->handle, 0, 0);
}
else if (settings->DesktopPosX != UINT32_MAX && settings->DesktopPosY != UINT32_MAX)
else if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX) != UINT32_MAX) &&
(freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY) != UINT32_MAX))
{
XMoveWindow(xfc->display, window->handle, settings->DesktopPosX, settings->DesktopPosY);
XMoveWindow(xfc->display, window->handle,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosX),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopPosY));
}
window->floatbar = xf_floatbar_new(xfc, window->handle, name,
@ -628,7 +641,8 @@ void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width, int hei
XResizeWindow(xfc->display, window->handle, width, height);
#ifdef WITH_XRENDER
if (!settings->SmartSizing && !settings->DynamicResolutionUpdate)
if (!freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) &&
!freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
#endif
{
if (!xfc->fullscreen)
@ -836,10 +850,9 @@ BOOL xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow)
{
char* class = NULL;
if (settings->WmClass)
{
class_hints->res_class = settings->WmClass;
}
const char* WmClass = freerdp_settings_get_string(settings, FreeRDP_WmClass);
if (WmClass)
class_hints->res_class = WmClass;
else
{
class = malloc(sizeof("RAIL:00000000"));
@ -1121,7 +1134,7 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i
xf_lock_x11(xfc);
if (settings->SoftwareGdi)
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
XPutImage(xfc->display, appWindow->pixmap, appWindow->gc, xfc->image, ax, ay, x, y, width,
height);

View File

@ -219,20 +219,21 @@ static BOOL freerdp_client_settings_post_process(rdpSettings* settings)
{
/* Moved GatewayUseSameCredentials logic outside of cmdline.c, so
* that the rdp file also triggers this functionality */
if (settings->GatewayEnabled)
if (freerdp_settings_get_bool(settings, FreeRDP_GatewayEnabled))
{
if (settings->GatewayUseSameCredentials)
if (freerdp_settings_get_bool(settings, FreeRDP_GatewayUseSameCredentials))
{
if (settings->Username)
const char* Username = freerdp_settings_get_string(settings, FreeRDP_Username);
const char* Domain = freerdp_settings_get_string(settings, FreeRDP_Domain);
if (Username)
{
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUsername,
settings->Username))
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUsername, Username))
goto out_error;
}
if (settings->Domain)
if (Domain)
{
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, settings->Domain))
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, Domain))
goto out_error;
}
@ -248,30 +249,27 @@ static BOOL freerdp_client_settings_post_process(rdpSettings* settings)
/* Moved logic for Multimon and Span monitors to force fullscreen, so
* that the rdp file also triggers this functionality */
if (settings->SpanMonitors)
if (freerdp_settings_get_bool(settings, FreeRDP_SpanMonitors))
{
settings->UseMultimon = TRUE;
settings->Fullscreen = TRUE;
freerdp_settings_set_bool(settings, FreeRDP_UseMultimon, TRUE);
freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, TRUE);
}
else if (settings->UseMultimon)
else if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
settings->Fullscreen = TRUE;
freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, TRUE);
}
/* deal with the smartcard / smartcard logon stuff */
if (settings->SmartcardLogon)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartcardLogon))
{
settings->TlsSecurity = TRUE;
settings->RedirectSmartCards = TRUE;
settings->DeviceRedirection = TRUE;
freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, TRUE);
freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards, TRUE);
freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE);
freerdp_settings_set_bool(settings, FreeRDP_PasswordIsSmartcardPin, TRUE);
}
return TRUE;
out_error:
free(settings->GatewayUsername);
free(settings->GatewayDomain);
free(settings->GatewayPassword);
return FALSE;
}
@ -501,8 +499,10 @@ static BOOL client_cli_authenticate_raw(freerdp* instance, rdp_auth_reason reaso
if (!*password)
goto fail;
const BOOL fromStdin =
freerdp_settings_get_bool(instance->context->settings, FreeRDP_CredentialsFromStdin);
if (freerdp_passphrase_read(instance->context, prompt[2], *password, password_size,
instance->context->settings->CredentialsFromStdin) == NULL)
fromStdin) == NULL)
goto fail;
}
@ -594,7 +594,7 @@ BOOL client_cli_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_lis
#if defined(WITH_FREERDP_DEPRECATED)
BOOL client_cli_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
if (instance->settings->SmartcardLogon)
if (freerdp_settings_get_bool(instance->settings, FreeRDP_SmartcardLogon))
{
WLog_INFO(TAG, "Authentication via smartcard");
return TRUE;
@ -619,7 +619,9 @@ static DWORD client_cli_accept_certificate(freerdp* instance)
const rdpSettings* settings = instance->context->settings;
WINPR_ASSERT(settings);
if (settings->CredentialsFromStdin)
const BOOL fromStdin =
freerdp_settings_get_bool(instance->context->settings, FreeRDP_CredentialsFromStdin);
if (fromStdin)
return 0;
while (1)
@ -632,7 +634,7 @@ static DWORD client_cli_accept_certificate(freerdp* instance)
{
printf("\nError: Could not read answer from stdin.");
if (settings->CredentialsFromStdin)
if (fromStdin)
printf(" - Run without parameter \"--from-stdin\" to set trust.");
printf("\n");
@ -1203,7 +1205,6 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp*
{
BOOL retry = TRUE;
UINT32 error;
UINT32 maxRetries;
UINT32 numRetries = 0;
rdpSettings* settings;
@ -1215,7 +1216,8 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp*
settings = instance->context->settings;
WINPR_ASSERT(settings);
maxRetries = settings->AutoReconnectMaxRetries;
const UINT32 maxRetries =
freerdp_settings_get_uint32(settings, FreeRDP_AutoReconnectMaxRetries);
/* Only auto reconnect on network disconnects. */
error = freerdp_error_info(instance);
@ -1234,7 +1236,7 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp*
return FALSE;
}
if (!settings->AutoReconnectionEnabled)
if (!freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled))
{
/* No auto-reconnect - just quit */
return FALSE;

File diff suppressed because it is too large Load Diff

View File

@ -1653,6 +1653,7 @@ fail:
freerdp_addin_argv_free(args);
return NULL;
}
BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSettings* settings)
{
BOOL setDefaultConnectionType = TRUE;
@ -2508,14 +2509,20 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett
if (file->args->argc > 1)
{
const char* ConnectionFile = freerdp_settings_get_string(settings, FreeRDP_ConnectionFile);
settings->ConnectionFile = NULL;
WCHAR* ConnectionFile =
freerdp_settings_get_string_as_utf16(settings, FreeRDP_ConnectionFile, NULL);
if (freerdp_client_settings_parse_command_line(settings, file->args->argc, file->args->argv,
FALSE) < 0)
{
free(ConnectionFile);
return FALSE;
}
if (!freerdp_settings_set_string(settings, FreeRDP_ConnectionFile, ConnectionFile))
BOOL rc = freerdp_settings_set_string_from_utf16(settings, FreeRDP_ConnectionFile,
ConnectionFile);
free(ConnectionFile);
if (!rc)
return FALSE;
}

View File

@ -90,7 +90,7 @@ static BOOL check_settings_smartcard_no_redirection(rdpSettings* settings)
{
BOOL result = TRUE;
if (settings->RedirectSmartCards)
if (freerdp_settings_get_bool(settings, FreeRDP_RedirectSmartCards))
{
TEST_FAILURE("Expected RedirectSmartCards = FALSE, but RedirectSmartCards = TRUE!\n");
result = FALSE;

View File

@ -294,38 +294,43 @@ int TestClientRdpFile(int argc, char* argv[])
if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
goto fail;
if (settings->UseMultimon)
if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n", settings->UseMultimon);
printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n",
freerdp_settings_get_bool(settings, FreeRDP_UseMultimon));
goto fail;
}
if (!settings->Fullscreen)
if (!freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
settings->Fullscreen);
freerdp_settings_get_bool(settings, FreeRDP_Fullscreen));
goto fail;
}
#if 0 /* TODO: Currently unused */
if (settings->GatewayProfileUsageMethod != 1)
if (freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod) != 1)
{
printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n",
settings->GatewayProfileUsageMethod);
freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod));
goto fail;
}
#endif
if (strcmp(settings->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
"LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n", settings->GatewayHostname,
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
"LAB1-W2K8R2-GW.lab1.awake.local");
goto fail;
}
if (strcmp(settings->ServerHostname, "LAB1-W7-DM-01.lab1.awake.local") != 0)
if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
"LAB1-W7-DM-01.lab1.awake.local") != 0)
{
printf("ServerHostname mismatch: Actual: %s, Expected: %s\n", settings->ServerHostname,
printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
"LAB1-W7-DM-01.lab1.awake.local");
goto fail;
}
@ -348,38 +353,43 @@ int TestClientRdpFile(int argc, char* argv[])
if (!freerdp_client_populate_settings_from_rdp_file(file, settings))
goto fail;
if (settings->UseMultimon != 0)
if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n", settings->UseMultimon);
printf("UseMultiMon mismatch: Actual: %" PRIu32 ", Expected: 0\n",
freerdp_settings_get_bool(settings, FreeRDP_UseMultimon));
return -1;
}
if (!settings->Fullscreen)
if (!freerdp_settings_get_bool(settings, FreeRDP_Fullscreen))
{
printf("ScreenModeId mismatch: Actual: %" PRIu32 ", Expected: TRUE\n",
settings->Fullscreen);
freerdp_settings_get_bool(settings, FreeRDP_Fullscreen));
return -1;
}
#if 0 /* TODO: Currently unused */
if (settings->GatewayProfileUsageMethod != 1)
if (freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod) != 1)
{
printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n",
settings->GatewayProfileUsageMethod);
freerdp_settings_get_uint32(settings, FreeRDP_GatewayProfileUsageMethod));
goto fail;
}
#endif
if (strcmp(settings->ServerHostname, "LAB1-W7-DM-01.lab1.awake.global") != 0)
if (strcmp(freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
"LAB1-W7-DM-01.lab1.awake.global") != 0)
{
printf("ServerHostname mismatch: Actual: %s, Expected: %s\n", settings->ServerHostname,
printf("ServerHostname mismatch: Actual: %s, Expected: %s\n",
freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
"LAB1-W7-DM-01.lab1.awake.global");
goto fail;
}
if (strcmp(settings->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
if (strcmp(freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
"LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n", settings->GatewayHostname,
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
freerdp_settings_get_string(settings, FreeRDP_GatewayHostname),
"LAB1-W2K8R2-GW.lab1.awake.local");
goto fail;
}

View File

@ -50,7 +50,7 @@ static void ios_OnChannelConnectedEventHandler(void *context, const ChannelConne
if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
gdi_graphics_pipeline_init(afc->_p.gdi, (RdpgfxClientContext *)e->pInterface);
}
@ -84,7 +84,7 @@ static void ios_OnChannelDisconnectedEventHandler(void *context,
if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
{
if (settings->SoftwareGdi)
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
gdi_graphics_pipeline_uninit(afc->_p.gdi, (RdpgfxClientContext *)e->pInterface);
}
@ -111,14 +111,20 @@ static BOOL ios_pre_connect(freerdp *instance)
settings = instance->context->settings;
WINPR_ASSERT(settings);
settings->AutoLogonEnabled = settings->Password && (strlen(settings->Password) > 0);
const char *Password = freerdp_settings_get_string(settings, FreeRDP_Password);
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoLogonEnabled,
Password && (Password && (strlen(Password) > 0))))
return FALSE;
// Verify screen width/height are sane
if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64) ||
(settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
if ((freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) < 64) ||
(freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) < 64) ||
(freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) > 4096) ||
(freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) > 4096))
{
NSLog(@"%s: invalid dimensions %d %d", __func__, settings->DesktopWidth,
settings->DesktopHeight);
NSLog(@"%s: invalid dimensions %d %d", __func__,
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
return FALSE;
}

View File

@ -30,8 +30,9 @@ static BOOL ios_ui_authenticate_raw(freerdp *instance, char **username, char **p
@"password",
(*domain) ? [NSString stringWithUTF8String:*domain] : @"",
@"domain",
[NSString stringWithUTF8String:instance->context->settings->
ServerHostname],
[NSString stringWithUTF8String:freerdp_settings_get_string(
instance->context->settings,
FreeRDP_ServerHostname)],
@"hostname", // used for the auth prompt message; not changed
nil];
// request auth UI
@ -160,7 +161,8 @@ BOOL ios_ui_resize_window(rdpContext *context)
settings = context->settings;
gdi = context->gdi;
if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight))
if (!gdi_resize(gdi, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth),
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)))
return FALSE;
ios_resize_display_buffer(MFI_FROM_INSTANCE(context->instance));

View File

@ -299,7 +299,8 @@ out_free:
// Set Screen Size to automatic if widht or height are still 0
rdpSettings *settings = _freerdp->context->settings;
if (settings->DesktopWidth == 0 || settings->DesktopHeight == 0)
if (freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) == 0 ||
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) == 0)
{
CGSize size = CGSizeZero;
@ -310,8 +311,8 @@ out_free:
{
[_params setInt:size.width forKey:@"width"];
[_params setInt:size.height forKey:@"height"];
settings->DesktopWidth = size.width;
settings->DesktopHeight = size.height;
freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, size.width);
freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, size.height);
}
}
@ -319,7 +320,10 @@ out_free:
// resolution width
// Otherwise this could result in screen corruption ..
if (freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth) <= 16)
settings->DesktopWidth &= (~1);
{
const UINT32 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) & (~1);
freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, w);
}
[self performSelectorInBackground:@selector(runSession) withObject:nil];
}
@ -360,8 +364,8 @@ out_free:
/* RECTANGLE_16 rec;
rec.left = 0;
rec.top = 0;
rec.right = instance->settings->width;
rec.bottom = instance->settings->height;
rec.right = freerdp_settings_get_uint32(instance->settings, FreeRDP_DesktopWidth);
rec.bottom = freerdp_settings_get_uint32(instance->settings, FreeRDP_DesktopHeight);
*/
_suspended = NO;
// instance->update->SuppressOutput(instance->context, 1, &rec);