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
//! Rebuilding the status item so it is drawn unpressed.
use ;
use crateLabel;
/// Replace the status item with a fresh one, drawn in its normal state.
///
/// The public tray surface cannot clear the pressed state - no method exposes the
/// status-bar button the highlight lives on - but `set_visible` is the whole
/// status item: `false` removes it, `true` builds a new one from the attributes
/// the tray was created with, and a button that did not exist when the click was
/// handled cannot be carrying that click's highlight.
///
/// Both calls are attempted even when the first one fails. A removal that fails
/// leaves the icon where it was, which is the state we started in; a removal that
/// succeeded and a re-create that did not would leave no icon at all, so the
/// second call must never be skipped.
///
/// The re-created item keeps its place: `create()` re-adds the status item with
/// the same attributes and the same id, so it is drawn with the template flag it
/// was built with and its click still routes to the handler registered against
/// that id. It is also placed back in the same slot rather than at the end of the
/// menu bar - measured by removing and re-creating one status item six times in a
/// probe app and reading the status window's origin each time: the same `x` every
/// cycle, and the new button reporting unpressed every cycle.