mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Add a way for midend_process_key() to report whether it handled a keypress
This adds a new bool * argument, which can be NULL if front ends don't care whether the keypress was handled. Currently they all do that. Currently, "undo" and "redo" keys are treated as not handled if there's no move to undo or redo. This may be a little too strict.
This commit is contained in:
18
windows.c
18
windows.c
@ -2530,18 +2530,18 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
cmd = wParam & ~0xF; /* low 4 bits reserved to Windows */
|
||||
switch (cmd) {
|
||||
case IDM_NEW:
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_NEWGAME))
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_NEWGAME, NULL))
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case IDM_RESTART:
|
||||
midend_restart_game(fe->me);
|
||||
break;
|
||||
case IDM_UNDO:
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_UNDO))
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_UNDO, NULL))
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case IDM_REDO:
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_REDO))
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_REDO, NULL))
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case IDM_COPY:
|
||||
@ -2563,7 +2563,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
break;
|
||||
case IDM_QUIT:
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_QUIT))
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_QUIT, NULL))
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case IDM_CONFIG:
|
||||
@ -2833,7 +2833,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
|
||||
if (key != -1) {
|
||||
if (!midend_process_key(fe->me, 0, 0, key))
|
||||
if (!midend_process_key(fe->me, 0, 0, key, NULL))
|
||||
PostQuitMessage(0);
|
||||
} else {
|
||||
MSG m;
|
||||
@ -2866,7 +2866,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
if (!midend_process_key(fe->me,
|
||||
(signed short)LOWORD(lParam) - fe->bitmapPosition.left,
|
||||
(signed short)HIWORD(lParam) - fe->bitmapPosition.top,
|
||||
button))
|
||||
button, NULL))
|
||||
PostQuitMessage(0);
|
||||
|
||||
SetCapture(hwnd);
|
||||
@ -2893,7 +2893,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
if (!midend_process_key(fe->me,
|
||||
(signed short)LOWORD(lParam) - fe->bitmapPosition.left,
|
||||
(signed short)HIWORD(lParam) - fe->bitmapPosition.top,
|
||||
button))
|
||||
button, NULL))
|
||||
PostQuitMessage(0);
|
||||
|
||||
ReleaseCapture();
|
||||
@ -2913,7 +2913,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
if (!midend_process_key(fe->me,
|
||||
(signed short)LOWORD(lParam) - fe->bitmapPosition.left,
|
||||
(signed short)HIWORD(lParam) - fe->bitmapPosition.top,
|
||||
button))
|
||||
button, NULL))
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
break;
|
||||
@ -2927,7 +2927,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
(keystate[VK_CONTROL] & 0x80))
|
||||
key = UI_REDO;
|
||||
}
|
||||
if (!midend_process_key(fe->me, 0, 0, key))
|
||||
if (!midend_process_key(fe->me, 0, 0, key, NULL))
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user