From: jacob Date: Sat, 20 Dec 2008 19:02:09 +0000 (+0000) Subject: "Derek" points out that reporting of wheel event coordinates to the host on X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/7a3fbdafb485690f97464e9f44ecb775fae9436b "Derek" points out that reporting of wheel event coordinates to the host on Windows was relative to the screen origin, not the window origin. git-svn-id: svn://svn.tartarus.org/sgt/putty@8375 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/windows/window.c b/windows/window.c index b424674e..7f23767c 100644 --- a/windows/window.c +++ b/windows/window.c @@ -3046,16 +3046,22 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (send_raw_mouse && !(cfg.mouse_override && shift_pressed)) { - /* send a mouse-down followed by a mouse up */ - term_mouse(term, b, translate_button(b), - MA_CLICK, - TO_CHR_X(X_POS(lParam)), - TO_CHR_Y(Y_POS(lParam)), shift_pressed, - control_pressed, is_alt_pressed()); - term_mouse(term, b, translate_button(b), - MA_RELEASE, TO_CHR_X(X_POS(lParam)), - TO_CHR_Y(Y_POS(lParam)), shift_pressed, - control_pressed, is_alt_pressed()); + /* Mouse wheel position is in screen coordinates for + * some reason */ + POINT p; + p.x = X_POS(lParam); p.y = Y_POS(lParam); + if (ScreenToClient(hwnd, &p)) { + /* send a mouse-down followed by a mouse up */ + term_mouse(term, b, translate_button(b), + MA_CLICK, + TO_CHR_X(p.x), + TO_CHR_Y(p.y), shift_pressed, + control_pressed, is_alt_pressed()); + term_mouse(term, b, translate_button(b), + MA_RELEASE, TO_CHR_X(p.x), + TO_CHR_Y(p.y), shift_pressed, + control_pressed, is_alt_pressed()); + } /* else: not sure when this can fail */ } else { /* trigger a scroll */ term_scroll(term, 0,