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;
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;
+
+ if (delta < 0)
{
- flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
+ flags |= PTR_FLAGS_WHEEL_NEGATIVE;
+ delta = -delta;
}
+ flags |= delta;
- input->MouseEvent(input, flags, 0, 0);
- return 0;
+ return wf_scale_mouse_event(wfc, input, flags, x, y);
}
static void wf_sizing(wfContext* wfc, WPARAM wParam, LPARAM lParam)
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);
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)
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;
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