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);
|
||||
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
||||
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_out;
|
||||
@ -188,27 +192,29 @@ void wf_event_focus_in(wfContext* wfc)
|
||||
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,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
static BOOL wf_event_process_WM_MOUSEWHEEL(wfContext* wfc, HWND hWnd, UINT Msg,
|
||||
WPARAM wParam, LPARAM lParam, BOOL horizontal, UINT16 x, UINT16 y)
|
||||
{
|
||||
int delta;
|
||||
int flags;
|
||||
UINT16 flags = 0;
|
||||
rdpInput* input;
|
||||
DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||
input = wfc->context.input;
|
||||
delta = ((signed short) HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
|
||||
|
||||
if (delta > 0)
|
||||
{
|
||||
flags = PTR_FLAGS_WHEEL | 0x0078;
|
||||
}
|
||||
if (horizontal)
|
||||
flags |= PTR_FLAGS_HWHEEL;
|
||||
else
|
||||
{
|
||||
flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
|
||||
}
|
||||
flags |= PTR_FLAGS_WHEEL;
|
||||
|
||||
input->MouseEvent(input, flags, 0, 0);
|
||||
return 0;
|
||||
if (delta < 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)
|
||||
@ -354,6 +360,28 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam,
|
||||
EndPaint(hWnd, &ps);
|
||||
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:
|
||||
wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1,
|
||||
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);
|
||||
break;
|
||||
|
||||
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
|
||||
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;
|
||||
#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:
|
||||
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;
|
||||
}
|
||||
|
||||
static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
||||
UINT16 x, UINT16 y)
|
||||
static BOOL wf_scale_mouse_pos(wfContext* wfc, UINT16* x, UINT16* y)
|
||||
{
|
||||
int ww, wh, dw, dh;
|
||||
rdpContext* context;
|
||||
rdpSettings* settings = wfc->context.settings;
|
||||
MouseEventEventArgs eventArgs;
|
||||
rdpSettings* settings;
|
||||
|
||||
if (!wfc || !x || !y)
|
||||
return FALSE;
|
||||
|
||||
settings = wfc->context.settings;
|
||||
if (!settings)
|
||||
return FALSE;
|
||||
|
||||
if (!wfc->client_width)
|
||||
wfc->client_width = settings->DesktopWidth;
|
||||
@ -676,16 +721,58 @@ static BOOL wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags,
|
||||
dh = settings->DesktopHeight;
|
||||
|
||||
if (!settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
||||
input->MouseEvent(input, flags, x + wfc->xCurrentScroll,
|
||||
y + wfc->yCurrentScroll);
|
||||
{
|
||||
*x += wfc->xCurrentScroll;
|
||||
*y += wfc->yCurrentScroll;
|
||||
}
|
||||
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.x = x;
|
||||
eventArgs.y = y;
|
||||
context = (rdpContext*) wfc;
|
||||
PubSub_OnMouseEvent(context->pubSub, context, &eventArgs);
|
||||
PubSub_OnMouseEvent(wfc->context.pubSub, &wfc->context, &eventArgs);
|
||||
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;
|
||||
DEFINE_EVENT_END(MouseEvent)
|
||||
|
||||
DEFINE_EVENT_BEGIN(MouseEventEx)
|
||||
UINT16 flags;
|
||||
UINT16 x;
|
||||
UINT16 y;
|
||||
DEFINE_EVENT_END(MouseEventEx)
|
||||
|
||||
DEFINE_EVENT_BEGIN(Timer)
|
||||
UINT64 now;
|
||||
DEFINE_EVENT_END(Timer)
|
||||
|
Loading…
Reference in New Issue
Block a user