Merge pull request #4472 from akallabeth/win_mouse_button
[WIN] Added additional mouse mappings.
This commit is contained in:
commit
1a8234c74d
@ -43,6 +43,10 @@ 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,
|
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
||||||
UINT16 x, UINT16 y);
|
UINT16 x, UINT16 y);
|
||||||
|
#if (_WIN32_WINNT >= 0x0500)
|
||||||
|
static BOOL wf_scale_mouse_event_ex(wfContext* wfc, rdpInput* input, UINT16 flags,
|
||||||
|
UINT16 buttonMask, UINT16 x, UINT16 y);
|
||||||
|
#endif
|
||||||
|
|
||||||
static BOOL g_flipping_in;
|
static BOOL g_flipping_in;
|
||||||
static BOOL g_flipping_out;
|
static BOOL g_flipping_out;
|
||||||
@ -188,27 +192,29 @@ void wf_event_focus_in(wfContext* wfc)
|
|||||||
input->MouseEvent(input, PTR_FLAGS_MOVE, (UINT16)pt.x, (UINT16)pt.y);
|
input->MouseEvent(input, PTR_FLAGS_MOVE, (UINT16)pt.x, (UINT16)pt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg,
|
static BOOL wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam, BOOL horizontal, UINT16 x, UINT16 y)
|
||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
int flags;
|
UINT16 flags = 0;
|
||||||
rdpInput* input;
|
rdpInput* input;
|
||||||
DefWindowProc(hWnd, Msg, wParam, lParam);
|
DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||||
input = wfc->context.input;
|
input = wfc->context.input;
|
||||||
delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
|
delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
|
||||||
|
|
||||||
if (delta > 0)
|
if (horizontal)
|
||||||
{
|
flags |= PTR_FLAGS_HWHEEL;
|
||||||
flags = PTR_FLAGS_WHEEL | 0x0078;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
flags |= PTR_FLAGS_WHEEL;
|
||||||
flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
|
|
||||||
}
|
|
||||||
|
|
||||||
input->MouseEvent(input, flags, 0, 0);
|
if (delta < 0)
|
||||||
return 0;
|
{
|
||||||
|
flags |= PTR_FLAGS_WHEEL_NEGATIVE;
|
||||||
|
delta = -delta;
|
||||||
|
}
|
||||||
|
flags |= delta;
|
||||||
|
|
||||||
|
return wf_scale_mouse_event(wfc, input, flags, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
|
static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
|
||||||
@ -354,6 +360,28 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
|
|||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if (_WIN32_WINNT >= 0x0500)
|
||||||
|
case WM_XBUTTONDOWN:
|
||||||
|
wf_scale_mouse_event_ex(wfc, input, PTR_XFLAGS_DOWN, GET_XBUTTON_WPARAM(wParam),
|
||||||
|
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_XBUTTONUP:
|
||||||
|
wf_scale_mouse_event_ex(wfc, input, 0, GET_XBUTTON_WPARAM(wParam),
|
||||||
|
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
|
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:
|
||||||
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON3,
|
||||||
|
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1,
|
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1,
|
||||||
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
|
||||||
@ -379,9 +407,21 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
|
|||||||
Y_POS(lParam) - wfc->offset_y);
|
Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam);
|
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam, FALSE,
|
||||||
|
X_POS(lParam) - wfc->offset_x,
|
||||||
|
Y_POS(lParam) - wfc->offset_y);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (_WIN32_WINNT >= 0x0600)
|
||||||
|
case WM_MOUSEHWHEEL:
|
||||||
|
wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam, TRUE,
|
||||||
|
X_POS(lParam) - wfc->offset_x,
|
||||||
|
Y_POS(lParam) - wfc->offset_y);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
if (LOWORD(lParam) == HTCLIENT)
|
if (LOWORD(lParam) == HTCLIENT)
|
||||||
@ -656,13 +696,18 @@ BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
static BOOL wf_scale_mouse_pos(wfContext* wfc, UINT16* x, UINT16* y)
|
||||||
UINT16 x, UINT16 y)
|
|
||||||
{
|
{
|
||||||
int ww, wh, dw, dh;
|
int ww, wh, dw, dh;
|
||||||
rdpContext* context;
|
rdpContext* context;
|
||||||
rdpSettings* settings = wfc->context.settings;
|
rdpSettings* settings;
|
||||||
MouseEventEventArgs eventArgs;
|
|
||||||
|
if (!wfc || !x || !y)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
settings = wfc->context.settings;
|
||||||
|
if (!settings)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (!wfc->client_width)
|
if (!wfc->client_width)
|
||||||
wfc->client_width = settings->DesktopWidth;
|
wfc->client_width = settings->DesktopWidth;
|
||||||
@ -676,16 +721,58 @@ static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
|||||||
dh = settings->DesktopHeight;
|
dh = settings->DesktopHeight;
|
||||||
|
|
||||||
if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
||||||
input->MouseEvent(input, flags, x + wfc->xCurrentScroll,
|
{
|
||||||
y + wfc->yCurrentScroll);
|
*x += wfc->xCurrentScroll;
|
||||||
|
*y += wfc->yCurrentScroll;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
input->MouseEvent(input, flags, x * dw / ww + wfc->xCurrentScroll,
|
{
|
||||||
y * dh / wh + wfc->yCurrentScroll);
|
*x = *x * dw / ww + wfc->xCurrentScroll;
|
||||||
|
*y = *y * dh / wh + wfc->yCurrentScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
||||||
|
UINT16 x, UINT16 y)
|
||||||
|
{
|
||||||
|
MouseEventEventArgs eventArgs;
|
||||||
|
|
||||||
|
if (!wf_scale_mouse_pos(wfc, &x, &y))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (freerdp_input_send_mouse_event(input, flags, x, y))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
eventArgs.flags = flags;
|
eventArgs.flags = flags;
|
||||||
eventArgs.x = x;
|
eventArgs.x = x;
|
||||||
eventArgs.y = y;
|
eventArgs.y = y;
|
||||||
context = (rdpContext*) wfc;
|
PubSub_OnMouseEvent(wfc->context.pubSub, &wfc->context, &eventArgs);
|
||||||
PubSub_OnMouseEvent(context->pubSub, context, &eventArgs);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if(_WIN32_WINNT >= 0x0500)
|
||||||
|
static BOOL wf_scale_mouse_event_ex(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 buttonMask,
|
||||||
|
UINT16 x, UINT16 y)
|
||||||
|
{
|
||||||
|
MouseEventExEventArgs eventArgs;
|
||||||
|
|
||||||
|
if (buttonMask & XBUTTON1)
|
||||||
|
flags |= PTR_XFLAGS_BUTTON1;
|
||||||
|
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
|
||||||
|
@ -104,6 +104,12 @@ UINT16 x;
|
|||||||
UINT16 y;
|
UINT16 y;
|
||||||
DEFINE_EVENT_END(MouseEvent)
|
DEFINE_EVENT_END(MouseEvent)
|
||||||
|
|
||||||
|
DEFINE_EVENT_BEGIN(MouseEventEx)
|
||||||
|
UINT16 flags;
|
||||||
|
UINT16 x;
|
||||||
|
UINT16 y;
|
||||||
|
DEFINE_EVENT_END(MouseEventEx)
|
||||||
|
|
||||||
DEFINE_EVENT_BEGIN(Timer)
|
DEFINE_EVENT_BEGIN(Timer)
|
||||||
UINT64 now;
|
UINT64 now;
|
||||||
DEFINE_EVENT_END(Timer)
|
DEFINE_EVENT_END(Timer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user