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).
git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5907
cda61777-01e9-0310-a592-
d414129be87e
if (event->button == 2 || (event->state & GDK_SHIFT_MASK))
button = MIDDLE_BUTTON;
if (event->button == 2 || (event->state & GDK_SHIFT_MASK))
button = MIDDLE_BUTTON;
+ else if (event->button == 3 || (event->state & GDK_MOD1_MASK))
+ button = RIGHT_BUTTON;
else if (event->button == 1)
button = LEFT_BUTTON;
else if (event->button == 1)
button = LEFT_BUTTON;
- else if (event->button == 3)
- button = RIGHT_BUTTON;
else
return FALSE; /* don't even know what button! */
else
return FALSE; /* don't even know what button! */
+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)
{
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
*/
if (message == WM_MBUTTONDOWN || (wParam & MK_SHIFT))
button = MIDDLE_BUTTON;
*/
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())
+ else
+ button = LEFT_BUTTON;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
*/
if (message == WM_MBUTTONUP || (wParam & MK_SHIFT))
button = MIDDLE_RELEASE;
*/
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())
+ else
+ button = LEFT_RELEASE;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
if (wParam & (MK_MBUTTON | MK_SHIFT))
button = MIDDLE_DRAG;
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())
+ else
+ button = LEFT_DRAG;
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))
if (!midend_process_key(fe->me, (signed short)LOWORD(lParam),
(signed short)HIWORD(lParam), button))