Simplified windows context.

This commit is contained in:
Armin Novak 2016-08-03 12:37:40 +02:00
parent 71a73068ec
commit fbdb00aa0c
6 changed files with 676 additions and 684 deletions

View File

@ -143,10 +143,9 @@ static BOOL wf_sw_desktop_resize(rdpContext* context)
if (wfc->primary)
{
UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
wf_image_free(wfc->primary);
wfc->primary = wf_image_new(wfc, settings->DesktopWidth,
settings->DesktopHeight, format, NULL);
settings->DesktopHeight, wfc->context.gdi->dstFormat, NULL);
}
return TRUE;
@ -188,11 +187,10 @@ static BOOL wf_hw_desktop_resize(rdpContext* context)
if (wfc->primary)
{
UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
same = (wfc->primary == wfc->drawing) ? TRUE : FALSE;
wf_image_free(wfc->primary);
wfc->primary = wf_image_new(wfc, settings->DesktopWidth,
settings->DesktopHeight, format, NULL);
settings->DesktopHeight, wfc->context.gdi->dstFormat, NULL);
if (same)
wfc->drawing = wfc->primary;
@ -202,7 +200,7 @@ static BOOL wf_hw_desktop_resize(rdpContext* context)
{
if (wfc->hwnd)
SetWindowPos(wfc->hwnd, HWND_TOP, -1, -1, settings->DesktopWidth + wfc->diff.x,
settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE);
settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE);
}
else
{
@ -227,7 +225,6 @@ static BOOL wf_pre_connect(freerdp* instance)
context = instance->context;
wfc = (wfContext*) instance->context;
wfc->instance = instance;
settings = instance->settings;
settings->OsMajorType = OSMAJORTYPE_WINDOWS;
settings->OsMinorType = OSMINORTYPE_WINDOWS_NT;
@ -299,22 +296,22 @@ static BOOL wf_pre_connect(freerdp* instance)
}
if ((settings->DesktopWidth < 64) || (settings->DesktopHeight < 64) ||
(settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
(settings->DesktopWidth > 4096) || (settings->DesktopHeight > 4096))
{
WLog_ERR(TAG, "invalid dimensions %d %d", settings->DesktopWidth,
settings->DesktopHeight);
settings->DesktopHeight);
return FALSE;
}
freerdp_set_param_uint32(settings, FreeRDP_KeyboardLayout,
(int) GetKeyboardLayout(0) & 0x0000FFFF);
(int) GetKeyboardLayout(0) & 0x0000FFFF);
PubSub_SubscribeChannelConnected(instance->context->pubSub,
(pChannelConnectedEventHandler) wf_OnChannelConnectedEventHandler);
(pChannelConnectedEventHandler) wf_OnChannelConnectedEventHandler);
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
(pChannelDisconnectedEventHandler) wf_OnChannelDisconnectedEventHandler);
(pChannelDisconnectedEventHandler) wf_OnChannelDisconnectedEventHandler);
if (freerdp_channels_pre_connect(instance->context->channels,
instance) != CHANNEL_RC_OK)
instance) != CHANNEL_RC_OK)
return FALSE;
return TRUE;
@ -326,7 +323,7 @@ static void wf_add_system_menu(wfContext* wfc)
MENUITEMINFO item_info;
ZeroMemory(&item_info, sizeof(MENUITEMINFO));
item_info.fMask = MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING |
MIIM_DATA;
MIIM_DATA;
item_info.cbSize = sizeof(MENUITEMINFO);
item_info.wID = SYSCOMMAND_ID_SMARTSIZING;
item_info.fType = MFT_STRING;
@ -335,7 +332,7 @@ static void wf_add_system_menu(wfContext* wfc)
item_info.dwItemData = (ULONG_PTR) wfc;
InsertMenuItem(hMenu, 6, TRUE, &item_info);
if (wfc->instance->settings->SmartSizing)
if (wfc->context.settings->SmartSizing)
{
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, MF_CHECKED);
}
@ -351,36 +348,33 @@ static BOOL wf_post_connect(freerdp* instance)
WCHAR lpWindowName[64];
rdpSettings* settings;
EmbedWindowEventArgs e;
const UINT32 format = PIXEL_FORMAT_BGRX32;
settings = instance->settings;
context = instance->context;
wfc = (wfContext*) instance->context;
cache = instance->context->cache;
UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
wfc->format = PIXEL_FORMAT_BGRX32;
wfc->primary = wf_image_new(wfc, settings->DesktopWidth,
settings->DesktopHeight, format, NULL);
settings->DesktopHeight, format, NULL);
if (!gdi_init_ex(instance, wfc->format, 0, wfc->primary->pdata, wf_image_free))
if (!gdi_init_ex(instance, format, 0, wfc->primary->pdata, wf_image_free))
return FALSE;
gdi = instance->context->gdi;
if (!settings->SoftwareGdi)
{
UINT32 format = gdi_get_pixel_format(settings->ColorDepth, FALSE);
wf_gdi_register_update_callbacks(instance->update);
wfc->primary = wf_image_new(wfc, settings->DesktopWidth,
settings->DesktopHeight, format, NULL);
}
if (settings->WindowTitle != NULL)
_snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"%S", settings->WindowTitle);
else if (settings->ServerPort == 3389)
_snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S",
settings->ServerHostname);
settings->ServerHostname);
else
_snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S:%d",
settings->ServerHostname, settings->ServerPort);
settings->ServerHostname, settings->ServerPort);
if (settings->EmbeddedWindow)
settings->Decorations = FALSE;
@ -391,20 +385,20 @@ static BOOL wf_post_connect(freerdp* instance)
dwStyle = WS_CHILD | WS_BORDER;
else
dwStyle = WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX
| WS_MAXIMIZEBOX;
| WS_MAXIMIZEBOX;
if (!wfc->hwnd)
{
wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, lpWindowName,
dwStyle,
0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL);
dwStyle,
0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL);
SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR) wfc);
}
wf_resize_window(wfc);
wf_add_system_menu(wfc);
BitBlt(wfc->primary->hdc, 0, 0, settings->DesktopWidth, settings->DesktopHeight,
NULL, 0, 0, BLACKNESS);
NULL, 0, 0, BLACKNESS);
wfc->drawing = wfc->primary;
EventArgsInit(&e, "wfreerdp");
e.embed = FALSE;
@ -459,7 +453,7 @@ static CREDUI_INFOA wfUiInfo =
};
static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
char** username, char** password, char** domain)
char** username, char** password, char** domain)
{
BOOL fSave;
DWORD status;
@ -473,8 +467,8 @@ static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
ZeroMemory(Password, sizeof(Password));
dwFlags = CREDUI_FLAGS_DO_NOT_PERSIST | CREDUI_FLAGS_EXCLUDE_CERTIFICATES;
status = CredUIPromptForCredentialsA(&wfUiInfo, title, NULL, 0,
UserName, CREDUI_MAX_USERNAME_LENGTH + 1,
Password, CREDUI_MAX_PASSWORD_LENGTH + 1, &fSave, dwFlags);
UserName, CREDUI_MAX_USERNAME_LENGTH + 1,
Password, CREDUI_MAX_PASSWORD_LENGTH + 1, &fSave, dwFlags);
if (status != NO_ERROR)
{
@ -485,7 +479,7 @@ static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
ZeroMemory(User, sizeof(User));
ZeroMemory(Domain, sizeof(Domain));
status = CredUIParseUserNameA(UserName, User, sizeof(User), Domain,
sizeof(Domain));
sizeof(Domain));
//WLog_ERR(TAG, "User: %s Domain: %s Password: %s", User, Domain, Password);
*username = _strdup(User);
@ -520,14 +514,14 @@ static BOOL wf_authenticate_raw(freerdp* instance, const char* title,
}
static BOOL wf_authenticate(freerdp* instance,
char** username, char** password, char** domain)
char** username, char** password, char** domain)
{
return wf_authenticate_raw(instance, instance->settings->ServerHostname,
username, password, domain);
username, password, domain);
}
static BOOL wf_gw_authenticate(freerdp* instance,
char** username, char** password, char** domain)
char** username, char** password, char** domain)
{
char tmp[MAX_PATH];
sprintf_s(tmp, sizeof(tmp), "Gateway %s", instance->settings->GatewayHostname);
@ -535,11 +529,11 @@ static BOOL wf_gw_authenticate(freerdp* instance,
}
static DWORD wf_verify_certificate(freerdp* instance,
const char* common_name,
const char* subject,
const char* issuer,
const char* fingerprint,
BOOL host_mismatch)
const char* common_name,
const char* subject,
const char* issuer,
const char* fingerprint,
BOOL host_mismatch)
{
#if 0
DWORD mode;
@ -556,9 +550,9 @@ static DWORD wf_verify_certificate(freerdp* instance,
WLog_INFO(TAG, "\tThumbprint: %s", fingerprint);
WLog_INFO(TAG, "\tHostMismatch: %s", host_mismatch ? "Yes" : "No");
WLog_INFO(TAG,
"The above X.509 certificate could not be verified, possibly because you do not have "
"the CA certificate in your certificate store, or the certificate has expired. "
"Please look at the documentation on how to create local certificate store for a private CA.");
"The above X.509 certificate could not be verified, possibly because you do not have "
"the CA certificate in your certificate store, or the certificate has expired. "
"Please look at the documentation on how to create local certificate store for a private CA.");
/* TODO: ask for user validation */
#if 0
input_handle = GetStdHandle(STD_INPUT_HANDLE);
@ -572,11 +566,11 @@ static DWORD wf_verify_certificate(freerdp* instance,
}
static DWORD wf_verify_changed_certificate(freerdp* instance,
const char* common_name,
const char* subject, const char* issuer,
const char* fingerprint,
const char* old_subject, const char* old_issuer,
const char* old_fingerprint)
const char* common_name,
const char* subject, const char* issuer,
const char* fingerprint,
const char* old_subject, const char* old_issuer,
const char* old_fingerprint)
{
WLog_ERR(TAG, "!!! Certificate has changed !!!");
WLog_ERR(TAG, "New Certificate details:");
@ -588,9 +582,9 @@ static DWORD wf_verify_changed_certificate(freerdp* instance,
WLog_ERR(TAG, "\tIssuer: %s", old_issuer);
WLog_ERR(TAG, "\tThumbprint: %s", old_fingerprint);
WLog_ERR(TAG,
"The above X.509 certificate does not match the certificate used for previous connections. "
"This may indicate that the certificate has been tampered with."
"Please contact the administrator of the RDP server and clarify.");
"The above X.509 certificate does not match the certificate used for previous connections. "
"This may indicate that the certificate has been tampered with."
"Please contact the administrator of the RDP server and clarify.");
return 0;
}
@ -651,7 +645,7 @@ static void* wf_input_thread(void* arg)
while (MessageQueue_Peek(queue, &message, TRUE))
{
status = freerdp_message_queue_process_message(instance,
FREERDP_INPUT_MESSAGE_QUEUE, &message);
FREERDP_INPUT_MESSAGE_QUEUE, &message);
if (!status)
break;
@ -697,8 +691,8 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
if (async_input)
{
if (!(input_thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) wf_input_thread,
instance, 0, NULL)))
(LPTHREAD_START_ROUTINE) wf_input_thread,
instance, 0, NULL)))
{
WLog_ERR(TAG, "Failed to create async input thread.");
goto disconnect;
@ -729,10 +723,10 @@ static DWORD WINAPI wf_client_thread(LPVOID lpParam)
}
if (MsgWaitForMultipleObjects(nCount, handles, FALSE, 1000,
QS_ALLINPUT) == WAIT_FAILED)
QS_ALLINPUT) == WAIT_FAILED)
{
WLog_ERR(TAG, "wfreerdp_run: WaitForMultipleObjects failed: 0x%04X",
GetLastError());
GetLastError());
break;
}
@ -820,7 +814,7 @@ static DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
wfc = (wfContext*) lpParam;
assert(NULL != wfc);
hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfc->hInstance,
0);
0);
if (hook_handle)
{
@ -852,7 +846,7 @@ static DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
static rdpSettings* freerdp_client_get_settings(wfContext* wfc)
{
return wfc->instance->settings;
return wfc->context.settings;
}
static int freerdp_client_focus_in(wfContext* wfc)
@ -874,14 +868,14 @@ static int freerdp_client_set_window_size(wfContext* wfc, int width, int height)
if ((width != wfc->client_width) || (height != wfc->client_height))
{
PostThreadMessage(wfc->mainThreadId, WM_SIZE, SIZE_RESTORED,
((UINT) height << 16) | (UINT) width);
((UINT) height << 16) | (UINT) width);
}
return 0;
}
void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
UINT32 client_height)
UINT32 client_height)
{
if (wfc->disablewindowtracking)
return;
@ -889,7 +883,7 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
// prevent infinite message loop
wfc->disablewindowtracking = TRUE;
if (wfc->instance->settings->SmartSizing)
if (wfc->context.settings->SmartSizing)
{
wfc->xCurrentScroll = 0;
wfc->yCurrentScroll = 0;
@ -909,30 +903,30 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
BOOL horiz = wfc->xScrollVisible;
BOOL vert = wfc->yScrollVisible;;
if (!horiz && client_width < wfc->instance->settings->DesktopWidth)
if (!horiz && client_width < wfc->context.settings->DesktopWidth)
{
horiz = TRUE;
}
else if (horiz
&& client_width >=
wfc->instance->settings->DesktopWidth/* - GetSystemMetrics(SM_CXVSCROLL)*/)
&& client_width >=
wfc->context.settings->DesktopWidth/* - GetSystemMetrics(SM_CXVSCROLL)*/)
{
horiz = FALSE;
}
if (!vert && client_height < wfc->instance->settings->DesktopHeight)
if (!vert && client_height < wfc->context.settings->DesktopHeight)
{
vert = TRUE;
}
else if (vert
&& client_height >=
wfc->instance->settings->DesktopHeight/* - GetSystemMetrics(SM_CYHSCROLL)*/)
&& client_height >=
wfc->context.settings->DesktopHeight/* - GetSystemMetrics(SM_CYHSCROLL)*/)
{
vert = FALSE;
}
if (horiz == vert && (horiz != wfc->xScrollVisible
&& vert != wfc->yScrollVisible))
&& vert != wfc->yScrollVisible))
{
if (ShowScrollBar(wfc->hwnd, SB_BOTH, horiz))
{
@ -962,12 +956,12 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
// 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(wfc->instance->settings->DesktopWidth - client_width, 0);
wfc->xMaxScroll = MAX(wfc->context.settings->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 = wfc->instance->settings->DesktopWidth;
si.nMax = wfc->context.settings->DesktopWidth;
si.nPage = client_width;
si.nPos = wfc->xCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
@ -978,13 +972,13 @@ void wf_size_scrollbars(wfContext* wfc, UINT32 client_width,
// 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(wfc->instance->settings->DesktopHeight - client_height,
0);
wfc->yMaxScroll = MAX(wfc->context.settings->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 = wfc->instance->settings->DesktopHeight;
si.nMax = wfc->context.settings->DesktopHeight;
si.nPage = client_height;
si.nPos = wfc->yCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
@ -1022,8 +1016,6 @@ static void wfreerdp_client_global_uninit(void)
static BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context)
{
wfContext* wfc = (wfContext*) context;
if (!(wfreerdp_client_global_init()))
return FALSE;
@ -1036,8 +1028,7 @@ static BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context)
instance->GatewayAuthenticate = wf_gw_authenticate;
instance->VerifyCertificate = wf_verify_certificate;
instance->VerifyChangedCertificate = wf_verify_changed_certificate;
wfc->instance = instance;
wfc->settings = instance->settings;
return TRUE;
}
@ -1082,7 +1073,7 @@ static int wfreerdp_client_start(rdpContext* context)
wfc->wndClass.hIconSm = wfc->icon;
RegisterClassEx(&(wfc->wndClass));
wfc->keyboardThread = CreateThread(NULL, 0, wf_keyboard_thread, (void*) wfc, 0,
&wfc->keyboardThreadId);
&wfc->keyboardThreadId);
if (!wfc->keyboardThread)
return -1;
@ -1091,7 +1082,7 @@ static int wfreerdp_client_start(rdpContext* context)
return -1;
wfc->thread = CreateThread(NULL, 0, wf_client_thread, (void*) instance, 0,
&wfc->mainThreadId);
&wfc->mainThreadId);
if (!wfc->thread)
return -1;

