Skip to content

Preserve mouse capture per pointer - #114

Open
tryk016 wants to merge 2 commits into
Try:masterfrom
tryk016:codex/pr-tempest-multitouch-capture
Open

tryk016 wants to merge 2 commits into
Try:masterfrom
tryk016:codex/pr-tempest-multitouch-capture

Conversation

@tryk016

@tryk016 tryk016 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Capture is currently stored by mouse button, so a second touch overwrites the
first one. Use the pointer ID as well, and don't treat a press from another
pointer as a double-click.

Enable multitouch on the controller's input view, including when Metal replaces it.

Adds regression tests for simultaneous touches, release order, mouse buttons,
re-entry and widget deletion. Tested with TempestTests on Windows, Linux and
locally on macOS, plus two-finger gestures in the iOS 18 and 27 simulators.

Comment thread Engine/system/eventdispatcher.h Outdated

Widget* customRoot = nullptr;
std::weak_ptr<Widget::Ref> mouseUp[Event::MouseButton::ButtonLast];
std::map<MouseCapture,std::weak_ptr<Widget::Ref>> mouseUp;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whole std::map is too heavy container for this use-case. In most cases this container will have 0-2 entries. Something like flat_map would be the right tool in principle, but it requires C++23.

Something like this should fit better:

struct MouseCapture {
  Event::MouseButton         button = {};
  int                        id     = 0;
  std::weak_ptr<Widget::Ref> ref    = {};
  };
std::vector<MouseCapture> mouseUp;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the map with a vector of MouseCapture, as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants