Smart sizing, dual monitor in client app

Scaling functions: do not scale with a ratio > 1.
This commit is contained in:
Benoit LeBlanc 2013-04-25 15:42:40 -04:00
parent 28e67a6adc
commit a5bcb8bc21
5 changed files with 79 additions and 15 deletions

View File

@ -170,6 +170,48 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
switch (Msg)
{
case WM_MOVE:
if (!wfi->fullscreen)
{
int x = LOWORD(lParam);
int y = HIWORD(lParam);
((wfContext*) wfi->instance->context)->wfi->client_x = x;
((wfContext*) wfi->instance->context)->wfi->client_y = y;
}
break;
case WM_SIZE:
{
int dwStyle = GetWindowLongPtr(wfi->hwnd, GWL_STYLE);
int width = LOWORD(lParam);
int height = HIWORD(lParam);
if (!wfi->fullscreen)
{
//if (width > wfi->width || height > wfi->height)
//{
// // Calculate decoration size
// RECT decoration;
// GetWindowRect(wfi->hwnd, &decoration);
// decoration.right = decoration.right - decoration.left - width;
// decoration.left = 0;
// decoration.bottom = decoration.bottom - decoration.top - height;
// decoration.top = 0;
// width = min(wfi->width + decoration.right, width + decoration.right);
// height = min(wfi->height + decoration.bottom, height + decoration.bottom);
// SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, width, height, SWP_NOMOVE | SWP_FRAMECHANGED);
//}
((wfContext*) wfi->instance->context)->wfi->client_width = width;
((wfContext*) wfi->instance->context)->wfi->client_height = height;
}
}
break;
case WM_ERASEBKGND:
/* Say we handled it - prevents flickering */
return (LRESULT) 1;
@ -286,7 +328,7 @@ BOOL wf_scale_blt(wfInfo* wfi, HDC hdc, int x, int y, int w, int h, HDC hdcSrc,
if (!wh)
wh = dh;
if (!wfi->instance->settings->SmartSizing || (ww == dw && wh == dh))
if (wfi->fullscreen || !wfi->instance->settings->SmartSizing || (ww >= dw && wh >= dh))
{
return BitBlt(hdc, x, y, w, h, wfi->primary->hdc, x1, y1, SRCCOPY);
}
@ -295,7 +337,7 @@ BOOL wf_scale_blt(wfInfo* wfi, HDC hdc, int x, int y, int w, int h, HDC hdcSrc,
SetStretchBltMode(hdc, HALFTONE);
SetBrushOrgEx(hdc, 0, 0, NULL);
return StretchBlt(hdc, x * ww / dw, y * wh / dh, ww, wh, wfi->primary->hdc, x1, y1, dw, dh, SRCCOPY);
return StretchBlt(hdc, MIN(x, x * ww / dw), MIN(y, y * wh / dh), MIN(dw, ww), MIN(dh, wh), wfi->primary->hdc, x1, y1, dw, dh, SRCCOPY);
}
return TRUE;
@ -316,8 +358,8 @@ void wf_scale_mouse_event(wfInfo* wfi, rdpInput* input, UINT16 flags, UINT16 x,
dw = wfi->instance->settings->DesktopWidth;
dh = wfi->instance->settings->DesktopHeight;
if ((ww == dw) && (wh == dh))
if ((ww >= dw) && (wh >= dh))
input->MouseEvent(input, flags, x, y);
else
input->MouseEvent(input, flags, x * dw / ww, y * dh / wh);
input->MouseEvent(input, flags, MAX(x, x * dw / ww), MAX(y, y * dh / wh));
}

View File

@ -189,10 +189,10 @@ void wf_scale_rect(wfInfo* wfi, RECT* source)
if (wfi->instance->settings->SmartSizing && (ww != dw || wh != dh))
{
source->bottom = MIN(dh, MAX(0, source->bottom * wh / dh + 2));
source->top = MIN(dh, MAX(0, source->top * wh / dh - 2));
source->left = MIN(dw, MAX(0, source->left * ww / dw - 2));
source->right = MIN(dw, MAX(0, source->right * ww / dw + 2));
source->bottom = MIN(source->bottom + 2, MAX(0, source->bottom * wh / dh + 2));
source->top = MIN(source->top - 2, MAX(0, source->top * wh / dh - 2));
source->left = MIN(source->left - 2, MAX(0, source->left * ww / dw - 2));
source->right = MIN(source->right + 2, MAX(0, source->right * ww / dw + 2));
}
}
@ -234,7 +234,7 @@ void wf_update_offset(wfInfo* wfi)
if (wfi->offset_y < y)
wfi->offset_y = y;
}
else
else
{
wfi->offset_x = (GetSystemMetrics(SM_CXSCREEN) - wfi->width) / 2;
if (wfi->offset_x < 0)
@ -255,7 +255,6 @@ void wf_resize_window(wfInfo* wfi)
{
if (wfi->fullscreen)
{
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP);
if(wfi->instance->settings->UseMultimon)
{
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
@ -263,10 +262,14 @@ void wf_resize_window(wfInfo* wfi)
int w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP);
SetWindowPos(wfi->hwnd, HWND_TOP, x, y, w, h, SWP_FRAMECHANGED);
}
else
{
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP);
SetWindowPos(wfi->hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
}
}
else if (!wfi->instance->settings->Decorations)
{
@ -290,17 +293,29 @@ void wf_resize_window(wfInfo* wfi)
RECT rc_wnd;
RECT rc_client;
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX);
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX);
if (!wfi->client_height)
wfi->client_height = wfi->height;
if (!wfi->client_width)
wfi->client_width = wfi->width;
if (!wfi->client_x)
wfi->client_x = 10;
if (!wfi->client_y)
wfi->client_y = 10;
/* Now resize to get full canvas size and room for caption and borders */
SetWindowPos(wfi->hwnd, HWND_TOP, 10, 10, wfi->width, wfi->height, SWP_FRAMECHANGED);
SetWindowPos(wfi->hwnd, HWND_TOP, wfi->client_x, wfi->client_y, wfi->client_width, wfi->client_height, SWP_FRAMECHANGED);
GetClientRect(wfi->hwnd, &rc_client);
GetWindowRect(wfi->hwnd, &rc_wnd);
wfi->diff.x = (rc_wnd.right - rc_wnd.left) - rc_client.right;
wfi->diff.y = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, wfi->width + wfi->diff.x, wfi->height + wfi->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, wfi->client_width + wfi->diff.x, wfi->client_height + wfi->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
}
wf_update_offset(wfi);
}

View File

@ -692,8 +692,8 @@ DWORD WINAPI wf_thread(LPVOID lpParam)
width = LOWORD(msg.lParam);
height = HIWORD(msg.lParam);
((wfContext*) instance->context)->wfi->client_width = width;
((wfContext*) instance->context)->wfi->client_height = height;
//((wfContext*) instance->context)->wfi->client_width = width;
//((wfContext*) instance->context)->wfi->client_height = height;
SetWindowPos(((wfContext*) instance->context)->wfi->hwnd, HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
}

View File

@ -89,6 +89,8 @@ struct wf_info
int fullscreen;
int percentscreen;
char window_title[64];
int client_x;
int client_y;
int client_width;
int client_height;

View File

@ -1071,6 +1071,11 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
CommandLineSwitchCase(arg, "multimon")
{
settings->UseMultimon = TRUE;
settings->Fullscreen = TRUE;
// force?
settings->DesktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
settings->DesktopHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
{