2011-09-26 00:30:20 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-09-26 00:30:20 +04:00
|
|
|
* Event Handling
|
|
|
|
*
|
|
|
|
* Copyright 2009-2011 Jay Sorg
|
|
|
|
* Copyright 2010-2011 Vic Lee
|
|
|
|
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:20:53 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-09-26 00:30:20 +04:00
|
|
|
#include <stdio.h>
|
2012-08-15 01:20:53 +04:00
|
|
|
|
2021-06-02 16:16:49 +03:00
|
|
|
#include <winpr/sysinfo.h>
|
2011-09-26 00:30:20 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
2012-08-15 01:20:53 +04:00
|
|
|
|
2014-09-13 00:30:57 +04:00
|
|
|
#include "wf_client.h"
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2012-12-25 08:10:24 +04:00
|
|
|
#include "wf_gdi.h"
|
2011-09-26 00:30:20 +04:00
|
|
|
#include "wf_event.h"
|
2014-09-13 00:30:57 +04:00
|
|
|
|
|
|
|
#include <freerdp/event.h>
|
2011-09-26 00:30:20 +04:00
|
|
|
|
|
|
|
static HWND g_focus_hWnd;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define X_POS(lParam) ((UINT16)(lParam & 0xFFFF))
|
|
|
|
#define Y_POS(lParam) ((UINT16)((lParam >> 16) & 0xFFFF))
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2021-06-02 14:46:00 +03:00
|
|
|
#define RESIZE_MIN_DELAY 200 /* minimum delay in ms between two resizes */
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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);
|
|
|
|
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
2018-03-08 12:58:47 +03:00
|
|
|
#if (_WIN32_WINNT >= 0x0500)
|
|
|
|
static BOOL wf_scale_mouse_event_ex(wfContext* wfc, rdpInput* input, UINT16 flags,
|
|
|
|
UINT16 buttonMask, UINT16 x, UINT16 y);
|
|
|
|
#endif
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2014-03-17 11:01:15 +04:00
|
|
|
static BOOL g_flipping_in;
|
|
|
|
static BOOL g_flipping_out;
|
|
|
|
|
|
|
|
static BOOL alt_ctrl_down()
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
return ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || (GetAsyncKeyState(VK_MENU) & 0x8000));
|
2014-03-17 11:01:15 +04:00
|
|
|
}
|
|
|
|
|
2011-09-26 00:30:20 +04:00
|
|
|
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
wfContext* wfc;
|
2013-03-06 21:50:25 +04:00
|
|
|
DWORD rdp_scancode;
|
2011-09-26 00:30:20 +04:00
|
|
|
rdpInput* input;
|
|
|
|
PKBDLLHOOKSTRUCT p;
|
2019-11-06 17:24:51 +03:00
|
|
|
DEBUG_KBD("Low-level keyboard hook, hWnd %X nCode %X wParam %X", g_focus_hWnd, nCode, wParam);
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2014-03-17 11:01:15 +04:00
|
|
|
if (g_flipping_in)
|
|
|
|
{
|
|
|
|
if (!alt_ctrl_down())
|
|
|
|
g_flipping_in = FALSE;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2014-03-17 11:01:15 +04:00
|
|
|
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2011-09-26 00:30:20 +04:00
|
|
|
if (g_focus_hWnd && (nCode == HC_ACTION))
|
|
|
|
{
|
|
|
|
switch (wParam)
|
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
2019-11-06 17:24:51 +03:00
|
|
|
wfc = (wfContext*)GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
|
|
|
|
p = (PKBDLLHOOKSTRUCT)lParam;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
|
|
|
if (!wfc || !p)
|
2016-08-03 13:37:40 +03:00
|
|
|
return 1;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
input = wfc->context.input;
|
2019-11-06 17:24:51 +03:00
|
|
|
rdp_scancode = MAKE_RDP_SCANCODE((BYTE)p->scanCode, p->flags & LLKHF_EXTENDED);
|
2016-12-14 00:47:08 +03:00
|
|
|
DEBUG_KBD("keydown %d scanCode 0x%08lX flags 0x%08lX vkCode 0x%08lX",
|
|
|
|
(wParam == WM_KEYDOWN), p->scanCode, p->flags, p->vkCode);
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2016-06-22 21:58:39 +03:00
|
|
|
if (wfc->fullscreen_toggle &&
|
2016-10-04 10:00:00 +03:00
|
|
|
((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
|
|
|
|
(GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
|
|
|
|
(GetAsyncKeyState(VK_MENU) & 0x8000)) /* could also use flags & LLKHF_ALTDOWN */
|
2016-08-03 13:37:40 +03:00
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
if (wParam == WM_KEYDOWN)
|
|
|
|
{
|
|
|
|
wf_toggle_fullscreen(wfc);
|
|
|
|
return 1;
|
|
|
|
}
|
2012-03-29 03:12:48 +04:00
|
|
|
}
|
2016-10-04 10:00:00 +03:00
|
|
|
|
|
|
|
if (rdp_scancode == RDP_SCANCODE_NUMLOCK_EXTENDED)
|
2011-09-26 00:30:20 +04:00
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
/* Windows sends NumLock as extended - rdp doesn't */
|
|
|
|
DEBUG_KBD("hack: NumLock (x45) should not be extended");
|
|
|
|
rdp_scancode = RDP_SCANCODE_NUMLOCK;
|
2011-09-26 00:30:20 +04:00
|
|
|
}
|
2016-10-04 10:00:00 +03:00
|
|
|
else if (rdp_scancode == RDP_SCANCODE_NUMLOCK)
|
|
|
|
{
|
|
|
|
/* Windows sends Pause as if it was a RDP NumLock (handled above).
|
2019-11-06 17:24:51 +03:00
|
|
|
* It must however be sent as a one-shot Ctrl+NumLock */
|
2016-10-04 10:00:00 +03:00
|
|
|
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");
|
|
|
|
}
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (rdp_scancode == RDP_SCANCODE_RSHIFT_EXTENDED)
|
|
|
|
{
|
|
|
|
DEBUG_KBD("right shift (x36) should not be extended");
|
|
|
|
rdp_scancode = RDP_SCANCODE_RSHIFT;
|
|
|
|
}
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
freerdp_input_send_keyboard_event_ex(input, !(p->flags & LLKHF_UP), rdp_scancode);
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
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");
|
2016-10-04 10:00:00 +03:00
|
|
|
else
|
|
|
|
return 1;
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 11:01:15 +04:00
|
|
|
if (g_flipping_out)
|
|
|
|
{
|
|
|
|
if (!alt_ctrl_down())
|
|
|
|
{
|
|
|
|
g_flipping_out = FALSE;
|
|
|
|
g_focus_hWnd = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-26 00:30:20 +04:00
|
|
|
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2014-10-03 18:27:47 +04:00
|
|
|
void wf_event_focus_in(wfContext* wfc)
|
|
|
|
{
|
|
|
|
UINT16 syncFlags;
|
|
|
|
rdpInput* input;
|
2015-01-16 20:40:57 +03:00
|
|
|
POINT pt;
|
|
|
|
RECT rc;
|
2016-08-03 13:37:40 +03:00
|
|
|
input = wfc->context.input;
|
2014-10-03 18:27:47 +04:00
|
|
|
syncFlags = 0;
|
|
|
|
|
|
|
|
if (GetKeyState(VK_NUMLOCK))
|
|
|
|
syncFlags |= KBD_SYNC_NUM_LOCK;
|
|
|
|
|
|
|
|
if (GetKeyState(VK_CAPITAL))
|
|
|
|
syncFlags |= KBD_SYNC_CAPS_LOCK;
|
|
|
|
|
|
|
|
if (GetKeyState(VK_SCROLL))
|
|
|
|
syncFlags |= KBD_SYNC_SCROLL_LOCK;
|
|
|
|
|
|
|
|
if (GetKeyState(VK_KANA))
|
|
|
|
syncFlags |= KBD_SYNC_KANA_LOCK;
|
|
|
|
|
2015-01-16 20:40:57 +03:00
|
|
|
input->FocusInEvent(input, syncFlags);
|
|
|
|
/* send pointer position if the cursor is currently inside our client area */
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
ScreenToClient(wfc->hwnd, &pt);
|
|
|
|
GetClientRect(wfc->hwnd, &rc);
|
|
|
|
|
|
|
|
if (pt.x >= rc.left && pt.x < rc.right && pt.y >= rc.top && pt.y < rc.bottom)
|
|
|
|
input->MouseEvent(input, PTR_FLAGS_MOVE, (UINT16)pt.x, (UINT16)pt.y);
|
2014-10-03 18:27:47 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg, WPARAM wParam,
|
|
|
|
LPARAM lParam, BOOL horizontal, UINT16 x, UINT16 y)
|
2012-10-16 20:57:12 +04:00
|
|
|
{
|
|
|
|
int delta;
|
2018-03-08 12:58:47 +03:00
|
|
|
UINT16 flags = 0;
|
2012-10-16 20:57:12 +04:00
|
|
|
rdpInput* input;
|
|
|
|
DefWindowProc(hWnd, Msg, wParam, lParam);
|
2016-08-03 13:37:40 +03:00
|
|
|
input = wfc->context.input;
|
2019-11-06 17:24:51 +03:00
|
|
|
delta = ((signed short)HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
|
2012-10-17 15:48:24 +04:00
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
if (horizontal)
|
|
|
|
flags |= PTR_FLAGS_HWHEEL;
|
2012-10-16 20:57:12 +04:00
|
|
|
else
|
2018-03-08 12:58:47 +03:00
|
|
|
flags |= PTR_FLAGS_WHEEL;
|
|
|
|
|
|
|
|
if (delta < 0)
|
2012-10-16 20:57:12 +04:00
|
|
|
{
|
2018-03-08 12:58:47 +03:00
|
|
|
flags |= PTR_FLAGS_WHEEL_NEGATIVE;
|
2021-02-10 20:50:51 +03:00
|
|
|
/* 9bit twos complement, delta already negative */
|
|
|
|
delta = 0x100 + delta;
|
2012-10-16 20:57:12 +04:00
|
|
|
}
|
2012-10-17 15:48:24 +04:00
|
|
|
|
2018-11-16 12:33:29 +03:00
|
|
|
flags |= delta;
|
2018-03-08 12:58:47 +03:00
|
|
|
return wf_scale_mouse_event(wfc, input, flags, x, y);
|
2012-10-16 20:57:12 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:36:15 +03:00
|
|
|
static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
|
2013-04-26 23:46:36 +04:00
|
|
|
{
|
2016-08-03 13:37:40 +03:00
|
|
|
rdpSettings* settings = wfc->context.settings;
|
2013-04-26 23:46:36 +04:00
|
|
|
// Holding the CTRL key down while resizing the window will force the desktop aspect ratio.
|
|
|
|
LPRECT rect;
|
2013-06-16 06:57:21 +04:00
|
|
|
|
2021-06-02 14:46:00 +03:00
|
|
|
if ((settings->SmartSizing || settings->DynamicResolutionUpdate) &&
|
|
|
|
(GetAsyncKeyState(VK_CONTROL) & 0x8000))
|
2013-04-26 23:46:36 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
rect = (LPRECT)wParam;
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
switch (lParam)
|
2013-04-26 23:46:36 +04:00
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
case WMSZ_LEFT:
|
|
|
|
case WMSZ_RIGHT:
|
|
|
|
case WMSZ_BOTTOMRIGHT:
|
|
|
|
// Adjust height
|
2019-11-06 17:24:51 +03:00
|
|
|
rect->bottom = rect->top + settings->DesktopHeight * (rect->right - rect->left) /
|
|
|
|
settings->DesktopWidth;
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WMSZ_TOP:
|
|
|
|
case WMSZ_BOTTOM:
|
|
|
|
case WMSZ_TOPRIGHT:
|
|
|
|
// Adjust width
|
|
|
|
rect->right = rect->left + settings->DesktopWidth * (rect->bottom - rect->top) /
|
2019-11-06 17:24:51 +03:00
|
|
|
settings->DesktopHeight;
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WMSZ_BOTTOMLEFT:
|
|
|
|
case WMSZ_TOPLEFT:
|
|
|
|
// adjust width
|
2019-11-06 17:24:51 +03:00
|
|
|
rect->left = rect->right - (settings->DesktopWidth * (rect->bottom - rect->top) /
|
|
|
|
settings->DesktopHeight);
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2013-04-26 23:46:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-02 16:16:49 +03:00
|
|
|
static void wf_send_resize(wfContext* wfc)
|
2021-06-02 14:46:00 +03:00
|
|
|
{
|
|
|
|
RECT windowRect;
|
|
|
|
int targetWidth = wfc->client_width;
|
|
|
|
int targetHeight = wfc->client_height;
|
|
|
|
rdpSettings* settings = wfc->context.settings;
|
|
|
|
|
|
|
|
if (settings->DynamicResolutionUpdate && wfc->disp != NULL)
|
|
|
|
{
|
2021-06-02 14:50:23 +03:00
|
|
|
if (GetTickCount64() - wfc->lastSentDate > RESIZE_MIN_DELAY)
|
2021-06-02 14:46:00 +03:00
|
|
|
{
|
|
|
|
if (wfc->fullscreen)
|
|
|
|
{
|
|
|
|
GetWindowRect(wfc->hwnd, &windowRect);
|
|
|
|
targetWidth = windowRect.right - windowRect.left;
|
|
|
|
targetHeight = windowRect.bottom - windowRect.top;
|
|
|
|
}
|
|
|
|
if (settings->SmartSizingWidth != targetWidth ||
|
|
|
|
settings->SmartSizingHeight != targetHeight)
|
|
|
|
{
|
2021-06-02 16:36:43 +03:00
|
|
|
DISPLAY_CONTROL_MONITOR_LAYOUT layout = { 0 };
|
|
|
|
|
|
|
|
layout.Flags = DISPLAY_CONTROL_MONITOR_PRIMARY;
|
|
|
|
layout.Top = layout.Left = 0;
|
|
|
|
layout.Width = targetWidth;
|
|
|
|
layout.Height = targetHeight;
|
|
|
|
layout.Orientation = settings->DesktopOrientation;
|
|
|
|
layout.DesktopScaleFactor = settings->DesktopScaleFactor;
|
|
|
|
layout.DeviceScaleFactor = settings->DeviceScaleFactor;
|
|
|
|
layout.PhysicalWidth = targetWidth;
|
|
|
|
layout.PhysicalHeight = targetHeight;
|
|
|
|
|
2021-06-02 14:46:00 +03:00
|
|
|
if (IFCALLRESULT(CHANNEL_RC_OK, wfc->disp->SendMonitorLayout, wfc->disp, 1,
|
2021-06-02 16:36:43 +03:00
|
|
|
&layout) != CHANNEL_RC_OK)
|
2021-06-02 14:46:00 +03:00
|
|
|
{
|
|
|
|
WLog_ERR("", "SendMonitorLayout failed.");
|
|
|
|
}
|
|
|
|
settings->SmartSizingWidth = targetWidth;
|
|
|
|
settings->SmartSizingHeight = targetHeight;
|
|
|
|
}
|
2021-06-02 14:50:23 +03:00
|
|
|
wfc->lastSentDate = GetTickCount64();
|
2021-06-02 14:46:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
2011-09-26 00:30:20 +04:00
|
|
|
{
|
|
|
|
HDC hdc;
|
2014-02-10 09:34:17 +04:00
|
|
|
LONG_PTR ptr;
|
2013-06-16 06:57:21 +04:00
|
|
|
wfContext* wfc;
|
2011-10-07 22:55:07 +04:00
|
|
|
int x, y, w, h;
|
2016-08-03 13:09:24 +03:00
|
|
|
PAINTSTRUCT ps;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL processed;
|
2013-06-16 06:57:21 +04:00
|
|
|
RECT windowRect;
|
|
|
|
MINMAXINFO* minmax;
|
2013-04-26 23:46:36 +04:00
|
|
|
SCROLLINFO si;
|
2012-10-09 10:31:28 +04:00
|
|
|
processed = TRUE;
|
2011-09-26 00:30:20 +04:00
|
|
|
ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
2019-11-06 17:24:51 +03:00
|
|
|
wfc = (wfContext*)ptr;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (wfc != NULL)
|
2011-09-26 00:30:20 +04:00
|
|
|
{
|
2016-08-03 13:37:40 +03:00
|
|
|
rdpInput* input = wfc->context.input;
|
|
|
|
rdpSettings* settings = wfc->context.settings;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2011-09-26 01:47:40 +04:00
|
|
|
switch (Msg)
|
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_MOVE:
|
|
|
|
if (!wfc->disablewindowtracking)
|
2013-04-25 23:42:40 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
int x = (int)(short)LOWORD(lParam);
|
|
|
|
int y = (int)(short)HIWORD(lParam);
|
2016-10-04 10:00:00 +03:00
|
|
|
wfc->client_x = x;
|
|
|
|
wfc->client_y = y;
|
2013-04-25 23:42:40 +04:00
|
|
|
}
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_GETMINMAXINFO:
|
2021-06-02 14:46:00 +03:00
|
|
|
if (wfc->context.settings->SmartSizing ||
|
|
|
|
wfc->context.settings->DynamicResolutionUpdate)
|
2016-10-04 10:00:00 +03:00
|
|
|
{
|
|
|
|
processed = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Set maximum window size for resizing
|
2019-11-06 17:24:51 +03:00
|
|
|
minmax = (MINMAXINFO*)lParam;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// 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);
|
2016-10-04 10:00:00 +03:00
|
|
|
|
|
|
|
if (!wfc->fullscreen)
|
|
|
|
{
|
|
|
|
// add window decoration
|
|
|
|
minmax->ptMaxTrackSize.x = settings->DesktopWidth + wfc->diff.x;
|
|
|
|
minmax->ptMaxTrackSize.y = settings->DesktopHeight + wfc->diff.y;
|
|
|
|
}
|
|
|
|
}
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_SIZING:
|
|
|
|
wf_sizing(wfc, lParam, wParam);
|
|
|
|
break;
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_SIZE:
|
|
|
|
GetWindowRect(wfc->hwnd, &windowRect);
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
if (!wfc->fullscreen)
|
|
|
|
{
|
|
|
|
wfc->client_width = LOWORD(lParam);
|
|
|
|
wfc->client_height = HIWORD(lParam);
|
|
|
|
wfc->client_x = windowRect.left;
|
|
|
|
wfc->client_y = windowRect.top;
|
|
|
|
}
|
2021-06-02 14:46:00 +03:00
|
|
|
else
|
|
|
|
{
|
2021-06-02 14:50:23 +03:00
|
|
|
wfc->wasMaximized = TRUE;
|
2021-06-02 14:46:00 +03:00
|
|
|
wf_send_resize(wfc);
|
|
|
|
}
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
if (wfc->client_width && wfc->client_height)
|
|
|
|
{
|
|
|
|
wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam));
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// Workaround: when the window is maximized, the call to "ShowScrollBars"
|
|
|
|
// returns TRUE but has no effect.
|
2016-10-04 10:00:00 +03:00
|
|
|
if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen)
|
2021-06-02 14:46:00 +03:00
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left,
|
2019-11-06 17:24:51 +03:00
|
|
|
windowRect.bottom - windowRect.top,
|
|
|
|
SWP_NOMOVE | SWP_FRAMECHANGED);
|
2021-06-02 14:50:23 +03:00
|
|
|
wfc->wasMaximized = TRUE;
|
2021-06-02 14:46:00 +03:00
|
|
|
wf_send_resize(wfc);
|
|
|
|
}
|
2021-06-02 14:50:23 +03:00
|
|
|
else if (wParam == SIZE_RESTORED && !wfc->fullscreen && wfc->wasMaximized)
|
2021-06-02 14:46:00 +03:00
|
|
|
{
|
2021-06-02 14:50:23 +03:00
|
|
|
wfc->wasMaximized = FALSE;
|
2021-06-02 14:46:00 +03:00
|
|
|
wf_send_resize(wfc);
|
|
|
|
}
|
2016-10-04 10:00:00 +03:00
|
|
|
}
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_EXITSIZEMOVE:
|
|
|
|
wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
|
2021-06-02 14:46:00 +03:00
|
|
|
wf_send_resize(wfc);
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
/* Say we handled it - prevents flickering */
|
2019-11-06 17:24:51 +03:00
|
|
|
return (LRESULT)1;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
|
|
|
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);
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2018-03-08 12:58:47 +03:00
|
|
|
#if (_WIN32_WINNT >= 0x0500)
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
case WM_XBUTTONDOWN:
|
|
|
|
wf_scale_mouse_event_ex(wfc, input, PTR_XFLAGS_DOWN, GET_XBUTTON_WPARAM(wParam),
|
2019-11-06 17:24:51 +03:00
|
|
|
X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2018-03-08 12:58:47 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_XBUTTONUP:
|
|
|
|
wf_scale_mouse_event_ex(wfc, input, 0, GET_XBUTTON_WPARAM(wParam),
|
2019-11-06 17:24:51 +03:00
|
|
|
X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2018-03-08 12:58:47 +03:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3,
|
|
|
|
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONUP:
|
2019-11-06 17:24:51 +03:00
|
|
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON3, X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2018-03-08 12:58:47 +03:00
|
|
|
break;
|
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
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);
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_LBUTTONUP:
|
2019-11-06 17:24:51 +03:00
|
|
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
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);
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2012-10-16 22:20:04 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_RBUTTONUP:
|
2019-11-06 17:24:51 +03:00
|
|
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2012-10-16 20:57:12 +04:00
|
|
|
break;
|
2011-09-26 01:47:40 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2016-08-03 13:37:40 +03:00
|
|
|
break;
|
2018-03-08 12:58:47 +03:00
|
|
|
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_MOUSEWHEEL:
|
2018-03-08 12:58:47 +03:00
|
|
|
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam, FALSE,
|
2018-11-16 12:33:29 +03:00
|
|
|
X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2011-09-26 01:47:40 +04:00
|
|
|
break;
|
2018-03-08 12:58:47 +03:00
|
|
|
#endif
|
|
|
|
#if (_WIN32_WINNT >= 0x0600)
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
case WM_MOUSEHWHEEL:
|
|
|
|
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam, TRUE,
|
2018-11-16 12:33:29 +03:00
|
|
|
X_POS(lParam) - wfc->offset_x,
|
|
|
|
Y_POS(lParam) - wfc->offset_y);
|
2018-03-08 12:58:47 +03:00
|
|
|
break;
|
|
|
|
#endif
|
2011-09-26 01:47:40 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_SETCURSOR:
|
|
|
|
if (LOWORD(lParam) == HTCLIENT)
|
|
|
|
SetCursor(wfc->cursor);
|
|
|
|
else
|
|
|
|
DefWindowProc(hWnd, Msg, wParam, lParam);
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
break;
|
2013-04-26 23:46:36 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_HSCROLL:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
int xDelta; // xDelta = new_pos - current_pos
|
|
|
|
int xNewPos; // new position
|
|
|
|
int yDelta = 0;
|
|
|
|
|
|
|
|
switch (LOWORD(wParam))
|
2016-10-04 10:00:00 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
// User clicked the scroll bar shaft left of the scroll box.
|
|
|
|
case SB_PAGEUP:
|
|
|
|
xNewPos = wfc->xCurrentScroll - 50;
|
|
|
|
break;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// 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;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// User dragged the scroll box.
|
|
|
|
case SB_THUMBPOSITION:
|
|
|
|
xNewPos = HIWORD(wParam);
|
|
|
|
break;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// user is dragging the scrollbar
|
|
|
|
case SB_THUMBTRACK:
|
|
|
|
xNewPos = HIWORD(wParam);
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
default:
|
|
|
|
xNewPos = wfc->xCurrentScroll;
|
2016-10-04 10:00:00 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
|
|
|
// 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;
|
2013-04-30 19:15:04 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_VSCROLL:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
int xDelta = 0;
|
|
|
|
int yDelta; // yDelta = new_pos - current_pos
|
|
|
|
int yNewPos; // new position
|
|
|
|
|
|
|
|
switch (LOWORD(wParam))
|
2016-10-04 10:00:00 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
// User clicked the scroll bar shaft above the scroll box.
|
|
|
|
case SB_PAGEUP:
|
|
|
|
yNewPos = wfc->yCurrentScroll - 50;
|
|
|
|
break;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// 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;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// 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;
|
2016-10-04 10:00:00 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// user is dragging the scrollbar
|
|
|
|
case SB_THUMBTRACK:
|
|
|
|
yNewPos = HIWORD(wParam);
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
default:
|
|
|
|
yNewPos = wfc->yCurrentScroll;
|
2016-10-04 10:00:00 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
|
|
|
|
// 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;
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_SYSCOMMAND:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
if (wParam == SYSCOMMAND_ID_SMARTSIZING)
|
2016-10-04 10:00:00 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
|
2021-06-16 15:50:14 +03:00
|
|
|
freerdp_settings_set_bool(wfc->context.settings, FreeRDP_SmartSizing,
|
|
|
|
!wfc->context.settings->SmartSizing);
|
2019-11-06 17:24:51 +03:00
|
|
|
CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING,
|
|
|
|
wfc->context.settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);
|
2016-10-04 10:00:00 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
processed = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-08-03 13:37:40 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
default:
|
2016-08-03 13:37:40 +03:00
|
|
|
processed = FALSE;
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2011-09-26 01:47:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-09 10:31:28 +04:00
|
|
|
processed = FALSE;
|
2011-09-26 01:47:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (processed)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (Msg)
|
|
|
|
{
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_DESTROY:
|
|
|
|
PostQuitMessage(WM_QUIT);
|
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_SETFOCUS:
|
|
|
|
DEBUG_KBD("getting focus %X", hWnd);
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
if (alt_ctrl_down())
|
|
|
|
g_flipping_in = TRUE;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
g_focus_hWnd = hWnd;
|
|
|
|
freerdp_set_focus(wfc->context.instance);
|
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_KILLFOCUS:
|
|
|
|
if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen)
|
|
|
|
{
|
|
|
|
DEBUG_KBD("loosing focus %X", hWnd);
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
if (alt_ctrl_down())
|
|
|
|
g_flipping_out = TRUE;
|
|
|
|
else
|
|
|
|
g_focus_hWnd = NULL;
|
|
|
|
}
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
case WM_ACTIVATE:
|
2019-11-06 17:24:51 +03:00
|
|
|
{
|
|
|
|
int activate = (int)(short)LOWORD(wParam);
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (activate != WA_INACTIVE)
|
|
|
|
{
|
|
|
|
if (alt_ctrl_down())
|
|
|
|
g_flipping_in = TRUE;
|
2016-08-03 13:09:24 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
g_focus_hWnd = hWnd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (alt_ctrl_down())
|
|
|
|
g_flipping_out = TRUE;
|
2016-10-04 10:00:00 +03:00
|
|
|
else
|
2019-11-06 17:24:51 +03:00
|
|
|
g_focus_hWnd = NULL;
|
2016-10-04 10:00:00 +03:00
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
}
|
2013-05-31 22:20:43 +04:00
|
|
|
|
2016-10-04 10:00:00 +03:00
|
|
|
default:
|
|
|
|
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
|
|
|
break;
|
2011-09-26 00:30:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1,
|
|
|
|
DWORD rop)
|
2013-04-11 00:58:14 +04:00
|
|
|
{
|
2016-08-03 13:09:24 +03:00
|
|
|
rdpSettings* settings;
|
|
|
|
UINT32 ww, wh, dw, dh;
|
2016-08-03 13:37:40 +03:00
|
|
|
settings = wfc->context.settings;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_width)
|
2016-08-03 13:09:24 +03:00
|
|
|
wfc->client_width = settings->DesktopWidth;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_height)
|
2016-08-03 13:09:24 +03:00
|
|
|
wfc->client_height = settings->DesktopHeight;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
ww = wfc->client_width;
|
|
|
|
wh = wfc->client_height;
|
2016-08-03 13:09:24 +03:00
|
|
|
dw = settings->DesktopWidth;
|
|
|
|
dh = settings->DesktopHeight;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
|
|
|
if (!ww)
|
|
|
|
ww = dw;
|
|
|
|
|
|
|
|
if (!wh)
|
|
|
|
wh = dh;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (wfc->fullscreen || !wfc->context.settings->SmartSizing || (ww == dw && wh == dh))
|
2013-04-11 00:58:14 +04:00
|
|
|
{
|
2013-06-16 06:57:21 +04:00
|
|
|
return BitBlt(hdc, x, y, w, h, wfc->primary->hdc, x1, y1, SRCCOPY);
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetStretchBltMode(hdc, HALFTONE);
|
|
|
|
SetBrushOrgEx(hdc, 0, 0, NULL);
|
2013-06-16 06:57:21 +04:00
|
|
|
return StretchBlt(hdc, 0, 0, ww, wh, wfc->primary->hdc, 0, 0, dw, dh, SRCCOPY);
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
static BOOL wf_scale_mouse_pos(wfContext* wfc, UINT16* x, UINT16* y)
|
2013-04-11 00:58:14 +04:00
|
|
|
{
|
|
|
|
int ww, wh, dw, dh;
|
2014-01-18 03:17:10 +04:00
|
|
|
rdpContext* context;
|
2018-03-08 12:58:47 +03:00
|
|
|
rdpSettings* settings;
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
if (!wfc || !x || !y)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
settings = wfc->context.settings;
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
if (!settings)
|
|
|
|
return FALSE;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_width)
|
2016-08-03 13:09:24 +03:00
|
|
|
wfc->client_width = settings->DesktopWidth;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
if (!wfc->client_height)
|
2016-08-03 13:09:24 +03:00
|
|
|
wfc->client_height = settings->DesktopHeight;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2013-06-16 06:57:21 +04:00
|
|
|
ww = wfc->client_width;
|
|
|
|
wh = wfc->client_height;
|
2016-08-03 13:09:24 +03:00
|
|
|
dw = settings->DesktopWidth;
|
|
|
|
dh = settings->DesktopHeight;
|
2013-04-11 00:58:14 +04:00
|
|
|
|
2016-08-03 13:09:24 +03:00
|
|
|
if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
2018-03-08 12:58:47 +03:00
|
|
|
{
|
|
|
|
*x += wfc->xCurrentScroll;
|
|
|
|
*y += wfc->yCurrentScroll;
|
|
|
|
}
|
2013-04-11 00:58:14 +04:00
|
|
|
else
|
2018-03-08 12:58:47 +03:00
|
|
|
{
|
|
|
|
*x = *x * dw / ww + wfc->xCurrentScroll;
|
|
|
|
*y = *y * dh / wh + wfc->yCurrentScroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
2018-03-08 12:58:47 +03:00
|
|
|
{
|
|
|
|
MouseEventEventArgs eventArgs;
|
|
|
|
|
|
|
|
if (!wf_scale_mouse_pos(wfc, &x, &y))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (freerdp_input_send_mouse_event(input, flags, x, y))
|
|
|
|
return FALSE;
|
2014-01-18 03:17:10 +04:00
|
|
|
|
|
|
|
eventArgs.flags = flags;
|
|
|
|
eventArgs.x = x;
|
|
|
|
eventArgs.y = y;
|
2018-03-08 12:58:47 +03:00
|
|
|
PubSub_OnMouseEvent(wfc->context.pubSub, &wfc->context, &eventArgs);
|
2016-08-03 13:09:24 +03:00
|
|
|
return TRUE;
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
2018-03-08 12:58:47 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#if (_WIN32_WINNT >= 0x0500)
|
2018-11-16 12:33:29 +03:00
|
|
|
static BOOL wf_scale_mouse_event_ex(wfContext* wfc, rdpInput* input, UINT16 flags,
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT16 buttonMask, UINT16 x, UINT16 y)
|
2018-03-08 12:58:47 +03:00
|
|
|
{
|
|
|
|
MouseEventExEventArgs eventArgs;
|
|
|
|
|
|
|
|
if (buttonMask & XBUTTON1)
|
|
|
|
flags |= PTR_XFLAGS_BUTTON1;
|
2018-11-16 12:33:29 +03:00
|
|
|
|
2018-03-08 12:58:47 +03:00
|
|
|
if (buttonMask & XBUTTON2)
|
|
|
|
flags |= PTR_XFLAGS_BUTTON2;
|
|
|
|
|
|
|
|
if (!wf_scale_mouse_pos(wfc, &x, &y))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (freerdp_input_send_extended_mouse_event(input, flags, x, y))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
eventArgs.flags = flags;
|
|
|
|
eventArgs.x = x;
|
|
|
|
eventArgs.y = y;
|
|
|
|
PubSub_OnMouseEventEx(wfc->context.pubSub, &wfc->context, &eventArgs);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|