mirror of https://github.com/FreeRDP/FreeRDP
xfreerdp: add support for selecting individual monitors
This commit is contained in:
parent
24573ef08d
commit
12ec6c60db
|
@ -83,9 +83,10 @@ int xf_list_monitors(xfInfo* xfi)
|
||||||
|
|
||||||
BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
|
BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
int nmonitors;
|
int nmonitors;
|
||||||
int primaryMonitor;
|
int primaryMonitor;
|
||||||
|
int vWidth, vHeight;
|
||||||
int maxWidth, maxHeight;
|
int maxWidth, maxHeight;
|
||||||
VIRTUAL_SCREEN* vscreen;
|
VIRTUAL_SCREEN* vscreen;
|
||||||
|
|
||||||
|
@ -169,19 +170,24 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
|
||||||
nmonitors = 0;
|
nmonitors = 0;
|
||||||
primaryMonitor = 0;
|
primaryMonitor = 0;
|
||||||
|
|
||||||
vscreen->area.left = settings->DesktopPosX;
|
|
||||||
vscreen->area.right = MIN(settings->DesktopPosX + settings->DesktopWidth - 1, maxWidth);
|
|
||||||
vscreen->area.top = settings->DesktopPosY;
|
|
||||||
vscreen->area.bottom = MIN(settings->DesktopPosY + settings->DesktopHeight - 1, maxHeight);
|
|
||||||
|
|
||||||
for (i = 0; i < vscreen->nmonitors; i++)
|
for (i = 0; i < vscreen->nmonitors; i++)
|
||||||
{
|
{
|
||||||
if ((vscreen->monitors[i].area.left > vscreen->area.right) || (vscreen->monitors[i].area.right < vscreen->area.left) ||
|
if (settings->NumMonitorIds)
|
||||||
(vscreen->monitors[i].area.top > vscreen->area.bottom) || (vscreen->monitors[i].area.bottom < vscreen->area.top))
|
{
|
||||||
continue;
|
BOOL found = FALSE;
|
||||||
|
|
||||||
settings->MonitorDefArray[nmonitors].x = vscreen->monitors[i].area.left - settings->DesktopPosX;
|
for (j = 0; j < settings->NumMonitorIds; j++)
|
||||||
settings->MonitorDefArray[nmonitors].y = vscreen->monitors[i].area.top - settings->DesktopPosY;
|
{
|
||||||
|
if (settings->MonitorIds[j] == i)
|
||||||
|
found = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings->MonitorDefArray[nmonitors].x = vscreen->monitors[i].area.left;
|
||||||
|
settings->MonitorDefArray[nmonitors].y = vscreen->monitors[i].area.top;
|
||||||
settings->MonitorDefArray[nmonitors].width = MIN(vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1, settings->DesktopWidth);
|
settings->MonitorDefArray[nmonitors].width = MIN(vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1, settings->DesktopWidth);
|
||||||
settings->MonitorDefArray[nmonitors].height = MIN(vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1, settings->DesktopHeight);
|
settings->MonitorDefArray[nmonitors].height = MIN(vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1, settings->DesktopHeight);
|
||||||
settings->MonitorDefArray[nmonitors].is_primary = vscreen->monitors[i].primary;
|
settings->MonitorDefArray[nmonitors].is_primary = vscreen->monitors[i].primary;
|
||||||
|
@ -192,6 +198,24 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
|
||||||
|
|
||||||
settings->MonitorCount = nmonitors;
|
settings->MonitorCount = nmonitors;
|
||||||
|
|
||||||
|
vWidth = vHeight = 0;
|
||||||
|
settings->DesktopPosX = maxWidth - 1;
|
||||||
|
settings->DesktopPosY = maxHeight - 1;
|
||||||
|
|
||||||
|
for (i = 0; i < settings->MonitorCount; i++)
|
||||||
|
{
|
||||||
|
settings->DesktopPosX = MIN(settings->DesktopPosX, settings->MonitorDefArray[i].x);
|
||||||
|
settings->DesktopPosY = MIN(settings->DesktopPosY, settings->MonitorDefArray[i].y);
|
||||||
|
|
||||||
|
vWidth += settings->MonitorDefArray[i].width;
|
||||||
|
vHeight = MAX(vHeight, settings->MonitorDefArray[i].height);
|
||||||
|
}
|
||||||
|
|
||||||
|
vscreen->area.left = 0;
|
||||||
|
vscreen->area.right = vWidth - 1;
|
||||||
|
vscreen->area.top = 0;
|
||||||
|
vscreen->area.bottom = vHeight - 1;
|
||||||
|
|
||||||
if (nmonitors && !primaryMonitor)
|
if (nmonitors && !primaryMonitor)
|
||||||
settings->MonitorDefArray[0].is_primary = TRUE;
|
settings->MonitorDefArray[0].is_primary = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -140,9 +140,11 @@ void xf_SetWindowFullscreen(xfInfo* xfi, xfWindow* window, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
|
rdpSettings* settings = xfi->instance->settings;
|
||||||
|
|
||||||
xf_SetWindowDecorations(xfi, window, FALSE);
|
xf_SetWindowDecorations(xfi, window, FALSE);
|
||||||
|
|
||||||
XMoveResizeWindow(xfi->display, window->handle, 0, 0, window->width, window->height);
|
XMoveResizeWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY, window->width, window->height);
|
||||||
XMapRaised(xfi->display, window->handle);
|
XMapRaised(xfi->display, window->handle);
|
||||||
|
|
||||||
window->fullscreen = TRUE;
|
window->fullscreen = TRUE;
|
||||||
|
@ -495,9 +497,13 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (xfi->instance->settings->RemoteApplicationMode)
|
if (xfi->instance->settings->RemoteApplicationMode)
|
||||||
|
{
|
||||||
XMoveWindow(xfi->display, window->handle, 0, 0);
|
XMoveWindow(xfi->display, window->handle, 0, 0);
|
||||||
|
}
|
||||||
else if (settings->DesktopPosX || settings->DesktopPosY)
|
else if (settings->DesktopPosX || settings->DesktopPosY)
|
||||||
|
{
|
||||||
XMoveWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY);
|
XMoveWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xf_SetWindowText(xfi, window, name);
|
xf_SetWindowText(xfi, window, name);
|
||||||
|
|
|
@ -50,6 +50,7 @@ COMMAND_LINE_ARGUMENT_A args[] =
|
||||||
{ "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "Admin (or console) session" },
|
{ "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "Admin (or console) session" },
|
||||||
{ "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Use multiple monitors" },
|
{ "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Use multiple monitors" },
|
||||||
{ "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" },
|
{ "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" },
|
||||||
|
{ "monitors", COMMAND_LINE_VALUE_REQUIRED, "<0,1,2...>", NULL, NULL, -1, NULL, "Select monitors to use" },
|
||||||
{ "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List detected monitors" },
|
{ "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List detected monitors" },
|
||||||
{ "t", COMMAND_LINE_VALUE_REQUIRED, "<title>", NULL, NULL, -1, "title", "Window title" },
|
{ "t", COMMAND_LINE_VALUE_REQUIRED, "<title>", NULL, NULL, -1, "title", "Window title" },
|
||||||
{ "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueTrue, -1, NULL, "Window decorations" },
|
{ "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueTrue, -1, NULL, "Window decorations" },
|
||||||
|
@ -1092,6 +1093,24 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
|
||||||
{
|
{
|
||||||
settings->Workarea = TRUE;
|
settings->Workarea = TRUE;
|
||||||
}
|
}
|
||||||
|
CommandLineSwitchCase(arg, "monitors")
|
||||||
|
{
|
||||||
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
||||||
|
{
|
||||||
|
char** p;
|
||||||
|
int i, count = 0;
|
||||||
|
|
||||||
|
p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
|
||||||
|
|
||||||
|
settings->NumMonitorIds = count;
|
||||||
|
settings->MonitorIds = (UINT32*) malloc(sizeof(UINT32) * settings->NumMonitorIds);
|
||||||
|
|
||||||
|
for (i = 0; i < settings->NumMonitorIds; i++)
|
||||||
|
{
|
||||||
|
settings->MonitorIds[i] = atoi(p[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
CommandLineSwitchCase(arg, "monitor-list")
|
CommandLineSwitchCase(arg, "monitor-list")
|
||||||
{
|
{
|
||||||
settings->ListMonitors = TRUE;
|
settings->ListMonitors = TRUE;
|
||||||
|
|
|
@ -812,7 +812,9 @@ struct rdp_settings
|
||||||
ALIGN64 UINT32 DesktopPosX; /* 390 */
|
ALIGN64 UINT32 DesktopPosX; /* 390 */
|
||||||
ALIGN64 UINT32 DesktopPosY; /* 391 */
|
ALIGN64 UINT32 DesktopPosY; /* 391 */
|
||||||
ALIGN64 BOOL ListMonitors; /* 392 */
|
ALIGN64 BOOL ListMonitors; /* 392 */
|
||||||
UINT64 padding0448[448 - 393]; /* 393 */
|
ALIGN64 UINT32* MonitorIds; /* 393 */
|
||||||
|
ALIGN64 UINT32 NumMonitorIds; /* 394 */
|
||||||
|
UINT64 padding0448[448 - 395]; /* 395 */
|
||||||
|
|
||||||
/* Client Message Channel Data */
|
/* Client Message Channel Data */
|
||||||
UINT64 padding0512[512 - 448]; /* 448 */
|
UINT64 padding0512[512 - 448]; /* 448 */
|
||||||
|
|
Loading…
Reference in New Issue