From ce9bc9fc64878177c9eccc171c514384583bad85 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 28 Jan 2022 12:11:39 +0100 Subject: [PATCH] The re-painting due to mouse-click under MS Windows is caused by line 561 of windisp.c. Upon left mouse button up the plot recangle is invalidated, and a WM_PAINT message is generated (same on line 614 for right mouse button up). If not re-pained, artifacts may be left on the canvas after collecting coordinate data. Shifting the command InvalidateRect to a place where it becomes active only after the mouse has been moved, does the trick. Simple clicking (right or left) will not cause a re-paint any more. --- src/frontend/wdisp/windisp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index e3aeb4c86..72461e0a4 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -558,7 +558,6 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, case WM_LBUTTONUP: { GRAPH *gr = pGraph(hwnd); - InvalidateRect (hwnd, NULL, TRUE); xe = LOWORD (lParam); ye = HIWORD (lParam); WIN_ScreentoData(gr, xe, ye, &fxe, &fye); @@ -578,6 +577,8 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, } else { /* need to print info about two points */ + /* trigger re-plotting the graph to get rid of the coordinate rectangle */ + InvalidateRect (hwnd, NULL, TRUE); fprintf(stdout, "\nx0 = %g, y0 = %g x1 = %g, y1 = %g\n", fx0, fy0, fxe, fye); fprintf(stdout, "dx = %g, dy = %g\n", fxe-fx0, fye - fy0); @@ -611,7 +612,6 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, case WM_RBUTTONUP: { GRAPH *gr = pGraph(hwnd); - InvalidateRect (hwnd, NULL, TRUE); xe = LOWORD (lParam); ye = HIWORD (lParam); /* do nothing if mouse curser is not moved in both x and y */ @@ -619,6 +619,9 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, SetFocus(swString); goto WIN_DEFAULT; } + /* trigger re-plotting the graph to get rid of the coordinate rectangle */ + InvalidateRect(hwnd, NULL, TRUE); + WIN_ScreentoData(gr, xe, ye, &fxe, &fye); strncpy(buf2, gr->plotname, sizeof(buf2));