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.
This commit is contained in:
Holger Vogt 2022-01-28 12:11:39 +01:00
parent 857fbec985
commit ce9bc9fc64
1 changed files with 5 additions and 2 deletions

View File

@ -558,7 +558,6 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg,
case WM_LBUTTONUP: case WM_LBUTTONUP:
{ {
GRAPH *gr = pGraph(hwnd); GRAPH *gr = pGraph(hwnd);
InvalidateRect (hwnd, NULL, TRUE);
xe = LOWORD (lParam); xe = LOWORD (lParam);
ye = HIWORD (lParam); ye = HIWORD (lParam);
WIN_ScreentoData(gr, xe, ye, &fxe, &fye); WIN_ScreentoData(gr, xe, ye, &fxe, &fye);
@ -578,6 +577,8 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg,
} }
else { else {
/* need to print info about two points */ /* 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", fprintf(stdout, "\nx0 = %g, y0 = %g x1 = %g, y1 = %g\n",
fx0, fy0, fxe, fye); fx0, fy0, fxe, fye);
fprintf(stdout, "dx = %g, dy = %g\n", fxe-fx0, fye - fy0); 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: case WM_RBUTTONUP:
{ {
GRAPH *gr = pGraph(hwnd); GRAPH *gr = pGraph(hwnd);
InvalidateRect (hwnd, NULL, TRUE);
xe = LOWORD (lParam); xe = LOWORD (lParam);
ye = HIWORD (lParam); ye = HIWORD (lParam);
/* do nothing if mouse curser is not moved in both x and y */ /* 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); SetFocus(swString);
goto WIN_DEFAULT; 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); WIN_ScreentoData(gr, xe, ye, &fxe, &fye);
strncpy(buf2, gr->plotname, sizeof(buf2)); strncpy(buf2, gr->plotname, sizeof(buf2));