Fix M9.8c review findings in the engineering client
Resolve pointer ownership per SDL event so same-batch panel clicks, wheel and click-to-focus typing never reach the world; keep the Tab toggle independent of idempotent external capture release; own launcher phase and remote session together so Local fixture ends any remote attempt; wrap notices beside a reserved close column within a bounded stack. Adds client-panels test and host/session, same-batch and host-order Tab regressions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -19,10 +19,10 @@
|
||||
{"name": "analysis", "configurePreset": "analysis"},
|
||||
{"name": "asan", "configurePreset": "asan"},
|
||||
{"name": "tsan", "configurePreset": "tsan"},
|
||||
{"name": "client", "configurePreset": "client", "targets": ["evo-client-state-tests", "evo-client", "evo-client-lifecycle-tests", "evo-client-environment-tests", "evo-client-organism-tests", "evo-client-ui-model-tests"]},
|
||||
{"name": "client", "configurePreset": "client", "targets": ["evo-client-state-tests", "evo-client", "evo-client-lifecycle-tests", "evo-client-environment-tests", "evo-client-organism-tests", "evo-client-ui-model-tests", "evo-client-panel-tests"]},
|
||||
{"name": "client-probe", "configurePreset": "client-probe", "targets": ["evo-client-probe"]},
|
||||
{"name": "network", "configurePreset": "network", "targets": ["evo-client-state-tests", "evo-network-tests", "evo-dev-session"]},
|
||||
{"name": "client-network", "configurePreset": "client-network", "targets": ["evo-client-state-tests", "evo-client", "evo-client-lifecycle-tests", "evo-client-environment-tests", "evo-client-organism-tests", "evo-client-ui-model-tests", "evo-network-tests", "evo-dev-session"]}
|
||||
{"name": "client-network", "configurePreset": "client-network", "targets": ["evo-client-state-tests", "evo-client", "evo-client-lifecycle-tests", "evo-client-environment-tests", "evo-client-organism-tests", "evo-client-ui-model-tests", "evo-client-panel-tests", "evo-network-tests", "evo-dev-session"]}
|
||||
],
|
||||
"testPresets": [
|
||||
{"name": "debug", "configurePreset": "debug", "output": {"outputOnFailure": true}},
|
||||
|
||||
+14
-15
@@ -1,6 +1,7 @@
|
||||
#include "evo/client/application.hpp"
|
||||
#include "evo/client/launcher.hpp"
|
||||
#include "evo/client/selection.hpp"
|
||||
#include "evo/client/session_host.hpp"
|
||||
#include "evo/client/ui_state.hpp"
|
||||
#include "evo/render/environment.hpp"
|
||||
#include "evo/render/organism.hpp"
|
||||
@@ -264,13 +265,14 @@ int main(int argc, char** argv) try {
|
||||
}
|
||||
if ((start_fixture && connect_now) || (!screenshot.empty() && frames == 0))
|
||||
return 2;
|
||||
evo::client::Launcher launcher;
|
||||
// Launcher phase and remote session change together (fixture/live distinction).
|
||||
evo::client::SessionHost<evo::client_app::RemoteSession> host;
|
||||
const auto& launcher = host.launcher();
|
||||
evo::client::UiState ui;
|
||||
evo::client::Selection selection;
|
||||
evo::client_app::FormBuffers buffers;
|
||||
buffers.load(form);
|
||||
std::optional<evo::client::LaunchError> form_error;
|
||||
std::optional<evo::client_app::RemoteSession> remote;
|
||||
std::optional<FixtureAuthority> authority;
|
||||
evo::client::EnvironmentLayer environment;
|
||||
evo::client::OrganismLayer population;
|
||||
@@ -287,12 +289,12 @@ int main(int argc, char** argv) try {
|
||||
form_error = material.error();
|
||||
return false;
|
||||
}
|
||||
remote = evo::client_app::RemoteSession::open(*material);
|
||||
if (!remote) {
|
||||
auto opened = evo::client_app::RemoteSession::open(*material);
|
||||
if (!opened) {
|
||||
form_error = evo::client::LaunchError::endpoint;
|
||||
return false;
|
||||
}
|
||||
return launcher.begin_connect();
|
||||
return host.connect(std::move(opened));
|
||||
}
|
||||
};
|
||||
const auto enter_fixture = [&] {
|
||||
@@ -304,7 +306,7 @@ int main(int argc, char** argv) try {
|
||||
environment.reset();
|
||||
population.reset();
|
||||
selection.clear();
|
||||
launcher.start_fixture();
|
||||
host.enter_fixture(); // Ends any remote attempt: nothing runs behind the banner.
|
||||
return true;
|
||||
};
|
||||
if (start_fixture && !enter_fixture()) {
|
||||
@@ -341,14 +343,14 @@ int main(int argc, char** argv) try {
|
||||
const auto shown_environment = [&]() -> const evo::client::EnvironmentLayer* {
|
||||
if (mode() == Mode::fixture)
|
||||
return &environment;
|
||||
if (mode() == Mode::remote && remote)
|
||||
if (const auto* remote = host.session(); remote && mode() == Mode::remote)
|
||||
return &remote->environment();
|
||||
return nullptr;
|
||||
};
|
||||
const auto shown_organisms = [&]() -> const evo::client::OrganismLayer* {
|
||||
if (mode() == Mode::fixture)
|
||||
return &population;
|
||||
if (mode() == Mode::remote && remote)
|
||||
if (const auto* remote = host.session(); remote && mode() == Mode::remote)
|
||||
return &remote->organisms();
|
||||
return nullptr;
|
||||
};
|
||||
@@ -364,7 +366,7 @@ int main(int argc, char** argv) try {
|
||||
view.organisms = shown_organisms();
|
||||
view.selection = &selection;
|
||||
view.ui = &ui;
|
||||
if (remote && view.mode == Mode::remote) {
|
||||
if (const auto* remote = host.session(); remote && view.mode == Mode::remote) {
|
||||
view.remote = remote->status();
|
||||
view.outcomes = &remote->outcomes();
|
||||
}
|
||||
@@ -394,8 +396,7 @@ int main(int argc, char** argv) try {
|
||||
selection.clear();
|
||||
}
|
||||
if (actions.cancel || actions.back) {
|
||||
remote.reset(); // Drops the connection; its unresolved outcomes are unknown.
|
||||
launcher.cancel();
|
||||
host.cancel(); // Drops the connection; its unresolved outcomes are unknown.
|
||||
selection.clear();
|
||||
}
|
||||
if (actions.ask_disconnect && !disconnect_dialog)
|
||||
@@ -406,8 +407,7 @@ int main(int argc, char** argv) try {
|
||||
if (actions.confirm_dialog && actions.confirm_dialog == disconnect_dialog &&
|
||||
ui.close_dialog(*actions.confirm_dialog)) {
|
||||
disconnect_dialog.reset();
|
||||
remote.reset();
|
||||
launcher.cancel();
|
||||
host.cancel();
|
||||
selection.clear();
|
||||
}
|
||||
if (actions.cancel_dialog && ui.close_dialog(*actions.cancel_dialog))
|
||||
@@ -422,8 +422,7 @@ int main(int argc, char** argv) try {
|
||||
const auto intention = (*app)->sample_intention(count);
|
||||
if (!intention)
|
||||
return 1;
|
||||
if (remote && launcher.phase() != evo::client::LaunchPhase::failed)
|
||||
remote->step(now, *intention, ui, launcher);
|
||||
host.step(now, *intention, ui); // Only while connecting or connected.
|
||||
// The fixture authority advances at its own cadence. Presentations refresh
|
||||
// every N authority ticks; in between the advanced watermark shows as stale.
|
||||
if (mode() == Mode::fixture && count % frames_per_authority_tick == 0) {
|
||||
|
||||
+39
-14
@@ -281,32 +281,57 @@ void session(const PanelView& v) {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// Newest at the bottom right. Each notice wraps its text beside a reserved close
|
||||
// column, so the button is always visible; the stack stops at 60 % of the viewport
|
||||
// height and counts what it could not show (those still expire or can be dismissed
|
||||
// once space frees). Notices are not the outcome record (Session panel is).
|
||||
void notices(const PanelView& v, PanelActions& a) {
|
||||
const auto& io = ImGui::GetIO();
|
||||
const float width = std::min(notice_width, io.DisplaySize.x - 16);
|
||||
const float top = io.DisplaySize.y * 0.4F;
|
||||
float y = io.DisplaySize.y - 8;
|
||||
for (const auto& n : v.ui->notices()) {
|
||||
const auto list = v.ui->notices();
|
||||
std::size_t hidden = 0;
|
||||
for (auto it = list.rbegin(); it != list.rend(); ++it) {
|
||||
const auto& n = *it;
|
||||
if (y < top || width < 120) {
|
||||
++hidden;
|
||||
continue;
|
||||
}
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, y}, ImGuiCond_Always, {1, 1});
|
||||
ImGui::SetNextWindowSize({320, 0}, ImGuiCond_Always);
|
||||
const std::string id = "##notice" + std::to_string(n.id);
|
||||
ImGui::SetNextWindowSize({width, 0}, ImGuiCond_Always);
|
||||
const std::string id = notice_window_prefix + std::to_string(n.id);
|
||||
ImGui::Begin(id.c_str(), nullptr,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
ImGui::TextColored(n.level == client::NoticeLevel::error ? red
|
||||
: n.level == client::NoticeLevel::warning ? amber
|
||||
: green,
|
||||
"%s", n.text.c_str());
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton(("x" + id).c_str()))
|
||||
a.dismiss_notice = n.id;
|
||||
if (ImGui::BeginTable("notice", 2)) {
|
||||
ImGui::TableSetupColumn("text", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("close", ImGuiTableColumnFlags_WidthFixed, notice_close_width);
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, n.level == client::NoticeLevel::error ? red
|
||||
: n.level == client::NoticeLevel::warning ? amber
|
||||
: green);
|
||||
ImGui::TextWrapped("%s", n.text.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button(("x" + id).c_str(), {notice_close_width, 0}))
|
||||
a.dismiss_notice = n.id;
|
||||
ImGui::EndTable();
|
||||
}
|
||||
y -= ImGui::GetWindowHeight() + 4;
|
||||
ImGui::End();
|
||||
}
|
||||
if (v.ui->evicted_notices() > 0) {
|
||||
if (v.ui->evicted_notices() > 0 || hidden > 0) {
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, y}, ImGuiCond_Always, {1, 1});
|
||||
ImGui::Begin("##evicted", nullptr,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::TextDisabled("%llu older notices discarded",
|
||||
static_cast<unsigned long long>(v.ui->evicted_notices()));
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
if (hidden > 0)
|
||||
ImGui::TextDisabled("%zu more notices (dismiss to show)", hidden);
|
||||
if (v.ui->evicted_notices() > 0)
|
||||
ImGui::TextDisabled("%llu older notices discarded",
|
||||
static_cast<unsigned long long>(v.ui->evicted_notices()));
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
namespace evo::client_app {
|
||||
enum class Mode : std::uint8_t { launcher, fixture, remote };
|
||||
// Notice layout (logical pixels); the window name is the prefix plus the notice id.
|
||||
inline constexpr float notice_width = 320, notice_close_width = 22;
|
||||
inline constexpr const char* notice_window_prefix = "##notice";
|
||||
// Text-field storage for the connect form (bounded; never persisted).
|
||||
struct FormBuffers {
|
||||
std::array<char, client::max_field_bytes> endpoint{}, server_name{}, authority{}, grants{};
|
||||
|
||||
@@ -96,10 +96,17 @@ if(EVO_BUILD_CLIENT)
|
||||
set_tests_properties(client-ui-model PROPERTIES TIMEOUT 60 LABELS "client")
|
||||
set_tests_properties(client-organisms PROPERTIES TIMEOUT 60 LABELS "client")
|
||||
set_tests_properties(client-environment PROPERTIES TIMEOUT 60 LABELS "client")
|
||||
# Production panels through the real adapter and toolkit (M9.8c layout/click checks).
|
||||
add_executable(evo-client-panel-tests tests/client_panels.cpp apps/evo-client/panels.cpp)
|
||||
target_include_directories(evo-client-panel-tests PRIVATE "${PROJECT_SOURCE_DIR}/apps/evo-client")
|
||||
target_link_libraries(evo-client-panel-tests PRIVATE evo_client_platform evo_client_ui SDL3::SDL3 evo_imgui)
|
||||
evo_owned_target(evo-client-panel-tests)
|
||||
evo_client_runtime(evo-client-panel-tests)
|
||||
add_test(NAME client-panels COMMAND evo-client-panel-tests)
|
||||
add_test(NAME client-lifecycle COMMAND evo-client-lifecycle-tests)
|
||||
add_test(NAME client-smoke COMMAND evo-client --renderer software --frames 3)
|
||||
add_test(NAME client-init-failure COMMAND evo-client --frames 1)
|
||||
set_tests_properties(client-lifecycle client-smoke PROPERTIES
|
||||
set_tests_properties(client-lifecycle client-panels client-smoke PROPERTIES
|
||||
ENVIRONMENT "SDL_VIDEO_DRIVER=dummy" TIMEOUT 30 LABELS "client")
|
||||
set_tests_properties(client-init-failure PROPERTIES
|
||||
ENVIRONMENT "SDL_VIDEO_DRIVER=evo-invalid" WILL_FAIL TRUE TIMEOUT 20 LABELS "client")
|
||||
|
||||
@@ -43,13 +43,13 @@ RUN cmake -P tools/prepare-sdl3.cmake \
|
||||
&& cmake -P tools/prepare-imgui.cmake \
|
||||
&& cmake --preset client-probe -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_C_COMPILER=clang-19 \
|
||||
-DEVO_BUILD_CLIENT=ON -DEVO_BUILD_UI_PROBE=ON -DEVO_ENABLE_TIDY=ON -DSDL_X11=ON -DSDL_WAYLAND=OFF \
|
||||
&& cmake --build build/client-probe --target evo-client-state-tests evo-ui-probe evo-client-probe evo-client evo-client-lifecycle-tests evo-client-environment-tests evo-client-organism-tests evo-client-ui-model-tests --parallel 2 \
|
||||
&& cmake --build build/client-probe --target evo-client-state-tests evo-ui-probe evo-client-probe evo-client evo-client-lifecycle-tests evo-client-environment-tests evo-client-organism-tests evo-client-ui-model-tests evo-client-panel-tests --parallel 2 \
|
||||
&& ctest --preset client-probe --no-tests=error \
|
||||
&& xvfb-run -a env SDL_VIDEO_DRIVER=x11 ./build/client-probe/evo-client-probe --renderer software \
|
||||
&& xvfb-run -a env SDL_VIDEO_DRIVER=x11 ./build/client-probe/evo-ui-probe --renderer software \
|
||||
&& xvfb-run -a env SDL_VIDEO_DRIVER=x11 ./build/client-probe/evo-client-lifecycle-tests \
|
||||
&& cmake --preset client-probe -DEVO_BUILD_CLIENT=ON -DEVO_SANITIZER=address -DEVO_ENABLE_TIDY=OFF \
|
||||
&& cmake --build build/client-probe --target evo-client-state-tests evo-ui-probe evo-client evo-client-lifecycle-tests evo-client-environment-tests evo-client-organism-tests evo-client-ui-model-tests --parallel 2 \
|
||||
&& cmake --build build/client-probe --target evo-client-state-tests evo-ui-probe evo-client evo-client-lifecycle-tests evo-client-environment-tests evo-client-organism-tests evo-client-ui-model-tests evo-client-panel-tests --parallel 2 \
|
||||
&& ctest --preset client-probe --no-tests=error \
|
||||
&& xvfb-run -a env SDL_VIDEO_DRIVER=x11 ./build/client-probe/evo-ui-probe --renderer software \
|
||||
&& xvfb-run -a env SDL_VIDEO_DRIVER=x11 ./build/client-probe/evo-client-lifecycle-tests
|
||||
|
||||
@@ -107,3 +107,11 @@ path, certificate or grant byte is displayed, logged or saved.
|
||||
`SessionClient::unreachable_attempts()` (additive API) counts connection attempts
|
||||
that fail before any session event, so the launcher bounds "unreachable" without
|
||||
an event per retry. No wire format, grant or biological rule changes.
|
||||
|
||||
M9.8c review corrections: the adapter reads the pinned toolkit's internal window
|
||||
list (`imgui_internal.h`: active, unhidden windows' clipped rectangles and the open
|
||||
popup stack) to decide pointer ownership per SDL event; `WantCaptureMouse` alone is
|
||||
one frame late for same-batch input. This internal use is tied to the 1.92.9b pin
|
||||
and must be rechecked on any toolkit update (the lifecycle and panel tests fail if
|
||||
it regresses). External capture no longer cancels the Tab toggle. Mode and remote
|
||||
session lifetime are owned together (`SessionHost`).
|
||||
|
||||
@@ -58,8 +58,10 @@ click without dragging selects the topmost organism, else the habitat cell, for
|
||||
Inspector; a click that lands on a panel or dismisses a notification never selects
|
||||
through it. Toolkit events are processed first: while a text field is focused or
|
||||
the pointer is over a panel, keys/wheel/clicks do not reach the world. Tab toggles
|
||||
UI capture: the bottom-left bar turns orange and navigation/movement input is
|
||||
suppressed. Leaving capture/focus loss requires fresh presses. The host's input
|
||||
UI capture (fixture or remote view): the bottom-left bar turns orange and
|
||||
navigation/movement input is suppressed until Tab is pressed again. Leaving
|
||||
capture/focus loss requires fresh presses. Choosing Local fixture ends any remote
|
||||
attempt; nothing connects or sends behind the LOCAL FIXTURE banner. The host's input
|
||||
tick is a local fixture counter and is never interpreted as authoritative server
|
||||
time. The top-right chips show environment then organism freshness (green current,
|
||||
amber stale, red none; magenta marker: organisms truncated); the Legend panel
|
||||
|
||||
@@ -43,10 +43,30 @@ Toolkit-independent models (src/client/ui, tested by `client-ui-model`):
|
||||
admitted, rejected, durable, not committed or unknown. It is the visible record;
|
||||
notifications are not.
|
||||
|
||||
Native adapter (`Application`): toolkit events are processed first; while the
|
||||
toolkit wants the keyboard or pointer, keys, wheel and clicks do not reach world
|
||||
input. A click is a left press and release within 4 pixels that began outside any
|
||||
panel. Capture changes from toolkit focus release world actions and require fresh
|
||||
presses; the Tab toggle keeps its earlier ordering. The overlay callback runs after
|
||||
Native adapter (`Application`): toolkit events are processed first. Keyboard focus
|
||||
in a widget (reported by the toolkit's last frame) captures world keys. Pointer
|
||||
ownership is resolved per event against the panel rectangles retained from the
|
||||
last frame (and any open popup), so a move onto a panel followed by a press or wheel
|
||||
in the same SDL batch never reaches the world; a press that begins on a panel owns
|
||||
the button until release. After a press on a panel, world key-downs in the same
|
||||
batch are dropped (releases still pass) because that press may focus a text field
|
||||
before the toolkit can report it; those keys need a fresh press. A click is a left
|
||||
press and release within 4 pixels, both outside any panel. Capture changes from
|
||||
toolkit focus release world actions and require fresh presses. External capture
|
||||
(launcher, modal) and the Tab toggle are independent: Tab is ignored while external
|
||||
capture holds, and an external release (sent every host frame outside a modal) does
|
||||
not cancel the toggle. The overlay callback runs after
|
||||
world drawing; `request_screenshot` saves the next frame as BMP (engineering review).
|
||||
Toolkit settings files and logs are disabled (`IniFilename`/`LogFilename` null).
|
||||
|
||||
Host ownership (`session_host.hpp`): the launcher phase and the remote session
|
||||
change together. Entering the local fixture, Cancel, Disconnect or a launcher
|
||||
failure drops the session at once (unresolved intentions become unknown); the
|
||||
session is serviced, and intentions sent, only while connecting or connected, so
|
||||
nothing runs behind a LOCAL FIXTURE banner. Retry opens a new session.
|
||||
|
||||
Notices (app panels): newest at the bottom right, at most 320 logical pixels wide
|
||||
(narrower viewports shrink them), text wrapped beside a reserved close column. The
|
||||
stack stops at 60 % of the viewport height and shows how many notices are not drawn
|
||||
and how many were discarded. `client-panels` renders the production panels through
|
||||
the adapter and checks notice geometry and close-button dismissal.
|
||||
|
||||
@@ -3715,3 +3715,44 @@ screen reader or accessibility review; the remote review used one connect withou
|
||||
WASD intentions, so the outcome list was empty in the screenshot (outcome states are
|
||||
covered by unit tests). No Docker/Gitea run, packaging, deployment or cluster test.
|
||||
No simulation version, wire format or golden changed.
|
||||
|
||||
|
||||
## 2026-10-02 — M9.8c review corrections (.cache/reviews/m98c-review.md)
|
||||
|
||||
1. Same-batch panel input: pointer ownership is now resolved per SDL event from the
|
||||
toolkit's retained window rectangles/popup stack (pinned internal API, ADR-0084);
|
||||
a press on a panel owns the button until release and drops world key-downs for
|
||||
the rest of that batch. Regressions without settling frames: world->panel move +
|
||||
press/release (no world click, button still activates), move + wheel (no zoom;
|
||||
world wheel still zooms), click-to-focus + W in one batch (no movement; field
|
||||
captures; fresh press after unfocus moves).
|
||||
2. Fixture/live distinction: `SessionHost` owns launcher phase and remote session;
|
||||
fixture, cancel, disconnect and failure drop the session; it is serviced only
|
||||
while connecting/connected. `client-ui-model` uses a fake session/server:
|
||||
connecting->fixture and failed->fixture followed by an available server produce
|
||||
no steps, Welcome (grant use) or intentions; ordinary connect still works.
|
||||
3. Tab capture: an external release no longer cancels it. Regression drives the
|
||||
host order (poll, set_ui_capture(false), sample, present) over several frames,
|
||||
requires capture until the second toggle and a fresh, non-repeat press after.
|
||||
4. Notices: wrapped text beside a reserved 22-pixel close column, width min(320,
|
||||
viewport-16), stack bounded to 60 % of the height with a not-shown/discarded
|
||||
count. New `client-panels` renders the production panels through the adapter:
|
||||
the three real session notices and a 240-byte message fit (content width and no
|
||||
horizontal scroll), the close button clicked in one batch dismisses exactly that
|
||||
notice with no world click; a full stack stays on screen.
|
||||
|
||||
Negative checks: the new lifecycle test fails against the previous adapter (same-
|
||||
batch click), the panel test against the previous notice layout (content width),
|
||||
and the host-order Tab test with the former clearing restored (Windows MSVC).
|
||||
A GCC-only failure in the new fake-session test was a test bug (by-value argument
|
||||
alive until the full expression ends); split the assertion.
|
||||
|
||||
Executed: Windows MSVC client 8/8 and client-network 9/9 (final). Linux: clang-19
|
||||
client-probe build with clang-tidy enabled (keep-going, no owned diagnostics) and
|
||||
CTest 12/12; Xvfb/X11 lifecycle and panel tests; Clang ASan/UBSan client CTest 12/12
|
||||
and Xvfb lifecycle/panels; GCC 14 client-network build, client|network CTest 9/9;
|
||||
clang-tidy on app main/panels (client-network); repository format check. Visual:
|
||||
live WSL dev region showing the wrapped connection notice with its close button.
|
||||
|
||||
Limits unchanged: no physical mouse/keyboard session, DPI or accessibility review;
|
||||
the live screenshot sent no intentions. No Docker/Gitea, packaging or deployment.
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
// M9.8c host-side ownership of the launcher phase together with the remote session,
|
||||
// so the visible mode and the session lifetime cannot diverge (ADR-0084). Entering the
|
||||
// local fixture, cancelling or failing drops the session at once: no retries, grant use
|
||||
// or intentions continue behind a LOCAL FIXTURE banner. Dropping a session leaves its
|
||||
// unresolved intentions unknown. `Session` provides
|
||||
// step(time_point, const Intention&, UiState&, Launcher&).
|
||||
#include "evo/client/input.hpp"
|
||||
#include "evo/client/launcher.hpp"
|
||||
#include "evo/client/ui_state.hpp"
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
namespace evo::client {
|
||||
template <class Session> class SessionHost {
|
||||
public:
|
||||
[[nodiscard]] const Launcher& launcher() const noexcept {
|
||||
return launcher_;
|
||||
}
|
||||
[[nodiscard]] Session* session() noexcept {
|
||||
return session_ ? &*session_ : nullptr;
|
||||
}
|
||||
[[nodiscard]] const Session* session() const noexcept {
|
||||
return session_ ? &*session_ : nullptr;
|
||||
}
|
||||
// Adopts a freshly opened session (from choosing or failed). Any previous session
|
||||
// is dropped first; on refusal no session remains.
|
||||
[[nodiscard]] bool connect(std::optional<Session> opened) {
|
||||
session_.reset();
|
||||
if (!opened || !launcher_.begin_connect())
|
||||
return false;
|
||||
session_.emplace(std::move(*opened));
|
||||
return true;
|
||||
}
|
||||
void enter_fixture() noexcept {
|
||||
session_.reset();
|
||||
launcher_.start_fixture();
|
||||
}
|
||||
void cancel() noexcept {
|
||||
session_.reset();
|
||||
launcher_.cancel();
|
||||
}
|
||||
// Services the session only while connecting or connected; a failure observed
|
||||
// during the step ends it immediately (Retry opens a new one).
|
||||
void step(std::chrono::steady_clock::time_point now, const Intention& intention, UiState& ui) {
|
||||
if (session_ && live())
|
||||
session_->step(now, intention, ui, launcher_);
|
||||
if (!live())
|
||||
session_.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool live() const noexcept {
|
||||
return launcher_.phase() == LaunchPhase::connecting ||
|
||||
launcher_.phase() == LaunchPhase::connected;
|
||||
}
|
||||
Launcher launcher_;
|
||||
std::optional<Session> session_;
|
||||
};
|
||||
} // namespace evo::client
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_sdl3.h>
|
||||
#include <imgui_impl_sdlrenderer3.h>
|
||||
#include <imgui_internal.h> // Pinned 1.92.9b: last-frame window rectangles (ADR-0084).
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
@@ -70,6 +71,19 @@ struct Toolkit {
|
||||
}
|
||||
};
|
||||
constexpr float click_slop = 4; // Logical units between press and release.
|
||||
// True when `at` lies on a toolkit window drawn in the last frame or any popup is open.
|
||||
// Resolved per event from the toolkit's retained window rectangles, so a move onto a
|
||||
// panel followed by a press in the same batch belongs to the panel, not the world.
|
||||
bool toolkit_window_at(float x, float y) {
|
||||
const ImGuiContext& g = *ImGui::GetCurrentContext();
|
||||
if (g.OpenPopupStack.Size > 0)
|
||||
return true;
|
||||
for (const ImGuiWindow* w : g.Windows)
|
||||
if (w->Active && !w->Hidden && (w->Flags & ImGuiWindowFlags_NoMouseInputs) == 0 &&
|
||||
w->OuterRectClipped.Contains(ImVec2{x, y}))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
struct Runtime {
|
||||
bool acquired{false};
|
||||
~Runtime() {
|
||||
@@ -96,6 +110,7 @@ struct Application::Impl {
|
||||
bool external_capture{false}, tab_capture{false}, toolkit_capture{false};
|
||||
bool toolkit_pointer{false};
|
||||
std::optional<SDL_FPoint> press; // Primary press not taken by the toolkit.
|
||||
bool ui_press{false}; // Primary press owned by the toolkit, until release.
|
||||
std::string screenshot;
|
||||
|
||||
// `drain`: input may have queued while an external UI or toolkit widget held it, so
|
||||
@@ -136,9 +151,9 @@ WindowState Application::state() const noexcept {
|
||||
return result;
|
||||
}
|
||||
void Application::set_ui_capture(bool captured) noexcept {
|
||||
// Independent of the legacy Tab toggle: an idempotent release (every host frame
|
||||
// outside a modal) must not cancel it; Tab is ignored while external capture holds.
|
||||
impl_->external_capture = captured;
|
||||
if (!captured)
|
||||
impl_->tab_capture = false; // An external release also ends the legacy toggle.
|
||||
impl_->update_capture();
|
||||
}
|
||||
void Application::set_overlay(Overlay overlay) {
|
||||
@@ -208,13 +223,16 @@ std::expected<void, Error> Application::poll_events() {
|
||||
return {};
|
||||
p.input.admit(p.state.accepts_input() && !p.backlogged);
|
||||
const auto id = SDL_GetWindowID(p.window.get());
|
||||
// The toolkit's wishes from its last frame decide this batch: keyboard focus in a
|
||||
// widget captures world keys; a pointer over UI cannot click, pan or zoom the world.
|
||||
// Keyboard focus in a widget (reported by the toolkit's last frame) captures world
|
||||
// keys. Pointer ownership is resolved per event below from the panel rectangles.
|
||||
const auto& io = ImGui::GetIO();
|
||||
p.toolkit_capture = io.WantCaptureKeyboard;
|
||||
p.toolkit_pointer = io.WantCaptureMouse;
|
||||
p.update_capture();
|
||||
bool reset = false;
|
||||
// A press on a panel in this batch may focus a text field before the toolkit's next
|
||||
// frame can report it: world key-downs after it wait for that frame (releases pass).
|
||||
bool ui_pressed = false;
|
||||
SDL_Event event{};
|
||||
int count = 0;
|
||||
for (; count < 256 && SDL_PollEvent(&event); ++count) {
|
||||
@@ -253,16 +271,20 @@ std::expected<void, Error> Application::poll_events() {
|
||||
}
|
||||
// Admission changes clear held inputs immediately, even if focus returns in this batch.
|
||||
p.input.admit(p.state.accepts_input() && !p.backlogged);
|
||||
if (!p.state.accepts_input()) {
|
||||
p.press.reset(); // A release may never arrive for this window.
|
||||
p.ui_press = false;
|
||||
}
|
||||
if ((event.type == SDL_EVENT_KEY_DOWN || event.type == SDL_EVENT_KEY_UP) &&
|
||||
event.key.windowID == id) {
|
||||
const bool down = event.type == SDL_EVENT_KEY_DOWN;
|
||||
if (event.key.scancode == SDL_SCANCODE_TAB && down && !event.key.repeat &&
|
||||
p.state.accepts_input() && !p.backlogged && !p.external_capture &&
|
||||
!p.toolkit_capture) {
|
||||
!p.toolkit_capture && !ui_pressed) {
|
||||
p.tab_capture = !p.tab_capture;
|
||||
p.update_capture(false);
|
||||
}
|
||||
if (const auto key = input_key(event.key.scancode)) {
|
||||
if (const auto key = input_key(event.key.scancode); key && (!down || !ui_pressed)) {
|
||||
if (auto result = p.input.key(*key, down, event.key.repeat); !result)
|
||||
p.input.admit(false);
|
||||
}
|
||||
@@ -272,21 +294,27 @@ std::expected<void, Error> Application::poll_events() {
|
||||
p.input.admit(false);
|
||||
}
|
||||
if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN && event.button.windowID == id &&
|
||||
event.button.button == SDL_BUTTON_LEFT)
|
||||
p.press = p.toolkit_pointer || p.input.captured()
|
||||
event.button.button == SDL_BUTTON_LEFT) {
|
||||
p.ui_press = toolkit_window_at(event.button.x, event.button.y);
|
||||
ui_pressed = ui_pressed || p.ui_press;
|
||||
p.press = p.ui_press || p.input.captured()
|
||||
? std::nullopt
|
||||
: std::optional<SDL_FPoint>{{event.button.x, event.button.y}};
|
||||
}
|
||||
if (event.type == SDL_EVENT_MOUSE_BUTTON_UP && event.button.windowID == id &&
|
||||
event.button.button == SDL_BUTTON_LEFT) {
|
||||
// A click that operated a widget (pressed over UI) never selects through it.
|
||||
// A click that operated a widget (pressed over UI) never selects through it,
|
||||
// nor does a release over UI that appeared while the button was held.
|
||||
if (p.press && std::abs(event.button.x - p.press->x) <= click_slop &&
|
||||
std::abs(event.button.y - p.press->y) <= click_slop && !p.toolkit_pointer &&
|
||||
std::abs(event.button.y - p.press->y) <= click_slop &&
|
||||
!toolkit_window_at(event.button.x, event.button.y) &&
|
||||
!p.input.click({event.button.x, event.button.y}))
|
||||
p.input.admit(false);
|
||||
p.press.reset();
|
||||
p.ui_press = false;
|
||||
}
|
||||
if (event.type == SDL_EVENT_MOUSE_WHEEL && event.wheel.windowID == id &&
|
||||
!p.toolkit_pointer) {
|
||||
if (event.type == SDL_EVENT_MOUSE_WHEEL && event.wheel.windowID == id && !p.ui_press &&
|
||||
!toolkit_window_at(event.wheel.mouse_x, event.wheel.mouse_y)) {
|
||||
const double direction = event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -1 : 1;
|
||||
if (!p.input.pointer({event.wheel.mouse_x, event.wheel.mouse_y}) ||
|
||||
!p.input.wheel(event.wheel.y * direction))
|
||||
|
||||
@@ -261,13 +261,17 @@ void toolkit_capture() {
|
||||
send(SDL_EVENT_WINDOW_FOCUS_GAINED, id);
|
||||
int presses = 0;
|
||||
bool text_focus = false;
|
||||
std::array<char, 32> text{};
|
||||
std::array<char, 32> text{}, field{};
|
||||
ImVec2 field_min{}, field_max{};
|
||||
app->set_overlay([&] {
|
||||
ImGui::SetNextWindowPos({0, 0}, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({150, 150}, ImGuiCond_Always);
|
||||
ImGui::Begin("panel", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
|
||||
if (ImGui::Button("Press", {130, 40}))
|
||||
++presses;
|
||||
ImGui::InputText("field", field.data(), field.size());
|
||||
field_min = ImGui::GetItemRectMin();
|
||||
field_max = ImGui::GetItemRectMax();
|
||||
if (text_focus) {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
ImGui::InputText("name", text.data(), text.size());
|
||||
@@ -314,12 +318,45 @@ void toolkit_capture() {
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_DOWN, 260, 200);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_UP, 290, 200);
|
||||
CHECK(app->poll_events() && !app->take_navigation().click);
|
||||
// Same batch, no settling frame: the pointer was last over the world, then moves
|
||||
// onto the panel and clicks. Ownership is resolved per event, so the world sees
|
||||
// nothing and the widget still activates on the toolkit's next frames.
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, 260, 200);
|
||||
CHECK(app->poll_events() && app->present(frame) == Step::rendered && !app->ui_wants_pointer());
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, 60, 30);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_DOWN, 60, 30);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_UP, 60, 30);
|
||||
CHECK(app->poll_events() && !app->take_navigation().click);
|
||||
for (int i = 0; i < 5 && presses == 1; ++i)
|
||||
CHECK(app->present(frame) == Step::rendered && app->poll_events());
|
||||
CHECK(presses == 2 && !app->take_navigation().click);
|
||||
// Same for the wheel: moving onto the panel and scrolling never zooms the world.
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, 260, 200);
|
||||
CHECK(app->poll_events() && app->present(frame) == Step::rendered);
|
||||
SDL_Event wheel{};
|
||||
wheel.type = SDL_EVENT_MOUSE_WHEEL;
|
||||
wheel.wheel.windowID = id;
|
||||
wheel.wheel.y = 3;
|
||||
wheel.wheel.mouse_x = 60;
|
||||
wheel.wheel.mouse_y = 30;
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, 60, 30);
|
||||
CHECK(SDL_PushEvent(&wheel));
|
||||
CHECK(app->poll_events() && app->take_navigation().wheel == 0);
|
||||
CHECK(app->present(frame) == Step::rendered);
|
||||
// ...while the same wheel over the world still zooms.
|
||||
wheel.wheel.mouse_x = 260;
|
||||
wheel.wheel.mouse_y = 200;
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, 260, 200);
|
||||
CHECK(SDL_PushEvent(&wheel));
|
||||
CHECK(app->poll_events() && app->take_navigation().wheel == 3);
|
||||
CHECK(app->present(frame) == Step::rendered);
|
||||
|
||||
auto key = [id](SDL_Scancode scancode, bool down) {
|
||||
auto key = [id](SDL_Scancode scancode, bool down, bool repeat = false) {
|
||||
SDL_Event event{};
|
||||
event.type = down ? SDL_EVENT_KEY_DOWN : SDL_EVENT_KEY_UP;
|
||||
event.key.windowID = id;
|
||||
event.key.scancode = scancode;
|
||||
event.key.repeat = repeat;
|
||||
CHECK(SDL_PushEvent(&event));
|
||||
};
|
||||
key(SDL_SCANCODE_W, true);
|
||||
@@ -342,6 +379,56 @@ void toolkit_capture() {
|
||||
CHECK(app->poll_events());
|
||||
key(SDL_SCANCODE_W, true);
|
||||
CHECK(app->poll_events() && required(app->sample_intention(103)).move_y == 1000);
|
||||
key(SDL_SCANCODE_W, false);
|
||||
CHECK(app->poll_events() && required(app->sample_intention(104)).move_y == 0);
|
||||
// Click-to-focus and typing in one batch: the field is not yet reported focused,
|
||||
// yet keys after a press on the panel never move the world.
|
||||
const float fx = (field_min.x + field_max.x) / 2, fy = (field_min.y + field_max.y) / 2;
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, fx, fy);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_DOWN, fx, fy);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_UP, fx, fy);
|
||||
key(SDL_SCANCODE_W, true);
|
||||
CHECK(app->poll_events() && !app->take_navigation().click);
|
||||
CHECK(required(app->sample_intention(105)).move_y == 0);
|
||||
for (int i = 0; i < 5 && !app->ui_captured(); ++i)
|
||||
CHECK(app->present(frame) == Step::rendered && app->poll_events());
|
||||
CHECK(app->ui_captured() && required(app->sample_intention(106)).move_y == 0);
|
||||
// A world click unfocuses the field; capture releases and fresh presses move again.
|
||||
mouse(SDL_EVENT_MOUSE_MOTION, 260, 200);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_DOWN, 260, 200);
|
||||
mouse(SDL_EVENT_MOUSE_BUTTON_UP, 260, 200);
|
||||
CHECK(app->poll_events());
|
||||
for (int i = 0; i < 5 && app->ui_captured(); ++i)
|
||||
CHECK(app->present(frame) == Step::rendered && app->poll_events());
|
||||
CHECK(!app->ui_captured());
|
||||
static_cast<void>(app->take_navigation());
|
||||
CHECK(app->poll_events());
|
||||
key(SDL_SCANCODE_W, true);
|
||||
CHECK(app->poll_events() && required(app->sample_intention(107)).move_y == 1000);
|
||||
key(SDL_SCANCODE_W, false);
|
||||
CHECK(app->poll_events());
|
||||
// Host order (main loop): poll -> set_ui_capture(false) outside modals -> sample ->
|
||||
// present. The idempotent external release must not cancel the Tab toggle.
|
||||
const auto host_frame = [&](std::uint64_t tick) {
|
||||
CHECK(app->poll_events());
|
||||
app->set_ui_capture(false);
|
||||
const auto intention = required(app->sample_intention(tick));
|
||||
CHECK(app->present(frame) == Step::rendered);
|
||||
return intention;
|
||||
};
|
||||
key(SDL_SCANCODE_TAB, true);
|
||||
key(SDL_SCANCODE_TAB, false);
|
||||
CHECK(host_frame(110).move_y == 0 && app->ui_captured());
|
||||
for (std::uint64_t tick = 111; tick < 115; ++tick) {
|
||||
key(SDL_SCANCODE_W, true);
|
||||
CHECK(host_frame(tick).move_y == 0 && app->ui_captured());
|
||||
}
|
||||
key(SDL_SCANCODE_TAB, true); // Second deliberate toggle; W stays held physically.
|
||||
CHECK(host_frame(115).move_y == 0 && !app->ui_captured());
|
||||
key(SDL_SCANCODE_W, true, true); // A repeat is not a fresh press.
|
||||
CHECK(host_frame(116).move_y == 0);
|
||||
key(SDL_SCANCODE_W, true);
|
||||
CHECK(host_frame(117).move_y == 1000);
|
||||
// Screenshot hook writes the composed frame (engineering visual review).
|
||||
const auto shot = std::filesystem::temp_directory_path() / "evo-toolkit-capture.bmp";
|
||||
CHECK(app->request_screenshot(shot.string()) && app->present(frame) == Step::rendered);
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
// M9.8c: the production engineering panels through the real adapter (dummy driver,
|
||||
// software renderer, pinned toolkit). Notices fit their fixed-width window with a
|
||||
// visible close button; clicking it (move + press + release in one batch, no settling
|
||||
// frame) dismisses exactly that notice and never reaches the world.
|
||||
#include "evo/client/application.hpp"
|
||||
#include "panels.hpp"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <source_location>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
using namespace evo;
|
||||
using namespace evo::client;
|
||||
using namespace evo::client_app;
|
||||
void check(bool ok, std::source_location at = std::source_location::current()) {
|
||||
if (!ok)
|
||||
throw std::runtime_error("client panels line " + std::to_string(at.line()));
|
||||
}
|
||||
#define CHECK(...) check(static_cast<bool>(__VA_ARGS__))
|
||||
SDL_Window* window() {
|
||||
int count{};
|
||||
SDL_Window** windows = SDL_GetWindows(&count);
|
||||
SDL_Window* result = count == 1 ? windows[0] : nullptr;
|
||||
SDL_free(static_cast<void*>(windows));
|
||||
CHECK(result);
|
||||
return result;
|
||||
}
|
||||
void mouse(SDL_WindowID id, SDL_EventType type, float x, float y) {
|
||||
SDL_Event event{};
|
||||
event.type = type;
|
||||
if (type == SDL_EVENT_MOUSE_MOTION) {
|
||||
event.motion.windowID = id;
|
||||
event.motion.x = x;
|
||||
event.motion.y = y;
|
||||
} else {
|
||||
event.button.windowID = id;
|
||||
event.button.button = SDL_BUTTON_LEFT;
|
||||
event.button.down = type == SDL_EVENT_MOUSE_BUTTON_DOWN;
|
||||
event.button.clicks = 1;
|
||||
event.button.x = x;
|
||||
event.button.y = y;
|
||||
}
|
||||
CHECK(SDL_PushEvent(&event));
|
||||
}
|
||||
ImGuiWindow* notice_window(std::uint64_t id) {
|
||||
return ImGui::FindWindowByName((notice_window_prefix + std::to_string(id)).c_str());
|
||||
}
|
||||
|
||||
void notices() {
|
||||
const std::array<render::Rectangle, 1> boxes{{{0, 0, 32, 32, {40, 40, 40, 255}}}};
|
||||
auto frame = render::Frame::create(boxes);
|
||||
CHECK(frame);
|
||||
auto opened = Application::open({960, 640, false, "software"});
|
||||
CHECK(opened);
|
||||
auto app = std::move(*opened);
|
||||
const auto id = SDL_GetWindowID(window());
|
||||
SDL_Event focus{};
|
||||
focus.type = SDL_EVENT_WINDOW_FOCUS_GAINED;
|
||||
focus.window.windowID = id;
|
||||
CHECK(SDL_PushEvent(&focus) && app->poll_events());
|
||||
|
||||
UiState ui;
|
||||
EnvironmentLayer environment;
|
||||
OrganismLayer organisms;
|
||||
Selection selection;
|
||||
Launcher launcher;
|
||||
FormBuffers form;
|
||||
render::EnvironmentDisplay display;
|
||||
PanelView view;
|
||||
view.mode = Mode::fixture;
|
||||
view.launcher = &launcher;
|
||||
view.environment = &environment;
|
||||
view.organisms = &organisms;
|
||||
view.selection = &selection;
|
||||
view.ui = &ui;
|
||||
std::optional<std::uint64_t> dismissed;
|
||||
app->set_overlay([&] {
|
||||
if (const auto a = draw_panels(view, form, display); a.dismiss_notice)
|
||||
dismissed = a.dismiss_notice;
|
||||
});
|
||||
// The application's real notices plus a maximal 240-byte message of wide glyphs.
|
||||
const std::string longest(UiState::max_text, 'W');
|
||||
std::vector<std::uint64_t> ids;
|
||||
for (const auto* text :
|
||||
{"Connected to the dev region (fresh baseline).", "Connection lost; views are stale.",
|
||||
"Session event backlog; reconnecting after draining.", longest.c_str()}) {
|
||||
const auto made = ui.notify(text, NoticeLevel::warning, 600000);
|
||||
CHECK(made);
|
||||
ids.push_back(*made);
|
||||
}
|
||||
for (int i = 0; i < 2; ++i)
|
||||
CHECK(app->poll_events() && app->present(*frame) == Step::rendered);
|
||||
const auto& style = ImGui::GetStyle();
|
||||
for (const auto n : ids) {
|
||||
const auto* w = notice_window(n);
|
||||
CHECK(w != nullptr && w->Active);
|
||||
// Nothing wider than the window: no clipped text, no horizontal scrolling.
|
||||
CHECK(w->ContentSize.x <= w->Size.x - (2 * style.WindowPadding.x) + 0.5F);
|
||||
CHECK(w->ScrollMax.x == 0 && w->Pos.x >= 0 && w->Pos.x + w->Size.x <= 960);
|
||||
CHECK(w->Pos.y >= 0 && w->Pos.y + w->Size.y <= 640);
|
||||
}
|
||||
// Close the longest notice: pointer last over the world, then one batch.
|
||||
const auto* target = notice_window(ids.back());
|
||||
const float x = target->Pos.x + target->Size.x - style.WindowPadding.x - style.CellPadding.x -
|
||||
(notice_close_width / 2);
|
||||
const float y = target->Pos.y + style.WindowPadding.y + style.CellPadding.y +
|
||||
style.FramePadding.y + (ImGui::GetFontSize() / 2);
|
||||
mouse(id, SDL_EVENT_MOUSE_MOTION, 480, 320);
|
||||
CHECK(app->poll_events() && app->present(*frame) == Step::rendered);
|
||||
static_cast<void>(app->take_navigation());
|
||||
mouse(id, SDL_EVENT_MOUSE_MOTION, x, y);
|
||||
mouse(id, SDL_EVENT_MOUSE_BUTTON_DOWN, x, y);
|
||||
mouse(id, SDL_EVENT_MOUSE_BUTTON_UP, x, y);
|
||||
CHECK(app->poll_events() && !app->take_navigation().click);
|
||||
for (int i = 0; i < 5 && !dismissed; ++i)
|
||||
CHECK(app->present(*frame) == Step::rendered && app->poll_events());
|
||||
CHECK(dismissed == ids.back() && ui.dismiss(*dismissed) && ui.notices().size() == 3);
|
||||
CHECK(!app->take_navigation().click);
|
||||
CHECK(app->present(*frame) == Step::rendered && app->poll_events());
|
||||
const auto* gone = notice_window(ids.back());
|
||||
CHECK(gone == nullptr || !gone->Active);
|
||||
for (std::size_t k = 0; k + 1 < ids.size(); ++k)
|
||||
CHECK(notice_window(ids[k])->Active);
|
||||
// A full stack stays inside the lower part of the viewport and counts the rest.
|
||||
for (int k = 0; k < 8; ++k)
|
||||
CHECK(ui.notify(longest, NoticeLevel::info, 600000));
|
||||
for (int i = 0; i < 2; ++i)
|
||||
CHECK(app->present(*frame) == Step::rendered && app->poll_events());
|
||||
for (const auto& n : ui.notices())
|
||||
if (const auto* w = notice_window(n.id); w != nullptr && w->Active)
|
||||
CHECK(w->Pos.y >= 0 && w->Pos.y + w->Size.y <= 640);
|
||||
const auto* more = ImGui::FindWindowByName("##evicted");
|
||||
CHECK(more != nullptr && more->Active && more->Pos.y >= 0);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() try {
|
||||
notices();
|
||||
std::puts("client panel tests passed");
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "%s: %s\n", e.what(), SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "evo/client/launcher.hpp"
|
||||
#include "evo/client/outcome_log.hpp"
|
||||
#include "evo/client/selection.hpp"
|
||||
#include "evo/client/session_host.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <source_location>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
@@ -244,6 +246,88 @@ void outcome_log() {
|
||||
log.evicted() == 201 - OutcomeLog::capacity);
|
||||
CHECK(log.entries().back().sequence == 201);
|
||||
}
|
||||
// Host/session boundary: the visible mode and the session lifetime change together.
|
||||
struct Server {
|
||||
bool available{};
|
||||
int steps{}, welcomes{}, intentions{}, alive{};
|
||||
};
|
||||
class FakeSession {
|
||||
public:
|
||||
explicit FakeSession(Server& server) : server_{&server} {
|
||||
++server_->alive;
|
||||
}
|
||||
FakeSession(FakeSession&& other) noexcept : server_{std::exchange(other.server_, nullptr)} {}
|
||||
FakeSession& operator=(FakeSession&&) = delete;
|
||||
FakeSession(const FakeSession&) = delete;
|
||||
FakeSession& operator=(const FakeSession&) = delete;
|
||||
~FakeSession() {
|
||||
if (server_ != nullptr)
|
||||
--server_->alive;
|
||||
}
|
||||
void step(std::chrono::steady_clock::time_point, const Intention& intention, UiState&,
|
||||
Launcher& launcher) {
|
||||
++server_->steps;
|
||||
if (!server_->available) {
|
||||
launcher.observe(ConnectSignal::lost);
|
||||
return;
|
||||
}
|
||||
if (!welcomed_) {
|
||||
welcomed_ = true;
|
||||
++server_->welcomes; // Spends a grant.
|
||||
launcher.observe(ConnectSignal::welcome);
|
||||
}
|
||||
if (intention.move_x != 0 || intention.move_y != 0)
|
||||
++server_->intentions;
|
||||
}
|
||||
|
||||
private:
|
||||
Server* server_;
|
||||
bool welcomed_{};
|
||||
};
|
||||
void session_host() {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
UiState ui;
|
||||
const Intention move{1, 0, 1000, 0};
|
||||
Server server;
|
||||
SessionHost<FakeSession> host;
|
||||
CHECK(!host.connect(std::nullopt) && host.session() == nullptr);
|
||||
// Connecting -> Local fixture: the attempt ends; a later server sees nothing.
|
||||
CHECK(host.connect(FakeSession{server}) && server.alive == 1);
|
||||
host.step(now, move, ui);
|
||||
CHECK(server.steps == 1 && host.launcher().phase() == LaunchPhase::connecting);
|
||||
host.enter_fixture();
|
||||
CHECK(server.alive == 0 && host.launcher().phase() == LaunchPhase::fixture);
|
||||
server.available = true;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
host.step(now, move, ui);
|
||||
CHECK(server.steps == 1 && server.welcomes == 0 && server.intentions == 0);
|
||||
// Failed -> Local fixture: the failure already dropped the session.
|
||||
host.cancel();
|
||||
server.available = false;
|
||||
CHECK(host.connect(FakeSession{server}));
|
||||
for (int i = 0; i < Launcher::max_attempts_without_welcome; ++i)
|
||||
host.step(now, move, ui);
|
||||
CHECK(host.launcher().phase() == LaunchPhase::failed && server.alive == 0);
|
||||
host.enter_fixture();
|
||||
server.available = true;
|
||||
host.step(now, move, ui);
|
||||
CHECK(server.welcomes == 0 && server.intentions == 0 && host.session() == nullptr);
|
||||
// Ordinary live use still works, and Cancel ends it.
|
||||
host.cancel();
|
||||
CHECK(host.connect(FakeSession{server}));
|
||||
host.step(now, move, ui);
|
||||
CHECK(host.launcher().phase() == LaunchPhase::connected && server.welcomes == 1 &&
|
||||
server.intentions == 1);
|
||||
host.cancel();
|
||||
host.step(now, move, ui);
|
||||
CHECK(server.alive == 0 && server.intentions == 1 &&
|
||||
host.launcher().phase() == LaunchPhase::choosing);
|
||||
// Connect is refused outside choosing/failed and leaves no session behind.
|
||||
host.enter_fixture();
|
||||
// (Separate statements: the by-value argument may live until the full expression ends.)
|
||||
CHECK(!host.connect(FakeSession{server}));
|
||||
CHECK(server.alive == 0 && host.session() == nullptr);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() try {
|
||||
@@ -251,6 +335,7 @@ int main() try {
|
||||
selection();
|
||||
launcher();
|
||||
outcome_log();
|
||||
session_host();
|
||||
std::puts("client UI model tests passed");
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
|
||||
Reference in New Issue
Block a user