From 8862bd4f89c3230cf52b0536a66a07abe9303253 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 1 Nov 2026 19:18:33 +0100 Subject: [PATCH] Require an owned mouse release in transfer modals (by Codex) Late or repeated releases from a post-match table cannot decline the immediately following transfer or acknowledge its confirmation. Track presses within each release-driven modal; keep semantic Source DOWN actions and fresh left/right gestures. Reproduced and verified through the real post-match table-to-transfer GUI flow. Refs: #44 --- docs/COMPATIBILITY.md | 6 ++++++ src/app/main.cpp | 16 +++++++++++----- src/ui/incoming_transfer.cpp | 11 +++++++++++ src/ui/incoming_transfer.hpp | 5 +++++ src/ui/incoming_transfer_tests.cpp | 25 +++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index 7092d8e..5705345 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -154,3 +154,9 @@ Per-unit rounding and the selected legacy/typed recipient policy are unchanged. This corrects intermediate overflow for representable dividends; account, deposit, property book value and monthly totals still use their native 32-bit storage and can overflow. It is not a complete large-balance finance fix. + + +Release-driven incoming-transfer presenters require a matching press observed +inside that modal. An orphan or repeated release from the preceding result table +cannot decline an offer or dismiss its confirmation. Repeated presses while a +button is held still form one gesture; fresh left/right clicks keep their actions. diff --git a/src/app/main.cpp b/src/app/main.cpp index a66f1fb..a131911 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -2225,10 +2225,13 @@ int main(int argc, char** argv) { while (quit_confirmation.poll(&event)) { if (event.type == SDL_QUIT) { running = false; return -1; } std::optional answer; - if (event.type == SDL_MOUSEBUTTONUP && + if (event.type == SDL_MOUSEBUTTONDOWN && (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) { - answer = offer_screen.click(event.button.x, event.button.y, - event.button.button == SDL_BUTTON_RIGHT); + offer_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT); + } else if (event.type == SDL_MOUSEBUTTONUP && + (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) { + answer = offer_screen.pointer_up(event.button.x, event.button.y, + event.button.button == SDL_BUTTON_RIGHT); offer_dirty = true; } else if (event.type == SDL_KEYDOWN) { if (offer_screen.notice_active()) { @@ -2293,9 +2296,12 @@ int main(int argc, char** argv) { SDL_Event event; while (quit_confirmation.poll(&event)) { if (event.type == SDL_QUIT) { running = false; return; } - if (event.type == SDL_MOUSEBUTTONUP && + if (event.type == SDL_MOUSEBUTTONDOWN && (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) - (void)decision_screen.click(event.button.x, event.button.y, + decision_screen.pointer_down(event.button.button == SDL_BUTTON_RIGHT); + else if (event.type == SDL_MOUSEBUTTONUP && + (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) + (void)decision_screen.pointer_up(event.button.x, event.button.y, event.button.button == SDL_BUTTON_RIGHT, elapsed); } if (confirmation ? decision_screen.confirmation_dismissed() : decision_screen.outcome_dismissed()) return; diff --git a/src/ui/incoming_transfer.cpp b/src/ui/incoming_transfer.cpp index f00372d..c6dbb96 100644 --- a/src/ui/incoming_transfer.cpp +++ b/src/ui/incoming_transfer.cpp @@ -530,6 +530,17 @@ bool IncomingTransferScreen::dismiss_notice() { return true; } +void IncomingTransferScreen::pointer_down(bool right) { + pointer_buttons_ |= right ? 2 : 1; +} + +std::optional IncomingTransferScreen::pointer_up(int x, int y, bool right, uint64_t elapsed_ms) { + const uint8_t button = right ? 2 : 1; + if (!(pointer_buttons_ & button)) return std::nullopt; + pointer_buttons_ &= uint8_t(~button); + return click(x, y, right, elapsed_ms); +} + std::optional IncomingTransferScreen::click(int x, int y, bool right, uint64_t elapsed_ms) { if (confirmation_mode_) { if (!right && x >= 95 && x <= 220 && y >= 166 && y <= 176) diff --git a/src/ui/incoming_transfer.hpp b/src/ui/incoming_transfer.hpp index c5eb228..717e86a 100644 --- a/src/ui/incoming_transfer.hpp +++ b/src/ui/incoming_transfer.hpp @@ -142,6 +142,10 @@ public: void show_confirmation(uint32_t original_text_address, const Image& backdrop); bool confirmation_dismissed() const { return confirmation_dismissed_; } bool outcome_dismissed() const { return outcome_dismissed_; } + // Raw release-driven presenters must own a press in this visible modal. + // Semantic Source DOWN actions can continue to use click directly. + void pointer_down(bool right = false); + std::optional pointer_up(int x, int y, bool right = false, uint64_t elapsed_ms = 0); std::optional click(int x, int y, bool right = false, uint64_t elapsed_ms = 0); std::optional key(std::string_view name); bool dismiss_notice(); @@ -159,6 +163,7 @@ private: Image background_, negotiation_; bool gradient_text_ = true; std::optional answer_; + uint8_t pointer_buttons_ = 0; bool notice_active_ = false; int outcome_row_count_ = -1; int outcome_accepted_bid_index_ = -1; diff --git a/src/ui/incoming_transfer_tests.cpp b/src/ui/incoming_transfer_tests.cpp index aa6479c..97f2f88 100644 --- a/src/ui/incoming_transfer_tests.cpp +++ b/src/ui/incoming_transfer_tests.cpp @@ -93,6 +93,24 @@ int main(int argc, char** argv) { "raw Source 0xfff pool seller resolves without indexing a club or national-team token"); auto state = fixture(); + IncomingTransferScreen release_owner(argv[1], state); + const auto undecided_pixels = release_owner.render().pixels; + check(!release_owner.pointer_up(310,230,true) && + !release_owner.pointer_up(309,229,true) && !release_owner.answer() && + release_owner.render().pixels == undecided_pixels, + "late/repeated table releases cannot decline the following transfer"); + release_owner.pointer_down(); + release_owner.pointer_down(); // Repeated DOWN still owns a single left gesture. + check(!release_owner.pointer_up(310,230,true) && !release_owner.answer(), + "an orphan right release does not consume an owned left press"); + check(release_owner.pointer_up(10,150) == 0 && + !release_owner.pointer_up(10,150) && release_owner.answer() == 0, + "fresh left gesture selects its raw offer once despite repeated DOWN/UP"); + IncomingTransferScreen right_owner(argv[1], state); + right_owner.pointer_down(true);right_owner.pointer_down(true); + check(right_owner.pointer_up(309,229,true) == -1 && + !right_owner.pointer_up(309,229,true) && right_owner.answer() == -1, + "fresh moved right gesture still declines exactly once"); IncomingTransferScreen screen(argv[1], state); const auto frame = screen.render(); check(frame.width == 320 && frame.height == 240 && frame.pixels.size() == 320u * 240u, @@ -247,6 +265,13 @@ int main(int argc, char** argv) { "only a left click inside KLICK can acknowledge the confirmation"); check(!confirm.click(95,166) && confirm.confirmation_dismissed() && !confirm.answer(), "KLICK acknowledges without submitting a new transfer decision"); + IncomingTransferScreen confirmation_owner(argv[1],confirm_state); + confirmation_owner.show_confirmation(::bmh::layout::PendingOffer_FormatError_ExecutableField2,settled_image); + check(!confirmation_owner.pointer_up(150,170) && !confirmation_owner.confirmation_dismissed(), + "an inherited left release cannot acknowledge the next confirmation"); + confirmation_owner.pointer_down(); + check(!confirmation_owner.pointer_up(150,170) && confirmation_owner.confirmation_dismissed(), + "a fresh complete left gesture acknowledges its owned confirmation"); IncomingTransferScreen confirm_edge(argv[1],confirm_state); confirm_edge.show_confirmation(::bmh::layout::PendingOffer_FormatError_ExecutableField2,settled_image); check(!confirm_edge.click(221,176) && !confirm_edge.confirmation_dismissed(),