X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/42132f2d662cd51e696af7923f7331bfb636b0cd..9bb5bf60022c774f1d4624eb37e648db4edd8b3c:/windows.c?ds=sidebyside diff --git a/windows.c b/windows.c index 6fb651c..7689993 100644 --- a/windows.c +++ b/windows.c @@ -328,6 +328,9 @@ static frontend *new_window(HINSTANCE inst) fe->timer = 0; + fe->fonts = NULL; + fe->nfonts = fe->fontsize = 0; + { int i, ncolours; float *colours; @@ -936,7 +939,50 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, button = LEFT_BUTTON; else button = RIGHT_BUTTON; - + + if (!midend_process_key(fe->me, LOWORD(lParam), + HIWORD(lParam), button)) + PostQuitMessage(0); + + SetCapture(hwnd); + } + break; + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + { + int button; + + /* + * Shift-clicks count as middle-clicks, since otherwise + * two-button Windows users won't have any kind of + * middle click to use. + */ + if (message == WM_MBUTTONUP || (wParam & MK_SHIFT)) + button = MIDDLE_RELEASE; + else if (message == WM_LBUTTONUP) + button = LEFT_RELEASE; + else + button = RIGHT_RELEASE; + + if (!midend_process_key(fe->me, LOWORD(lParam), + HIWORD(lParam), button)) + PostQuitMessage(0); + + ReleaseCapture(); + } + break; + case WM_MOUSEMOVE: + { + int button; + + if (wParam & (MK_MBUTTON | MK_SHIFT)) + button = MIDDLE_DRAG; + else if (wParam & MK_LBUTTON) + button = LEFT_DRAG; + else + button = RIGHT_DRAG; + if (!midend_process_key(fe->me, LOWORD(lParam), HIWORD(lParam), button)) PostQuitMessage(0);