View File

@ -76,11 +76,6 @@ struct wf_context
rdpContext context;
DEFINE_RDP_CLIENT_COMMON();
freerdp* instance;
rdpSettings* settings;
UINT32 format; /* Local framebuffer color format */
int offset_x;
int offset_y;
int fs_toggle;

View File

@ -40,9 +40,9 @@ static HWND g_focus_hWnd;
#define Y_POS(lParam) ((UINT16) ((lParam >> 16) & 0xFFFF))
static BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
HDC hdcSrc, int x1, int y1, DWORD rop);
HDC hdcSrc, int x1, int y1, DWORD rop);
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y);
UINT16 x, UINT16 y);
static BOOL g_flipping_in;
static BOOL g_flipping_out;
@ -50,7 +50,7 @@ static BOOL g_flipping_out;
static BOOL alt_ctrl_down()
{
return ((GetAsyncKeyState(VK_CONTROL) & 0x8000) ||
(GetAsyncKeyState(VK_MENU) & 0x8000));
(GetAsyncKeyState(VK_MENU) & 0x8000));
}
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
@ -60,7 +60,7 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
rdpInput* input;
PKBDLLHOOKSTRUCT p;
DEBUG_KBD("Low-level keyboard hook, hWnd %X nCode %X wParam %X", g_focus_hWnd,
nCode, wParam);
nCode, wParam);
if (g_flipping_in)
{
@ -74,74 +74,74 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
wfc = (wfContext*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
p = (PKBDLLHOOKSTRUCT) lParam;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
wfc = (wfContext*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
p = (PKBDLLHOOKSTRUCT) lParam;
if (!wfc || !p)
if (!wfc || !p)
return 1;
input = wfc->context.input;
rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED);
DEBUG_KBD("keydown %d scanCode %04X flags %02X vkCode %02X",
(wParam == WM_KEYDOWN), (BYTE) p->scanCode, p->flags, p->vkCode);
if (wfc->fs_toggle &&
((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
(GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
(GetAsyncKeyState(VK_MENU) & 0x8000)) /* could also use flags & LLKHF_ALTDOWN */
{
if (wParam == WM_KEYDOWN)
{
wf_toggle_fullscreen(wfc);
return 1;
input = wfc->instance->input;
rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED);
DEBUG_KBD("keydown %d scanCode %04X flags %02X vkCode %02X",
(wParam == WM_KEYDOWN), (BYTE) p->scanCode, p->flags, p->vkCode);
if (wfc->fs_toggle &&
((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
(GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
(GetAsyncKeyState(VK_MENU) & 0x8000)) /* could also use flags & LLKHF_ALTDOWN */
{
if (wParam == WM_KEYDOWN)
{
wf_toggle_fullscreen(wfc);
return 1;
}
}
}
if (rdp_scancode == RDP_SCANCODE_NUMLOCK_EXTENDED)
{
/* Windows sends NumLock as extended - rdp doesn't */
DEBUG_KBD("hack: NumLock (x45) should not be extended");
rdp_scancode = RDP_SCANCODE_NUMLOCK;
}
else if (rdp_scancode == RDP_SCANCODE_NUMLOCK)
{
/* Windows sends Pause as if it was a RDP NumLock (handled above).
if (rdp_scancode == RDP_SCANCODE_NUMLOCK_EXTENDED)
{
/* Windows sends NumLock as extended - rdp doesn't */
DEBUG_KBD("hack: NumLock (x45) should not be extended");
rdp_scancode = RDP_SCANCODE_NUMLOCK;
}
else if (rdp_scancode == RDP_SCANCODE_NUMLOCK)
{
/* Windows sends Pause as if it was a RDP NumLock (handled above).
* It must however be sent as a one-shot Ctrl+NumLock */
if (wParam == WM_KEYDOWN)
{
DEBUG_KBD("Pause, sent as Ctrl+NumLock");
freerdp_input_send_keyboard_event_ex(input, TRUE, RDP_SCANCODE_LCONTROL);
freerdp_input_send_keyboard_event_ex(input, TRUE, RDP_SCANCODE_NUMLOCK);
freerdp_input_send_keyboard_event_ex(input, FALSE, RDP_SCANCODE_LCONTROL);
freerdp_input_send_keyboard_event_ex(input, FALSE, RDP_SCANCODE_NUMLOCK);
}
else
{
DEBUG_KBD("Pause up");
}
return 1;
}
else if (rdp_scancode == RDP_SCANCODE_RSHIFT_EXTENDED)
if (wParam == WM_KEYDOWN)
{
DEBUG_KBD("right shift (x36) should not be extended");
rdp_scancode = RDP_SCANCODE_RSHIFT;
DEBUG_KBD("Pause, sent as Ctrl+NumLock");
freerdp_input_send_keyboard_event_ex(input, TRUE, RDP_SCANCODE_LCONTROL);
freerdp_input_send_keyboard_event_ex(input, TRUE, RDP_SCANCODE_NUMLOCK);
freerdp_input_send_keyboard_event_ex(input, FALSE, RDP_SCANCODE_LCONTROL);
freerdp_input_send_keyboard_event_ex(input, FALSE, RDP_SCANCODE_NUMLOCK);
}
else
{
DEBUG_KBD("Pause up");
}
freerdp_input_send_keyboard_event_ex(input, !(p->flags & LLKHF_UP),
rdp_scancode);
return 1;
}
else if (rdp_scancode == RDP_SCANCODE_RSHIFT_EXTENDED)
{
DEBUG_KBD("right shift (x36) should not be extended");
rdp_scancode = RDP_SCANCODE_RSHIFT;
}
if (p->vkCode == VK_NUMLOCK || p->vkCode == VK_CAPITAL
|| p->vkCode == VK_SCROLL || p->vkCode == VK_KANA)
DEBUG_KBD("lock keys are processed on client side too to toggle their indicators");
else
return 1;
freerdp_input_send_keyboard_event_ex(input, !(p->flags & LLKHF_UP),
rdp_scancode);
break;
if (p->vkCode == VK_NUMLOCK || p->vkCode == VK_CAPITAL
|| p->vkCode == VK_SCROLL || p->vkCode == VK_KANA)
DEBUG_KBD("lock keys are processed on client side too to toggle their indicators");
else
return 1;
break;
}
}
@ -163,7 +163,7 @@ void wf_event_focus_in(wfContext* wfc)
rdpInput* input;
POINT pt;
RECT rc;
input = wfc->instance->input;
input = wfc->context.input;
syncFlags = 0;
if (GetKeyState(VK_NUMLOCK))
@ -189,13 +189,13 @@ void wf_event_focus_in(wfContext* wfc)
}
static int wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
WPARAM wParam, LPARAM lParam)
{
int delta;
int flags;
rdpInput* input;
DefWindowProc(hWnd, Msg, wParam, lParam);
input = wfc->instance->input;
input = wfc->context.input;
delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
if (delta > 0)
@ -213,7 +213,7 @@ static int wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg,
static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
{
rdpSettings* settings = wfc->instance->settings;
rdpSettings* settings = wfc->context.settings;
// Holding the CTRL key down while resizing the window will force the desktop aspect ratio.
LPRECT rect;
@ -223,34 +223,34 @@ static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
switch (lParam)
{
case WMSZ_LEFT:
case WMSZ_RIGHT:
case WMSZ_BOTTOMRIGHT:
// Adjust height
rect->bottom = rect->top + settings->DesktopHeight * (rect->right -
rect->left) / settings->DesktopWidth;
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
case WMSZ_BOTTOMRIGHT:
// Adjust height
rect->bottom = rect->top + settings->DesktopHeight * (rect->right -
rect->left) / settings->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;
break;
case WMSZ_TOP:
case WMSZ_BOTTOM:
case WMSZ_TOPRIGHT:
// Adjust width
rect->right = rect->left + settings->DesktopWidth * (rect->bottom - rect->top) /
settings->DesktopHeight;
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_TOPLEFT:
// adjust width
rect->left = rect->right - (settings->DesktopWidth * (rect->bottom -
rect->top) / settings->DesktopHeight);
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_TOPLEFT:
// adjust width
rect->left = rect->right - (settings->DesktopWidth * (rect->bottom -
rect->top) / settings->DesktopHeight);
break;
}
}
}
LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
LPARAM lParam)
LPARAM lParam)
{
HDC hdc;
LONG_PTR ptr;
@ -267,289 +267,289 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
if (wfc != NULL)
{
rdpInput* input = wfc->instance->input;
rdpSettings* settings = wfc->instance->settings;
rdpInput* input = wfc->context.input;
rdpSettings* settings = wfc->context.settings;
switch (Msg)
{
case WM_MOVE:
if (!wfc->disablewindowtracking)
{
int x = (int)(short) LOWORD(lParam);
int y = (int)(short) HIWORD(lParam);
wfc->client_x = x;
wfc->client_y = y;
}
case WM_MOVE:
if (!wfc->disablewindowtracking)
{
int x = (int)(short) LOWORD(lParam);
int y = (int)(short) HIWORD(lParam);
wfc->client_x = x;
wfc->client_y = y;
}
break;
break;
case WM_GETMINMAXINFO:
if (wfc->instance->settings->SmartSizing)
{
processed = FALSE;
}
else
{
// Set maximum window size for resizing
minmax = (MINMAXINFO*) lParam;
case WM_GETMINMAXINFO:
if (wfc->context.settings->SmartSizing)
{
processed = FALSE;
}
else
{
// Set maximum window size for resizing
minmax = (MINMAXINFO*) lParam;
//always use the last determined canvas diff, because it could be
//that the window is minimized when this gets called
//wf_update_canvas_diff(wfc);
if (!wfc->fullscreen)
{
// add window decoration
minmax->ptMaxTrackSize.x = settings->DesktopWidth + wfc->diff.x;
minmax->ptMaxTrackSize.y = settings->DesktopHeight + wfc->diff.y;
}
}
break;
case WM_SIZING:
wf_sizing(wfc, lParam, wParam);
break;
case WM_SIZE:
GetWindowRect(wfc->hwnd, &windowRect);
//always use the last determined canvas diff, because it could be
//that the window is minimized when this gets called
//wf_update_canvas_diff(wfc);
if (!wfc->fullscreen)
{
wfc->client_width = LOWORD(lParam);
wfc->client_height = HIWORD(lParam);
wfc->client_x = windowRect.left;
wfc->client_y = windowRect.top;
// add window decoration
minmax->ptMaxTrackSize.x = settings->DesktopWidth + wfc->diff.x;
minmax->ptMaxTrackSize.y = settings->DesktopHeight + wfc->diff.y;
}
}
if (wfc->client_width && wfc->client_height)
{
wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam));
break;
// Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect.
if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen)
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED);
}
case WM_SIZING:
wf_sizing(wfc, lParam, wParam);
break;
case WM_SIZE:
GetWindowRect(wfc->hwnd, &windowRect);
if (!wfc->fullscreen)
{
wfc->client_width = LOWORD(lParam);
wfc->client_height = HIWORD(lParam);
wfc->client_x = windowRect.left;
wfc->client_y = windowRect.top;
}
if (wfc->client_width && wfc->client_height)
{
wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam));
// Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect.
if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen)
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED);
}
break;
case WM_EXITSIZEMOVE:
wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
break;
case WM_ERASEBKGND:
/* Say we handled it - prevents flickering */
return (LRESULT) 1;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
x = ps.rcPaint.left;
y = ps.rcPaint.top;
w = ps.rcPaint.right - ps.rcPaint.left + 1;
h = ps.rcPaint.bottom - ps.rcPaint.top + 1;
wf_scale_blt(wfc, hdc, x, y, w, h, wfc->primary->hdc,
x - wfc->offset_x + wfc->xCurrentScroll,
y - wfc->offset_y + wfc->yCurrentScroll, SRCCOPY);
EndPaint(hWnd, &ps);
break;
case WM_LBUTTONDOWN:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
case WM_LBUTTONUP:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
case WM_RBUTTONDOWN:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
case WM_RBUTTONUP:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
case WM_MOUSEMOVE:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfc->offset_x,
Y_POS(lParam) - wfc->offset_y);
break;
case WM_MOUSEWHEEL:
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam);
break;
case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT)
SetCursor(wfc->cursor);
else
DefWindowProc(hWnd, Msg, wParam, lParam);
break;
case WM_HSCROLL:
{
int xDelta; // xDelta = new_pos - current_pos
int xNewPos; // new position
int yDelta = 0;
switch (LOWORD(wParam))
{
// User clicked the scroll bar shaft left of the scroll box.
case SB_PAGEUP:
xNewPos = wfc->xCurrentScroll - 50;
break;
case WM_EXITSIZEMOVE:
wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
// User clicked the scroll bar shaft right of the scroll box.
case SB_PAGEDOWN:
xNewPos = wfc->xCurrentScroll + 50;
break;
case WM_ERASEBKGND:
/* Say we handled it - prevents flickering */
return (LRESULT) 1;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
x = ps.rcPaint.left;
y = ps.rcPaint.top;
w = ps.rcPaint.right - ps.rcPaint.left + 1;
h = ps.rcPaint.bottom - ps.rcPaint.top + 1;
wf_scale_blt(wfc, hdc, x, y, w, h, wfc->primary->hdc,
x - wfc->offset_x + wfc->xCurrentScroll,
y - wfc->offset_y + wfc->yCurrentScroll, SRCCOPY);
EndPaint(hWnd, &ps);
// User clicked the left arrow.
case SB_LINEUP:
xNewPos = wfc->xCurrentScroll - 5;
break;
case WM_LBUTTONDOWN:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
// User clicked the right arrow.
case SB_LINEDOWN:
xNewPos = wfc->xCurrentScroll + 5;
break;
case WM_LBUTTONUP:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
// User dragged the scroll box.
case SB_THUMBPOSITION:
xNewPos = HIWORD(wParam);
case WM_RBUTTONDOWN:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
case WM_RBUTTONUP:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2,
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
break;
case WM_MOUSEMOVE:
wf_scale_mouse_event(wfc, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfc->offset_x,
Y_POS(lParam) - wfc->offset_y);
break;
case WM_MOUSEWHEEL:
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam);
break;
case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT)
SetCursor(wfc->cursor);
else
DefWindowProc(hWnd, Msg, wParam, lParam);
break;
case WM_HSCROLL:
{
int xDelta; // xDelta = new_pos - current_pos
int xNewPos; // new position
int yDelta = 0;
switch (LOWORD(wParam))
{
// User clicked the scroll bar shaft left of the scroll box.
case SB_PAGEUP:
xNewPos = wfc->xCurrentScroll - 50;
break;
// User clicked the scroll bar shaft right of the scroll box.
case SB_PAGEDOWN:
xNewPos = wfc->xCurrentScroll + 50;
break;
// User clicked the left arrow.
case SB_LINEUP:
xNewPos = wfc->xCurrentScroll - 5;
break;
// User clicked the right arrow.
case SB_LINEDOWN:
xNewPos = wfc->xCurrentScroll + 5;
break;
// User dragged the scroll box.
case SB_THUMBPOSITION:
xNewPos = HIWORD(wParam);
// user is dragging the scrollbar
case SB_THUMBTRACK :
xNewPos = HIWORD(wParam);
break;
default:
xNewPos = wfc->xCurrentScroll;
}
// New position must be between 0 and the screen width.
xNewPos = MAX(0, xNewPos);
xNewPos = MIN(wfc->xMaxScroll, xNewPos);
// If the current position does not change, do not scroll.
if (xNewPos == wfc->xCurrentScroll)
break;
// Determine the amount scrolled (in pixels).
xDelta = xNewPos - wfc->xCurrentScroll;
// Reset the current scroll position.
wfc->xCurrentScroll = xNewPos;
// Scroll the window. (The system repaints most of the
// client area when ScrollWindowEx is called; however, it is
// necessary to call UpdateWindow in order to repaint the
// rectangle of pixels that were invalidated.)
ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*) NULL,
(CONST RECT*) NULL, (HRGN) NULL, (PRECT) NULL,
SW_INVALIDATE);
UpdateWindow(wfc->hwnd);
// Reset the scroll bar.
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = wfc->xCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
}
break;
case WM_VSCROLL:
{
int xDelta = 0;
int yDelta; // yDelta = new_pos - current_pos
int yNewPos; // new position
switch (LOWORD(wParam))
{
// User clicked the scroll bar shaft above the scroll box.
case SB_PAGEUP:
yNewPos = wfc->yCurrentScroll - 50;
break;
// User clicked the scroll bar shaft below the scroll box.
case SB_PAGEDOWN:
yNewPos = wfc->yCurrentScroll + 50;
break;
// User clicked the top arrow.
case SB_LINEUP:
yNewPos = wfc->yCurrentScroll - 5;
break;
// User clicked the bottom arrow.
case SB_LINEDOWN:
yNewPos = wfc->yCurrentScroll + 5;
break;
// User dragged the scroll box.
case SB_THUMBPOSITION:
yNewPos = HIWORD(wParam);
break;
// user is dragging the scrollbar
case SB_THUMBTRACK :
yNewPos = HIWORD(wParam);
break;
default:
yNewPos = wfc->yCurrentScroll;
}
// New position must be between 0 and the screen height.
yNewPos = MAX(0, yNewPos);
yNewPos = MIN(wfc->yMaxScroll, yNewPos);
// If the current position does not change, do not scroll.
if (yNewPos == wfc->yCurrentScroll)
break;
// Determine the amount scrolled (in pixels).
yDelta = yNewPos - wfc->yCurrentScroll;
// Reset the current scroll position.
wfc->yCurrentScroll = yNewPos;
// Scroll the window. (The system repaints most of the
// client area when ScrollWindowEx is called; however, it is
// necessary to call UpdateWindow in order to repaint the
// rectangle of pixels that were invalidated.)
ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*) NULL,
(CONST RECT*) NULL, (HRGN) NULL, (PRECT) NULL,
SW_INVALIDATE);
UpdateWindow(wfc->hwnd);
// Reset the scroll bar.
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = wfc->yCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
}
break;
case WM_SYSCOMMAND:
{
if (wParam == SYSCOMMAND_ID_SMARTSIZING)
{
HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
freerdp_set_param_bool(wfc->instance->settings, FreeRDP_SmartSizing,
!wfc->instance->settings->SmartSizing);
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING,
wfc->instance->settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
}
else
{
processed = FALSE;
}
}
// user is dragging the scrollbar
case SB_THUMBTRACK :
xNewPos = HIWORD(wParam);
break;
default:
processed = FALSE;
xNewPos = wfc->xCurrentScroll;
}
// New position must be between 0 and the screen width.
xNewPos = MAX(0, xNewPos);
xNewPos = MIN(wfc->xMaxScroll, xNewPos);
// If the current position does not change, do not scroll.
if (xNewPos == wfc->xCurrentScroll)
break;
// Determine the amount scrolled (in pixels).
xDelta = xNewPos - wfc->xCurrentScroll;
// Reset the current scroll position.
wfc->xCurrentScroll = xNewPos;
// Scroll the window. (The system repaints most of the
// client area when ScrollWindowEx is called; however, it is
// necessary to call UpdateWindow in order to repaint the
// rectangle of pixels that were invalidated.)
ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*) NULL,
(CONST RECT*) NULL, (HRGN) NULL, (PRECT) NULL,
SW_INVALIDATE);
UpdateWindow(wfc->hwnd);
// Reset the scroll bar.
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = wfc->xCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
}
break;
case WM_VSCROLL:
{
int xDelta = 0;
int yDelta; // yDelta = new_pos - current_pos
int yNewPos; // new position
switch (LOWORD(wParam))
{
// User clicked the scroll bar shaft above the scroll box.
case SB_PAGEUP:
yNewPos = wfc->yCurrentScroll - 50;
break;
// User clicked the scroll bar shaft below the scroll box.
case SB_PAGEDOWN:
yNewPos = wfc->yCurrentScroll + 50;
break;
// User clicked the top arrow.
case SB_LINEUP:
yNewPos = wfc->yCurrentScroll - 5;
break;
// User clicked the bottom arrow.
case SB_LINEDOWN:
yNewPos = wfc->yCurrentScroll + 5;
break;
// User dragged the scroll box.
case SB_THUMBPOSITION:
yNewPos = HIWORD(wParam);
break;
// user is dragging the scrollbar
case SB_THUMBTRACK :
yNewPos = HIWORD(wParam);
break;
default:
yNewPos = wfc->yCurrentScroll;
}
// New position must be between 0 and the screen height.
yNewPos = MAX(0, yNewPos);
yNewPos = MIN(wfc->yMaxScroll, yNewPos);
// If the current position does not change, do not scroll.
if (yNewPos == wfc->yCurrentScroll)
break;
// Determine the amount scrolled (in pixels).
yDelta = yNewPos - wfc->yCurrentScroll;
// Reset the current scroll position.
wfc->yCurrentScroll = yNewPos;
// Scroll the window. (The system repaints most of the
// client area when ScrollWindowEx is called; however, it is
// necessary to call UpdateWindow in order to repaint the
// rectangle of pixels that were invalidated.)
ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT*) NULL,
(CONST RECT*) NULL, (HRGN) NULL, (PRECT) NULL,
SW_INVALIDATE);
UpdateWindow(wfc->hwnd);
// Reset the scroll bar.
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = wfc->yCurrentScroll;
SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
}
break;
case WM_SYSCOMMAND:
{
if (wParam == SYSCOMMAND_ID_SMARTSIZING)
{
HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
freerdp_set_param_bool(wfc->context.settings, FreeRDP_SmartSizing,
!wfc->context.settings->SmartSizing);
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING,
wfc->context.settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
}
else
{
processed = FALSE;
}
}
break;
default:
processed = FALSE;
break;
}
}
else
@ -562,75 +562,75 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
switch (Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT)
SetCursor(wfc->hDefaultCursor);
case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT)
SetCursor(wfc->hDefaultCursor);
else
DefWindowProc(hWnd, Msg, wParam, lParam);
break;
case WM_SETFOCUS:
DEBUG_KBD("getting focus %X", hWnd);
if (alt_ctrl_down())
g_flipping_in = TRUE;
g_focus_hWnd = hWnd;
freerdp_set_focus(wfc->context.instance);
break;
case WM_KILLFOCUS:
if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen)
{
DEBUG_KBD("loosing focus %X", hWnd);
if (alt_ctrl_down())
g_flipping_out = TRUE;
else
DefWindowProc(hWnd, Msg, wParam, lParam);
g_focus_hWnd = NULL;
}
break;
break;
case WM_SETFOCUS:
DEBUG_KBD("getting focus %X", hWnd);
case WM_ACTIVATE:
{
int activate = (int)(short) LOWORD(wParam);
if (activate != WA_INACTIVE)
{
if (alt_ctrl_down())
g_flipping_in = TRUE;
g_focus_hWnd = hWnd;
freerdp_set_focus(wfc->instance);
break;
}
else
{
if (alt_ctrl_down())
g_flipping_out = TRUE;
else
g_focus_hWnd = NULL;
}
}
case WM_KILLFOCUS:
if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen)
{
DEBUG_KBD("loosing focus %X", hWnd);
if (alt_ctrl_down())
g_flipping_out = TRUE;
else
g_focus_hWnd = NULL;
}
break;
case WM_ACTIVATE:
{
int activate = (int)(short) LOWORD(wParam);
if (activate != WA_INACTIVE)
{
if (alt_ctrl_down())
g_flipping_in = TRUE;
g_focus_hWnd = hWnd;
}
else
{
if (alt_ctrl_down())
g_flipping_out = TRUE;
else
g_focus_hWnd = NULL;
}
}
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
break;
}
return 0;
}
BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
HDC hdcSrc, int x1, int y1, DWORD rop)
HDC hdcSrc, int x1, int y1, DWORD rop)
{
rdpSettings* settings;
UINT32 ww, wh, dw, dh;
settings = wfc->instance->settings;
settings = wfc->context.settings;
if (!wfc->client_width)
wfc->client_width = settings->DesktopWidth;
@ -649,8 +649,8 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
if (!wh)
wh = dh;
if (wfc->fullscreen || !wfc->instance->settings->SmartSizing || (ww == dw
&& wh == dh))
if (wfc->fullscreen || !wfc->context.settings->SmartSizing || (ww == dw
&& wh == dh))
{
return BitBlt(hdc, x, y, w, h, wfc->primary->hdc, x1, y1, SRCCOPY);
}
@ -665,7 +665,7 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
}
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y)
UINT16 x, UINT16 y)
{
int ww, wh, dw, dh;
rdpContext* context;
@ -685,10 +685,10 @@ static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
input->MouseEvent(input, flags, x + wfc->xCurrentScroll,
y + wfc->yCurrentScroll);
y + wfc->yCurrentScroll);
else
input->MouseEvent(input, flags, x * dw / ww + wfc->xCurrentScroll,
y * dh / wh + wfc->yCurrentScroll);
y * dh / wh + wfc->yCurrentScroll);
eventArgs.flags = flags;
eventArgs.x = x;

