summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--freecell.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/freecell.c b/freecell.c
index f6562b8..da8729d 100644
--- a/freecell.c
+++ b/freecell.c
@@ -275,18 +275,18 @@ static bool mouseButtonDown(SDL_MouseButtonEvent button) {
 }
 
 static bool mouseButtonUp(SDL_MouseButtonEvent button) {
+	struct SDL_Point point = { button.x, button.y };
+
 	if (button.button == SDL_BUTTON_RIGHT) {
 		if (!reveal.len) return false;
 		reveal.len = 0;
 		return true;
 	}
 
-	struct SDL_Point point = { button.x, button.y };
-	struct Item *item = listFind(&layout.main, &point);
-
 	if (button.clicks % 2 == 0) {
 		Card card = layout.dragItem.card;
 		if (!card) {
+			struct Item *item = listFind(&layout.main, &point);
 			if (!item) return false;
 			card = item->card;
 		}
@@ -308,6 +308,7 @@ static bool mouseButtonUp(SDL_MouseButtonEvent button) {
 		return true;
 	}
 
+	struct Item *item = listFind(&layout.main, &point);
 	if (!item) return false;
 	if (!gameAvail(item->card)) return false;
 	layout.dragItem = *item;