Refresh advertising hover when modal input returns (by Codex)

This commit is contained in:
Codex committed 2026-11-02 16:23:10 +01:00
1 parent 8b1dc16233
commit fcbe1ebc13
5 files changed
+69 -2

No files matched your search

+19 -1
View File
@@ -858,6 +858,7 @@ void AdvertisingScreen::draw_notification(Image& out) const {
bool AdvertisingScreen::dismiss_notification() {
if (!notification_open()) return false;
notification_dismissed_ = true;
refresh_hover();
return true;
}
@@ -894,6 +895,7 @@ void AdvertisingScreen::open_spending_calculator(int display_slot) {
void AdvertisingScreen::close_spending_calculator() {
spending_calculator_open_ = false;
spending_backdrop_.reset();
refresh_hover();
}
bool AdvertisingScreen::accept_spending_calculator() {
@@ -1001,11 +1003,20 @@ bool AdvertisingScreen::reject_action(std::string reason) {
(void)utf8_to_original(reason);
if (pending_->kind == AdvertisingActionKind::set_spending) close_spending_calculator();
pending_.reset();
refresh_hover();
feedback_ = std::move(reason);
return true;
}
void AdvertisingScreen::refresh_hover() {
if (pointer_position_) (void)move((*pointer_position_)[0], (*pointer_position_)[1]);
else hovered_target_ = -1;
}
bool AdvertisingScreen::move(int x, int y) {
// Modal input freezes the parent view, but its last physical position must
// be sampled again as soon as that modal returns.
pointer_position_ = std::array<int, 2>{x, y};
if (close_requested_ || pending_ || notification_open() || spending_calculator_open_ || offer_open_)
return false;
int target = -1;
@@ -1026,6 +1037,7 @@ bool AdvertisingScreen::move(int x, int y) {
}
bool AdvertisingScreen::click(int x, int y) {
pointer_position_ = std::array<int, 2>{x, y};
if (close_requested_ || pending_ || x < 0 || y < 0 || x >= 320 || y >= 240) return false;
if (notification_open()) return dismiss_notification();
if (spending_calculator_open_) {
@@ -1056,6 +1068,7 @@ bool AdvertisingScreen::click(int x, int y) {
offer_open_ = false;
selected_offer_ = -1;
feedback_.clear();
refresh_hover();
return true;
}
if (x >= 164 && x <= 229 && y >= 191 && y <= 200) {
@@ -1133,7 +1146,12 @@ bool AdvertisingScreen::key(std::string_view value) {
return text(value);
}
if (value == "ESC") {
if (offer_open_) { offer_open_ = false; selected_offer_ = -1; return true; }
if (offer_open_) {
offer_open_ = false;
selected_offer_ = -1;
refresh_hover();
return true;
}
close_requested_ = true;
return true;
}
+3
View File
@@ -114,6 +114,7 @@ public:
bool reject_action(std::string reason);
int selected_contract() const { return selected_contract_; }
int hovered_target() const { return hovered_target_; }
std::optional<std::array<int, 2>> pointer_position() const { return pointer_position_; }
int selected_offer() const { return selected_offer_; }
bool offer_open() const { return offer_open_; }
bool spending_calculator_open() const { return spending_calculator_open_; }
@@ -139,6 +140,7 @@ private:
std::optional<Image> spending_backdrop_;
int selected_contract_ = -1;
int hovered_target_ = -1;
std::optional<std::array<int, 2>> pointer_position_;
int selected_spending_slot_ = -1;
int selected_offer_ = -1;
uint64_t next_request_id_ = 1;
@@ -160,6 +162,7 @@ private:
bool accept_spending_calculator();
void close_spending_calculator();
bool dismiss_notification();
void refresh_hover();
void draw_spending_calculator(Image&) const;
void draw_notification(Image&) const;
void pattern_rect(Image&, int x, int y, int width, int height) const;
+25
View File
@@ -407,6 +407,17 @@ int main(int argc, char** argv) {
offers.close_requested(),
"cancel closes the offer browser first; a second ESC closes the screen");
AdvertisingScreen resumed_offers(data, offer_state);
const auto closed_offer_pixels = resumed_offers.render().pixels;
check(resumed_offers.open_offers(0) && !resumed_offers.move(-1, -1) &&
resumed_offers.key("ESC") && resumed_offers.hovered_target() == -1 &&
resumed_offers.render().pixels == closed_offer_pixels,
"offer ESC rechecks the pointer moved during the modal without another motion event");
check(resumed_offers.open_offers(0) && resumed_offers.click(110, 195) &&
resumed_offers.hovered_target() == -1 &&
resumed_offers.render().pixels == closed_offer_pixels,
"offer cancel rechecks its own click position and removes the old target outline");
// The three source spending controls open the original calculator. All
// editing remains local; only J/Enter on a changed value creates a
// manager/revision-bound request for the app controller.
@@ -470,6 +481,20 @@ int main(int argc, char** argv) {
unchanged_budget.spending_input() == 10000 && unchanged_budget.key("J") &&
!unchanged_budget.pending() && !unchanged_budget.spending_calculator_open(),
"accepting an unchanged monthly budget closes locally without an engine request");
AdvertisingScreen resumed_budget(data, spending_state);
const auto closed_budget_pixels = resumed_budget.render().pixels;
check(resumed_budget.click(budget_x, budget_y) && !resumed_budget.move(-1, -1) &&
resumed_budget.key("ESC") && resumed_budget.hovered_target() == -1 &&
resumed_budget.render().pixels == closed_budget_pixels,
"calculator ESC restores the current off-target pointer without another motion event");
AdvertisingScreen expected_parent(data, spending_state);
check(expected_parent.move(empty_x, empty_y) &&
resumed_budget.click(budget_x, budget_y) && !resumed_budget.move(empty_x, empty_y) &&
resumed_budget.key("J") && !resumed_budget.pending() &&
resumed_budget.hovered_target() == empty_slot &&
resumed_budget.render().pixels == expected_parent.render().pixels,
"unchanged calculator acceptance resumes hover over the current parent target");
AdvertisingScreen preset_budget(data, spending_state, 0x300000018ULL);
const int preset0_x = 103 + exe.u16(::bmh::layout::Advertising_Click_RuntimeField + 15 * 2);
+3
View File
@@ -1144,6 +1144,7 @@ FlowResult StartupFlow::pointer_down(int x,int y,bool right) {
return {changed};
}
if (environment_) return {environment_->pointer_down(x,y,right)};
if (advertising_) return {advertising_->move(x,y)};
if(pitch_){
const std::string before=pitch_->state_json();
const auto request=pitch_->pointer_down(x,y,right);
@@ -2293,6 +2294,8 @@ void StartupFlow::acknowledge_advertising(AdvertisingState state, DeskState desk
// Only contract acceptance resumes the next offer. Spending closes its calculator.
if (request.kind == AdvertisingActionKind::accept_offer)
(void)next_advertising->open_offers(request.offer.display_slot);
if (const auto pointer = advertising_->pointer_position())
(void)next_advertising->move((*pointer)[0], (*pointer)[1]);
desktop_ = std::move(next_desktop);
preparation_ = std::move(next_preparation);
advertising_ = std::move(next_advertising);