From: Jonas Kölker Date: Tue, 22 Sep 2015 09:18:31 +0000 (+0200) Subject: Refactor modifier handling in Pearl's cursor code. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;ds=sidebyside;h=8e35087e093876cd12b1a5800c16a068473e9bff;p=sgt-puzzles.git Refactor modifier handling in Pearl's cursor code. --- diff --git a/pearl.c b/pearl.c index 0eb3d4b..83413a2 100644 --- a/pearl.c +++ b/pearl.c @@ -1998,6 +1998,9 @@ static char *interpret_move(const game_state *state, game_ui *ui, int release = FALSE; char tmpbuf[80]; + int shift = button & MOD_SHFT, control = button & MOD_CTRL; + button &= ~MOD_MASK; + if (IS_MOUSE_DOWN(button)) { ui->cursor_active = FALSE; @@ -2020,10 +2023,10 @@ static char *interpret_move(const game_state *state, game_ui *ui, if (IS_MOUSE_RELEASE(button)) release = TRUE; - if (IS_CURSOR_MOVE(button & ~MOD_MASK)) { + if (IS_CURSOR_MOVE(button)) { if (!ui->cursor_active) { ui->cursor_active = TRUE; - } else if (button & (MOD_SHFT | MOD_CTRL)) { + } else if (control | shift) { if (ui->ndragcoords > 0) return NULL; ui->ndragcoords = -1; return mark_in_direction(state, ui->curx, ui->cury, @@ -2037,7 +2040,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, return ""; } - if (IS_CURSOR_SELECT(button & ~MOD_MASK)) { + if (IS_CURSOR_SELECT(button)) { if (!ui->cursor_active) { ui->cursor_active = TRUE; return "";