View File

@ -43,7 +43,7 @@
#define TAG CLIENT_TAG("windows.gdi")
const BYTE wf_rop2_table[] =
static const BYTE wf_rop2_table[] =
{
R2_BLACK, /* 0 */
R2_NOTMERGEPEN, /* DPon */
@ -63,7 +63,13 @@ const BYTE wf_rop2_table[] =
R2_WHITE, /* 1 */
};
BOOL wf_set_rop2(HDC hdc, int rop2)
static BOOL wf_decode_color(wfContext* wfc, const UINT32 srcColor,
UINT32* color, UINT32* format)
{
return gdi_decode_color(wfc->context.gdi, srcColor, color, format);
}
static BOOL wf_set_rop2(HDC hdc, int rop2)
{
if ((rop2 < 0x01) || (rop2 > 0x10))
{
@ -75,20 +81,20 @@ BOOL wf_set_rop2(HDC hdc, int rop2)
return TRUE;
}
wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph)
static wfBitmap* wf_glyph_new(wfContext* wfc, GLYPH_DATA* glyph)
{
wfBitmap* glyph_bmp;
glyph_bmp = wf_image_new(wfc, glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
glyph->aj);
glyph->aj);
return glyph_bmp;
}
void wf_glyph_free(wfBitmap* glyph)
static void wf_glyph_free(wfBitmap* glyph)
{
wf_image_free(glyph);
}
BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data)
static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data)
{
int indexx;
int indexy;
@ -119,7 +125,7 @@ BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data)
}
static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color,
UINT32 bpp)
UINT32 bpp)
{
UINT32 i;
HBRUSH br;
@ -130,7 +136,7 @@ static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color,
lbr.lbStyle = brush->style;
if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8
|| lbr.lbStyle == BS_DIBPATTERNPT)
|| lbr.lbStyle == BS_DIBPATTERNPT)
lbr.lbColor = DIB_RGB_COLORS;
else
lbr.lbColor = color;
@ -177,10 +183,10 @@ static BOOL wf_scale_rect(wfContext* wfc, RECT* source)
UINT32 ww, wh, dw, dh;
rdpSettings* settings;
if (!wfc || !source || !wfc->instance)
if (!wfc || !source || !wfc->context.settings)
return FALSE;
settings = wfc->instance->settings;
settings = wfc->context.settings;
if (!settings)
return FALSE;
@ -203,7 +209,7 @@ static BOOL wf_scale_rect(wfContext* wfc, RECT* source)
if (!wh)
wh = dh;
if (wfc->instance->settings->SmartSizing && (ww != dw || wh != dh))
if (wfc->context.settings->SmartSizing && (ww != dw || wh != dh))
{
source->bottom = source->bottom * wh / dh + 20;
source->top = source->top * wh / dh - 20;
@ -219,7 +225,7 @@ static BOOL wf_scale_rect(wfContext* wfc, RECT* source)
}
void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width,
UINT32 height)
UINT32 height)
{
RECT rect;
rdpGdi* gdi = wfc->context.gdi;
@ -235,17 +241,17 @@ void wf_invalidate_region(wfContext* wfc, UINT32 x, UINT32 y, UINT32 width,
rect.bottom = height;
wf_scale_rect(wfc, &rect);
gdi_InvalidateRegion(gdi->primary->hdc, rect.left, rect.top, rect.right,
rect.bottom);
rect.bottom);
}
void wf_update_offset(wfContext* wfc)
{
rdpSettings* settings;
settings = wfc->instance->settings;
settings = wfc->context.settings;
if (wfc->fullscreen)
{
if (wfc->instance->settings->UseMultimon)
if (wfc->context.settings->UseMultimon)
{
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
@ -284,11 +290,11 @@ void wf_update_offset(wfContext* wfc)
void wf_resize_window(wfContext* wfc)
{
rdpSettings* settings;
settings = wfc->instance->settings;
settings = wfc->context.settings;
if (wfc->fullscreen)
{
if (wfc->instance->settings->UseMultimon)
if (wfc->context.settings->UseMultimon)
{
int x = GetSystemMetrics(SM_XVIRTUALSCREEN);
int y = GetSystemMetrics(SM_YVIRTUALSCREEN);
@ -301,24 +307,24 @@ void wf_resize_window(wfContext* wfc)
{
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_POPUP);
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);
}
}
else if (!wfc->instance->settings->Decorations)
else if (!wfc->context.settings->Decorations)
{
SetWindowLongPtr(wfc->hwnd, GWL_STYLE, WS_CHILD);
/* Now resize to get full canvas size and room for caption and borders */
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, settings->DesktopWidth,
settings->DesktopHeight, SWP_FRAMECHANGED);
settings->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);
settings->DesktopHeight + wfc->diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
}
else
{
SetWindowLongPtr(wfc->hwnd, GWL_STYLE,
WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX |
WS_MAXIMIZEBOX);
WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX |
WS_MAXIMIZEBOX);
if (!wfc->client_height)
wfc->client_height = settings->DesktopHeight;
@ -335,8 +341,8 @@ void wf_resize_window(wfContext* wfc)
wf_update_canvas_diff(wfc);
/* Now resize to get full canvas size and room for caption and borders */
SetWindowPos(wfc->hwnd, HWND_TOP, wfc->client_x, wfc->client_y,
wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y,
0 /*SWP_FRAMECHANGED*/);
wfc->client_width + wfc->diff.x, wfc->client_height + wfc->diff.y,
0 /*SWP_FRAMECHANGED*/);
//wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
}
@ -371,7 +377,7 @@ void wf_toggle_fullscreen(wfContext* wfc)
}
static BOOL wf_gdi_palette_update(rdpContext* context,
const PALETTE_UPDATE* palette)
const PALETTE_UPDATE* palette)
{
return TRUE;
}
@ -400,7 +406,7 @@ static BOOL wf_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds)
if (bounds != NULL)
{
hrgn = CreateRectRgn(bounds->left, bounds->top, bounds->right + 1,
bounds->bottom + 1);
bounds->bottom + 1);
SelectClipRgn(wfc->drawing->hdc, hrgn);
DeleteObject(hrgn);
}
@ -418,11 +424,11 @@ static BOOL wf_gdi_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
return FALSE;
if (!BitBlt(wfc->drawing->hdc, dstblt->nLeftRect, dstblt->nTopRect,
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)))
dstblt->nWidth, dstblt->nHeight, NULL, 0, 0, gdi_rop3_code(dstblt->bRop)))
return FALSE;
wf_invalidate_region(wfc, dstblt->nLeftRect, dstblt->nTopRect,
dstblt->nWidth, dstblt->nHeight);
dstblt->nWidth, dstblt->nHeight);
return TRUE;
}
@ -441,20 +447,20 @@ static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
if (!context || !patblt)
return FALSE;
if (!gdi_decode_color(context->gdi, patblt->foreColor, &fgcolor, NULL))
if (!wf_decode_color(wfc, patblt->foreColor, &fgcolor, NULL))
return FALSE;
if (!gdi_decode_color(context->gdi, patblt->backColor, &bgcolor, NULL))
if (!wf_decode_color(wfc, patblt->backColor, &bgcolor, NULL))
return FALSE;
brush = wf_create_brush(wfc, &patblt->brush, fgcolor,
context->settings->ColorDepth);
context->settings->ColorDepth);
org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);
org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush);
rc = PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));
patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));
SelectObject(wfc->drawing->hdc, org_brush);
DeleteObject(brush);
SetBkMode(wfc->drawing->hdc, org_bkmode);
@ -463,7 +469,7 @@ static BOOL wf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt)
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth,
patblt->nHeight);
patblt->nHeight);
return rc;
}
@ -476,17 +482,17 @@ static BOOL wf_gdi_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
return FALSE;
if (!BitBlt(wfc->drawing->hdc, scrblt->nLeftRect, scrblt->nTopRect,
scrblt->nWidth, scrblt->nHeight, wfc->primary->hdc,
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)))
scrblt->nWidth, scrblt->nHeight, wfc->primary->hdc,
scrblt->nXSrc, scrblt->nYSrc, gdi_rop3_code(scrblt->bRop)))
return FALSE;
wf_invalidate_region(wfc, scrblt->nLeftRect, scrblt->nTopRect,
scrblt->nWidth, scrblt->nHeight);
scrblt->nWidth, scrblt->nHeight);
return TRUE;
}
static BOOL wf_gdi_opaque_rect(rdpContext* context,
const OPAQUE_RECT_ORDER* opaque_rect)
const OPAQUE_RECT_ORDER* opaque_rect)
{
RECT rect;
HBRUSH brush;
@ -496,7 +502,7 @@ static BOOL wf_gdi_opaque_rect(rdpContext* context,
if (!context || !opaque_rect)
return FALSE;
if (!gdi_decode_color(context->gdi, opaque_rect->color, &brush_color, NULL))
if (!wf_decode_color(wfc, opaque_rect->color, &brush_color, NULL))
return FALSE;
rect.left = opaque_rect->nLeftRect;
@ -509,13 +515,13 @@ static BOOL wf_gdi_opaque_rect(rdpContext* context,
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1,
rect.bottom - rect.top + 1);
rect.bottom - rect.top + 1);
return TRUE;
}
static BOOL wf_gdi_multi_opaque_rect(rdpContext* context,
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
UINT32 i;
RECT rect;
@ -526,8 +532,8 @@ static BOOL wf_gdi_multi_opaque_rect(rdpContext* context,
if (!context || !multi_opaque_rect)
return FALSE;
if (!gdi_decode_color(context->gdi, multi_opaque_rect->color, &brush_color,
NULL))
if (!wf_decode_color(wfc, multi_opaque_rect->color, &brush_color,
NULL))
return FALSE;
for (i = 0; i < multi_opaque_rect->numRectangles; i++)
@ -542,7 +548,7 @@ static BOOL wf_gdi_multi_opaque_rect(rdpContext* context,
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, rect.left, rect.top, rect.right - rect.left + 1,
rect.bottom - rect.top + 1);
rect.bottom - rect.top + 1);
DeleteObject(brush);
}
@ -561,7 +567,7 @@ static BOOL wf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
if (!context || !line_to)
return FALSE;
if (!gdi_decode_color(context->gdi, line_to->penColor, &pen_color, NULL))
if (!wf_decode_color(wfc, line_to->penColor, &pen_color, NULL))
return FALSE;
pen = CreatePen(line_to->penStyle, line_to->penWidth, pen_color);
@ -572,9 +578,9 @@ static BOOL wf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
x = (line_to->nXStart < line_to->nXEnd) ? line_to->nXStart : line_to->nXEnd;
y = (line_to->nYStart < line_to->nYEnd) ? line_to->nYStart : line_to->nYEnd;
w = (line_to->nXStart < line_to->nXEnd) ? (line_to->nXEnd - line_to->nXStart)
: (line_to->nXStart - line_to->nXEnd);
: (line_to->nXStart - line_to->nXEnd);
h = (line_to->nYStart < line_to->nYEnd) ? (line_to->nYEnd - line_to->nYStart)
: (line_to->nYStart - line_to->nYEnd);
: (line_to->nYStart - line_to->nYEnd);
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, x, y, w, h);
@ -595,7 +601,7 @@ static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
if (!context || !polyline)
return FALSE;
if (!gdi_decode_color(context->gdi, polyline->penColor, &pen_color, NULL))
if (!wf_decode_color(wfc, polyline->penColor, &pen_color, NULL))
return FALSE;
hpen = CreatePen(0, 1, pen_color);
@ -623,7 +629,7 @@ static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline)
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, wfc->client_x, wfc->client_y, wfc->client_width,
wfc->client_height);
wfc->client_height);
Polyline(wfc->drawing->hdc, pts, numPoints);
free(pts);
@ -649,18 +655,18 @@ static BOOL wf_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
return FALSE;
BitBlt(wfc->drawing->hdc, memblt->nLeftRect, memblt->nTopRect,
memblt->nWidth, memblt->nHeight, bitmap->hdc,
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
memblt->nWidth, memblt->nHeight, bitmap->hdc,
memblt->nXSrc, memblt->nYSrc, gdi_rop3_code(memblt->bRop));
if (wfc->drawing == wfc->primary)
wf_invalidate_region(wfc, memblt->nLeftRect, memblt->nTopRect, memblt->nWidth,
memblt->nHeight);
memblt->nHeight);
return TRUE;
}
static BOOL wf_gdi_surface_frame_marker(rdpContext* context,
const SURFACE_FRAME_MARKER* surface_frame_marker)
const SURFACE_FRAME_MARKER* surface_frame_marker)
{
rdpSettings* settings;
@ -673,10 +679,10 @@ static BOOL wf_gdi_surface_frame_marker(rdpContext* context,
return FALSE;
if (surface_frame_marker->frameAction == SURFACECMD_FRAMEACTION_END
&& settings->FrameAcknowledge > 0)
&& settings->FrameAcknowledge > 0)
{
IFCALL(context->instance->update->SurfaceFrameAcknowledge, context,
surface_frame_marker->frameId);
surface_frame_marker->frameId);
}
return TRUE;

