aboutsummaryrefslogtreecommitdiff
path: root/windows.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-06-03 12:27:29 +0000
committerSimon Tatham <anakin@pobox.com>2005-06-03 12:27:29 +0000
commit402408125eb8db989b125e3059f873b9a833632a (patch)
treeb6b62262e145538e24994ca5a540a926048a5399 /windows.c
parent41ebdb29c6e40be97d2b02259c41522319d131d9 (diff)
downloadpuzzles-402408125eb8db989b125e3059f873b9a833632a.zip
puzzles-402408125eb8db989b125e3059f873b9a833632a.tar.gz
puzzles-402408125eb8db989b125e3059f873b9a833632a.tar.bz2
puzzles-402408125eb8db989b125e3059f873b9a833632a.tar.xz
Colin Watson suggests that Alt-click (or Option-click) could
usefully be equivalent to right-clicking on platforms other than OS X; in particular, it's useful if you're running Linux on Apple hardware such as PowerBook which inherently has only one button. So here's the fix for GTK, and Windows as well (the latter for completeness and consistency, not because I can actually think of any reason somebody might be running Windows on one-button hardware). [originally from svn r5907]
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/windows.c b/windows.c
index 430fff0..be1f17c 100644
--- a/windows.c
+++ b/windows.c
@@ -1107,6 +1107,19 @@ static void new_game_type(frontend *fe)
midend_redraw(fe->me);
}
+static int is_alt_pressed(void)
+{
+ BYTE keystate[256];
+ int r = GetKeyboardState(keystate);
+ if (!r)
+ return FALSE;
+ if (keystate[VK_MENU] & 0x80)
+ return TRUE;
+ if (keystate[VK_RMENU] & 0x80)
+ return TRUE;
+ return FALSE;
+}
+
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
@@ -1316,10 +1329,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
*/
if (message == WM_MBUTTONDOWN || (wParam & MK_SHIFT))
button = MIDDLE_BUTTON;
- else if (message == WM_LBUTTONDOWN)
- button = LEFT_BUTTON;
- else
+ else if (message == WM_RBUTTONDOWN || is_alt_pressed())
button = RIGHT_BUTTON;
+ else
+ button = LEFT_BUTTON;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
@@ -1341,10 +1354,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
*/
if (message == WM_MBUTTONUP || (wParam & MK_SHIFT))
button = MIDDLE_RELEASE;
- else if (message == WM_LBUTTONUP)
- button = LEFT_RELEASE;
- else
+ else if (message == WM_RBUTTONUP || is_alt_pressed())
button = RIGHT_RELEASE;
+ else
+ button = LEFT_RELEASE;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
@@ -1359,10 +1372,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
if (wParam & (MK_MBUTTON | MK_SHIFT))
button = MIDDLE_DRAG;
- else if (wParam & MK_LBUTTON)
- button = LEFT_DRAG;
- else
+ else if (wParam & MK_RBUTTON || is_alt_pressed())
button = RIGHT_DRAG;
+ else
+ button = LEFT_DRAG;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))