1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-FileCopyrightText: Copyright (c) 2026 Mike Li/Mikewolfli/Wei Li(mikewolfli@163.com)
// SPDX-License-Identifier: MIT
//! Shared cleanup for the menu tables the non-Windows backends keep.
//!
//! # Why this exists (PLAT-08)
//!
//! Android, the mobile preview backend and Wayland each used to carry a hand-written copy of
//! "remove this widget from the attached-bar map, the menu tree and the trigger queue" inside
//! `destroy_widget`. The copies had drifted (one cleared only one direction of the attached-bar
//! map, one forgot the trigger queue), and a new side table had to be added to every copy.
//!
//! This module owns the rule once. Each backend's menu state exposes a `purge` method that
//! delegates here, so `destroy_widget` makes one call and the tables it owns are cleaned the same
//! way. Windows keeps a different model (native handle map + command-id map), so its `purge`
//! lives on its own state type but follows the same one-call shape.
use crate;
/// Removes every reference to `widget_id` from the shared menu tables.
///
/// `pending_menu_events` is optional because the mobile preview backend keeps its trigger queue
/// in `BackendState::widget_events` rather than beside the menu model; passing `None` cleans the
/// tables it does own without inventing a second queue.
///
/// The `Ord` bound is not used by the standard `HashMap`; it is what lets this one body compile
/// where `crate::compat::HashMap` is a `BTreeMap` (the allocation-frugal profiles).
pub