Fix foreign toplevel handle eligibility and app_id handling for Wayland manager/list#4946
Fix foreign toplevel handle eligibility and app_id handling for Wayland manager/list#4946Copilot wants to merge 6 commits into
Conversation
Agent-Logs-Url: https://github.com/canonical/mir/sessions/c43861cd-8934-4436-b91c-e180b8e155c4 Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Agent-Logs-Url: https://github.com/canonical/mir/sessions/c43861cd-8934-4436-b91c-e180b8e155c4 Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
| else | ||
| { | ||
| should_have_handle = false; | ||
| app_id = foreign_toplevel_app_id(surface->application_id(), desktop_file_manager->resolve_app_id(surface.get())); |
There was a problem hiding this comment.
Calling resolve_app_id is potentially expensive. We should only call it if surface->application_id() is empty.
There was a problem hiding this comment.
Updated in commit a5eeedf: resolve_app_id() is now only called when the surface/event application_id is empty (in both foreign_toplevel_list_v1.cpp and foreign_toplevel_manager_v1.cpp).
Agent-Logs-Url: https://github.com/canonical/mir/sessions/0e9c5b86-3758-4f59-8e49-373941df5945 Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
AlanGriffiths
left a comment
There was a problem hiding this comment.
@copilot please address issues raised in this therad
| inline auto foreign_toplevel_app_id(std::string const& application_id, std::string const& resolved_app_id) -> std::string | ||
| { | ||
| if (!application_id.empty()) | ||
| return application_id; | ||
|
|
||
| return resolved_app_id; | ||
| } | ||
|
|
There was a problem hiding this comment.
This is only used in tests: it isn't needed.
There was a problem hiding this comment.
Addressed in 90f623e: removed the unused foreign_toplevel_app_id() helper from foreign_toplevel_handle_creation.h.
| inline auto should_create_foreign_toplevel_handle( | ||
| MirWindowType type, | ||
| bool has_session, | ||
| std::string const& app_id) -> bool |
There was a problem hiding this comment.
All the parameters need to be derived from the same surface: it would be better to pass the surface than repeat this at each call site.
There was a problem hiding this comment.
Addressed in 90f623e: should_create_foreign_toplevel_handle() now takes scene::Surface const& and derives eligibility inputs from that single surface.
| { | ||
| return has_session && type == mir_window_type_normal && !app_id.empty(); | ||
| } |
There was a problem hiding this comment.
This will incorrectly identify windows outside the application layer and windows that cannot get focus. It will not identify freestyle windows.
There was a problem hiding this comment.
Addressed in 90f623e: eligibility now requires application layer and focusable windows, and includes freestyle windows; also re-evaluates on depth-layer updates. Added focused coverage in e3b2678.
Agent-Logs-Url: https://github.com/canonical/mir/sessions/69ffaf31-6913-4e32-a808-bb4b8877913a Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Agent-Logs-Url: https://github.com/canonical/mir/sessions/69ffaf31-6913-4e32-a808-bb4b8877913a Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Addressed in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Related: n/a
What's new?
Foreign toplevel handle creation was over-inclusive (non-app windows), under-inclusive (freestyle windows), and sometimes emitted meaningless metadata (blank app_id/title). This change aligns both foreign-toplevel implementations to expose only eligible app toplevels with stable app identity.
Shared handle policy (deduplicated logic)
foreign_toplevel_handle_creation.hwith:should_create_foreign_toplevel_handle(surface, app_id)(single eligibility gate)foreign_toplevel_app_id(...)helper (it was only test-facing and unnecessary).foreign_toplevel_manager_v1.cppandforeign_toplevel_list_v1.cppuse this shared policy.Correct eligibility semantics
mir_depth_layer_applicationfocus_mode != mir_focus_mode_disabled)normal,utility, andfreestyleCorrect app_id emission semantics and performance
surface->application_id()when present.resolve_app_id()is called only whenapplication_idis empty (includingapplication_id_set_topaths), avoiding unnecessary expensive resolution.application_id_set_to, eligibility is re-evaluated so handles can be created/closed as app identity becomes known.Re-evaluate on depth-layer changes
depth_layer_set_to(...)handling in both foreign-toplevel observers so eligibility updates when a surface moves between layers.Focused tests
test_foreign_toplevel_handle_creation.cppto validate the new surface-derived eligibility policy:How to test
mir_unit_tests.bin --gtest_filter=ForeignToplevelHandleCreation*mir_unit_tests.bin --gtest_filter=DesktopFileManager*Checklist