View File

@ -39,7 +39,7 @@ HBITMAP wf_create_dib(wfContext* wfc, UINT32 width, UINT32 height,
HBITMAP bitmap;
BITMAPINFO bmi;
BYTE* cdata = NULL;
UINT32 dstFormat = wfc->format;
UINT32 dstFormat = srcFormat;
/**
* See: http://msdn.microsoft.com/en-us/library/dd183376
* if biHeight is positive, the bitmap is bottom-up

View File

@ -130,7 +130,7 @@ void PrintExtendedWindowStyles(UINT32 style)
if (EXTENDED_WINDOW_STYLES[i].multi)
{
if ((style & EXTENDED_WINDOW_STYLES[i].style) !=
EXTENDED_WINDOW_STYLES[i].style)
EXTENDED_WINDOW_STYLES[i].style)
continue;
}
@ -140,7 +140,7 @@ void PrintExtendedWindowStyles(UINT32 style)
}
void PrintRailWindowState(WINDOW_ORDER_INFO* orderInfo,
WINDOW_STATE_ORDER* windowState)
WINDOW_STATE_ORDER* windowState)
{
if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW)
WLog_INFO(TAG, "WindowCreate: WindowId: 0x%04X", orderInfo->windowId);
@ -157,7 +157,7 @@ void PrintRailWindowState(WINDOW_ORDER_INFO* orderInfo,
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
WLog_INFO(TAG, "\tStyle: 0x%04X ExtendedStyle: 0x%04X",
windowState->style, windowState->extendedStyle);
windowState->style, windowState->extendedStyle);
PrintWindowStyles(windowState->style);
PrintExtendedWindowStyles(windowState->extendedStyle);
}
@ -171,22 +171,22 @@ void PrintRailWindowState(WINDOW_ORDER_INFO* orderInfo,
{
char* title = NULL;
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
windowState->titleInfo.length / 2, &title, 0, NULL, NULL);
windowState->titleInfo.length / 2, &title, 0, NULL, NULL);
WLog_INFO(TAG, "\tTitleInfo: %s (length = %d)", title,
windowState->titleInfo.length);
windowState->titleInfo.length);
free(title);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
{
WLog_INFO(TAG, "\tClientOffsetX: %d ClientOffsetY: %d",
windowState->clientOffsetX, windowState->clientOffsetY);
windowState->clientOffsetX, windowState->clientOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
{
WLog_INFO(TAG, "\tClientAreaWidth: %d ClientAreaHeight: %d",
windowState->clientAreaWidth, windowState->clientAreaHeight);
windowState->clientAreaWidth, windowState->clientAreaHeight);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT)
@ -202,19 +202,19 @@ void PrintRailWindowState(WINDOW_ORDER_INFO* orderInfo,
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
{
WLog_INFO(TAG, "\tWindowOffsetX: %d WindowOffsetY: %d",
windowState->windowOffsetX, windowState->windowOffsetY);
windowState->windowOffsetX, windowState->windowOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
{
WLog_INFO(TAG, "\tWindowClientDeltaX: %d WindowClientDeltaY: %d",
windowState->windowClientDeltaX, windowState->windowClientDeltaY);
windowState->windowClientDeltaX, windowState->windowClientDeltaY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
{
WLog_INFO(TAG, "\tWindowWidth: %d WindowHeight: %d",
windowState->windowWidth, windowState->windowHeight);
windowState->windowWidth, windowState->windowHeight);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
@ -227,14 +227,14 @@ void PrintRailWindowState(WINDOW_ORDER_INFO* orderInfo,
{
rect = &windowState->windowRects[index];
WLog_INFO(TAG, "\twindowRect[%d]: left: %d top: %d right: %d bottom: %d",
index, rect->left, rect->top, rect->right, rect->bottom);
index, rect->left, rect->top, rect->right, rect->bottom);
}
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
{
WLog_INFO(TAG, "\tvisibileOffsetX: %d visibleOffsetY: %d",
windowState->visibleOffsetX, windowState->visibleOffsetY);
windowState->visibleOffsetX, windowState->visibleOffsetY);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
@ -247,7 +247,7 @@ void PrintRailWindowState(WINDOW_ORDER_INFO* orderInfo,
{
rect = &windowState->visibilityRects[index];
WLog_INFO(TAG, "\tvisibilityRect[%d]: left: %d top: %d right: %d bottom: %d",
index, rect->left, rect->top, rect->right, rect->bottom);
index, rect->left, rect->top, rect->right, rect->bottom);
}
}
@ -259,7 +259,7 @@ static void PrintRailIconInfo(WINDOW_ORDER_INFO* orderInfo, ICON_INFO* iconInfo)
WLog_INFO(TAG, "ICON_INFO");
WLog_INFO(TAG, "{");
WLog_INFO(TAG, "\tbigIcon: %s",
(orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_BIG) ? "true" : "false");
(orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_BIG) ? "true" : "false");
WLog_INFO(TAG, "\tcacheEntry; 0x%04X", iconInfo->cacheEntry);
WLog_INFO(TAG, "\tcacheId: 0x%04X", iconInfo->cacheId);
WLog_INFO(TAG, "\tbpp: %d", iconInfo->bpp);
@ -275,7 +275,7 @@ static void PrintRailIconInfo(WINDOW_ORDER_INFO* orderInfo, ICON_INFO* iconInfo)
}
LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam)
LPARAM lParam)
{
HDC hDC;
int x, y;
@ -302,116 +302,116 @@ LRESULT CALLBACK wf_RailWndProc(HWND hWnd, UINT msg, WPARAM wParam,
switch (msg)
{
case WM_PAINT:
{
if (!wfc)
return 0;
case WM_PAINT:
{
if (!wfc)
return 0;
hDC = BeginPaint(hWnd, &ps);
x = ps.rcPaint.left;
y = ps.rcPaint.top;
width = ps.rcPaint.right - ps.rcPaint.left + 1;
height = ps.rcPaint.bottom - ps.rcPaint.top + 1;
BitBlt(hDC, x, y, width, height, wfc->primary->hdc,
railWindow->x + x, railWindow->y + y, SRCCOPY);
EndPaint(hWnd, &ps);
}
break;
hDC = BeginPaint(hWnd, &ps);
x = ps.rcPaint.left;
y = ps.rcPaint.top;
width = ps.rcPaint.right - ps.rcPaint.left + 1;
height = ps.rcPaint.bottom - ps.rcPaint.top + 1;
BitBlt(hDC, x, y, width, height, wfc->primary->hdc,
railWindow->x + x, railWindow->y + y, SRCCOPY);
EndPaint(hWnd, &ps);
}
break;
case WM_LBUTTONDOWN:
{
if (!railWindow || !input)
return 0;
case WM_LBUTTONDOWN:
{
if (!railWindow || !input)
return 0;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
case WM_LBUTTONUP:
{
if (!railWindow || !input)
return 0;
case WM_LBUTTONUP:
{
if (!railWindow || !input)
return 0;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_BUTTON1;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_BUTTON1;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
case WM_RBUTTONDOWN:
{
if (!railWindow || !input)
return 0;
case WM_RBUTTONDOWN:
{
if (!railWindow || !input)
return 0;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
case WM_RBUTTONUP:
{
if (!railWindow || !input)
return 0;
case WM_RBUTTONUP:
{
if (!railWindow || !input)
return 0;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_BUTTON2;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_BUTTON2;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
case WM_MOUSEMOVE:
{
if (!railWindow || !input)
return 0;
case WM_MOUSEMOVE:
{
if (!railWindow || !input)
return 0;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_MOVE;
xPos = GET_X_LPARAM(lParam) + railWindow->x;
yPos = GET_Y_LPARAM(lParam) + railWindow->y;
inputFlags = PTR_FLAGS_MOVE;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
if (input)
input->MouseEvent(input, inputFlags, xPos, yPos);
}
break;
case WM_MOUSEWHEEL:
break;
case WM_MOUSEWHEEL:
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
#define RAIL_DISABLED_WINDOW_STYLES (WS_BORDER | WS_THICKFRAME | WS_DLGFRAME | WS_CAPTION | \
WS_OVERLAPPED | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
WS_OVERLAPPED | WS_VSCROLL | WS_HSCROLL | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#define RAIL_DISABLED_EXTENDED_WINDOW_STYLES (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE)
static BOOL wf_rail_window_common(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState)
WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState)
{
wfRailWindow* railWindow = NULL;
wfContext* wfc = (wfContext*) context;
@ -452,7 +452,7 @@ static BOOL wf_rail_window_common(rdpContext* context,
}
}
else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "failed to convert window title");
/* error handled below */
@ -489,22 +489,22 @@ static BOOL wf_rail_window_common(rdpContext* context,
wndClassEx.hIconSm = NULL;
RegisterClassEx(&wndClassEx);
railWindow->hWnd = CreateWindowExW(
railWindow->dwExStyle, /* dwExStyle */
_T("RdpRailWindow"), /* lpClassName */
titleW, /* lpWindowName */
railWindow->dwStyle, /* dwStyle */
railWindow->x, /* x */
railWindow->y, /* y */
railWindow->width, /* nWidth */
railWindow->height, /* nHeight */
NULL, /* hWndParent */
NULL, /* hMenu */
hInstance, /* hInstance */
NULL /* lpParam */
);
railWindow->dwExStyle, /* dwExStyle */
_T("RdpRailWindow"), /* lpClassName */
titleW, /* lpWindowName */
railWindow->dwStyle, /* dwStyle */
railWindow->x, /* x */
railWindow->y, /* y */
railWindow->width, /* nWidth */
railWindow->height, /* nHeight */
NULL, /* hWndParent */
NULL, /* hMenu */
hInstance, /* hInstance */
NULL /* lpParam */
);
SetWindowLongPtr(railWindow->hWnd, GWLP_USERDATA, (LONG_PTR) railWindow);
HashTable_Add(wfc->railWindows, (void*)(UINT_PTR) orderInfo->windowId,
(void*) railWindow);
(void*) railWindow);
free(titleW);
UpdateWindow(railWindow->hWnd);
return TRUE;
@ -512,14 +512,14 @@ static BOOL wf_rail_window_common(rdpContext* context,
else
{
railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
(void*)(UINT_PTR) orderInfo->windowId);
(void*)(UINT_PTR) orderInfo->windowId);
}
if (!railWindow)
return TRUE;
if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) ||
(fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE))
(fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE))
{
if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
{
@ -534,11 +534,11 @@ static BOOL wf_rail_window_common(rdpContext* context,
}
SetWindowPos(railWindow->hWnd, NULL,
railWindow->x,
railWindow->y,
railWindow->width,
railWindow->height,
0);
railWindow->x,
railWindow->y,
railWindow->width,
railWindow->height,
0);
}
if (fieldFlags & WINDOW_ORDER_FIELD_OWNER)
@ -574,7 +574,7 @@ static BOOL wf_rail_window_common(rdpContext* context,
}
}
else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string,
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1)
{
WLog_ERR(TAG, "failed to convert window title");
return FALSE;
@ -645,14 +645,14 @@ static BOOL wf_rail_window_common(rdpContext* context,
}
static BOOL wf_rail_window_delete(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo)
WINDOW_ORDER_INFO* orderInfo)
{
wfRailWindow* railWindow = NULL;
wfContext* wfc = (wfContext*) context;
RailClientContext* rail = wfc->rail;
WLog_DBG(TAG, "RailWindowDelete");
railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
(void*)(UINT_PTR) orderInfo->windowId);
(void*)(UINT_PTR) orderInfo->windowId);
if (!railWindow)
return TRUE;
@ -664,7 +664,7 @@ static BOOL wf_rail_window_delete(rdpContext* context,
}
static BOOL wf_rail_window_icon(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* windowIcon)
WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* windowIcon)
{
HDC hDC;
int bpp;
@ -681,7 +681,7 @@ static BOOL wf_rail_window_icon(rdpContext* context,
WLog_DBG(TAG, "RailWindowIcon");
PrintRailIconInfo(orderInfo, windowIcon->iconInfo);
railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
(void*)(UINT_PTR) orderInfo->windowId);
(void*)(UINT_PTR) orderInfo->windowId);
if (!railWindow)
return TRUE;
@ -708,13 +708,13 @@ static BOOL wf_rail_window_icon(rdpContext* context,
bitmapInfoHeader->biClrUsed = 0;
bitmapInfoHeader->biClrImportant = 0;
iconInfo.hbmMask = CreateDIBitmap(hDC,
bitmapInfoHeader, CBM_INIT,
windowIcon->iconInfo->bitsMask,
&bitmapInfo, DIB_RGB_COLORS);
bitmapInfoHeader, CBM_INIT,
windowIcon->iconInfo->bitsMask,
&bitmapInfo, DIB_RGB_COLORS);
iconInfo.hbmColor = CreateDIBitmap(hDC,
bitmapInfoHeader, CBM_INIT,
windowIcon->iconInfo->bitsColor,
&bitmapInfo, DIB_RGB_COLORS);
bitmapInfoHeader, CBM_INIT,
windowIcon->iconInfo->bitsColor,
&bitmapInfo, DIB_RGB_COLORS);
hIcon = CreateIconIndirect(&iconInfo);
if (hIcon)
@ -737,14 +737,14 @@ static BOOL wf_rail_window_icon(rdpContext* context,
}
static BOOL wf_rail_window_cached_icon(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* windowCachedIcon)
{
WLog_DBG(TAG, "RailWindowCachedIcon");
return TRUE;
}
static void wf_rail_notify_icon_common(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState)
WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
{
@ -774,7 +774,7 @@ static void wf_rail_notify_icon_common(rdpContext* context,
}
static BOOL wf_rail_notify_icon_create(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState)
WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
wfContext* wfc = (wfContext*) context;
RailClientContext* rail = wfc->rail;
@ -784,7 +784,7 @@ static BOOL wf_rail_notify_icon_create(rdpContext* context,
}
static BOOL wf_rail_notify_icon_update(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState)
WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notifyIconState)
{
wfContext* wfc = (wfContext*) context;
RailClientContext* rail = wfc->rail;
@ -794,7 +794,7 @@ static BOOL wf_rail_notify_icon_update(rdpContext* context,
}
static BOOL wf_rail_notify_icon_delete(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo)
WINDOW_ORDER_INFO* orderInfo)
{
wfContext* wfc = (wfContext*) context;
RailClientContext* rail = wfc->rail;
@ -803,7 +803,7 @@ static BOOL wf_rail_notify_icon_delete(rdpContext* context,
}
static BOOL wf_rail_monitored_desktop(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitoredDesktop)
WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitoredDesktop)
{
wfContext* wfc = (wfContext*) context;
RailClientContext* rail = wfc->rail;
@ -812,7 +812,7 @@ static BOOL wf_rail_monitored_desktop(rdpContext* context,
}
static BOOL wf_rail_non_monitored_desktop(rdpContext* context,
WINDOW_ORDER_INFO* orderInfo)
WINDOW_ORDER_INFO* orderInfo)
{
wfContext* wfc = (wfContext*) context;
RailClientContext* rail = wfc->rail;
@ -843,7 +843,7 @@ void wf_rail_register_update_callbacks(rdpUpdate* update)
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_execute_result(RailClientContext* context,
RAIL_EXEC_RESULT_ORDER* execResult)
RAIL_EXEC_RESULT_ORDER* execResult)
{
WLog_DBG(TAG, "RailServerExecuteResult: 0x%04X", execResult->rawResult);
return CHANNEL_RC_OK;
@ -855,7 +855,7 @@ static UINT wf_rail_server_execute_result(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_system_param(RailClientContext* context,
RAIL_SYSPARAM_ORDER* sysparam)
RAIL_SYSPARAM_ORDER* sysparam)
{
return CHANNEL_RC_OK;
}
@ -866,14 +866,14 @@ static UINT wf_rail_server_system_param(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_handshake(RailClientContext* context,
RAIL_HANDSHAKE_ORDER* handshake)
RAIL_HANDSHAKE_ORDER* handshake)
{
RAIL_EXEC_ORDER exec;
RAIL_SYSPARAM_ORDER sysparam;
RAIL_HANDSHAKE_ORDER clientHandshake;
RAIL_CLIENT_STATUS_ORDER clientStatus;
wfContext* wfc = (wfContext*) context->custom;
rdpSettings* settings = wfc->settings;
rdpSettings* settings = wfc->context.settings;
clientHandshake.buildNumber = 0x00001DB0;
context->ClientHandshake(context, &clientHandshake);
ZeroMemory(&clientStatus, sizeof(RAIL_CLIENT_STATUS_ORDER));
@ -922,7 +922,7 @@ static UINT wf_rail_server_handshake(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_handshake_ex(RailClientContext* context,
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
{
return CHANNEL_RC_OK;
}
@ -933,7 +933,7 @@ static UINT wf_rail_server_handshake_ex(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_local_move_size(RailClientContext* context,
RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
{
return CHANNEL_RC_OK;
}
@ -944,7 +944,7 @@ static UINT wf_rail_server_local_move_size(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_min_max_info(RailClientContext* context,
RAIL_MINMAXINFO_ORDER* minMaxInfo)
RAIL_MINMAXINFO_ORDER* minMaxInfo)
{
return CHANNEL_RC_OK;
}
@ -955,7 +955,7 @@ static UINT wf_rail_server_min_max_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_language_bar_info(RailClientContext* context,
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
{
return CHANNEL_RC_OK;
}
@ -966,7 +966,7 @@ static UINT wf_rail_server_language_bar_info(RailClientContext* context,
* @return 0 on success, otherwise a Win32 error code
*/
static UINT wf_rail_server_get_appid_response(RailClientContext* context,
RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
{
return CHANNEL_RC_OK;
}
@ -987,7 +987,7 @@ void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion)
for (index = 0; index < count; index++)
{
railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows,
(void*) pKeys[index]);
(void*) pKeys[index]);
if (railWindow)
{