Skip to content

Commit 293b1d9

Browse files
committed
HideTracker: Improve transients management
1 parent fca1d7d commit 293b1d9

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/ShellClients/HideTracker.vala

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class Gala.HideTracker : Object {
2121

2222
private bool hovered = false;
2323

24+
private uint num_transients = 0;
25+
private bool has_transients { get { return num_transients > 0; } }
26+
2427
private Barrier? barrier;
2528

2629
private uint hide_timeout_id = 0;
@@ -51,13 +54,22 @@ public class Gala.HideTracker : Object {
5154

5255
if (hovered != has_pointer) {
5356
hovered = has_pointer;
57+
check_trigger_conditions ();
58+
}
59+
});
5460

55-
if (hovered) {
56-
trigger_show ();
57-
} else {
58-
trigger_hide ();
61+
display.window_created.connect ((new_window) => {
62+
InternalUtils.wait_for_window_actor (new_window, (new_window_actor) => {
63+
if (panel.window.is_ancestor_of_transient (new_window_actor.meta_window)) {
64+
num_transients++;
65+
check_trigger_conditions ();
66+
67+
new_window_actor.meta_window.unmanaged.connect (() => {
68+
num_transients = uint.max (num_transients - 1, 0);
69+
check_trigger_conditions ();
70+
});
5971
}
60-
}
72+
});
6173
});
6274

6375
pan_action = new Clutter.PanAction () {
@@ -83,25 +95,17 @@ public class Gala.HideTracker : Object {
8395
setup_barrier ();
8496
}
8597

98+
private void check_trigger_conditions () {
99+
if (hovered || has_transients) {
100+
trigger_show ();
101+
} else {
102+
trigger_hide ();
103+
}
104+
}
105+
86106
private void trigger_hide () {
87107
reset_hide_timeout ();
88108

89-
// Don't hide if we have transients, e.g. an open popover, dialog, etc.
90-
// TODO: this is broken, we should monitor transients for has_pointer and use it instead.
91-
var has_transients = false;
92-
panel.window.foreach_transient ((transient) => {
93-
if (transient.window_type == DROPDOWN_MENU) {
94-
return true;
95-
}
96-
97-
has_transients = true;
98-
return false;
99-
});
100-
101-
if (has_transients) {
102-
return;
103-
}
104-
105109
hide_timeout_id = Timeout.add_once (HIDE_DELAY, () => {
106110
hide ();
107111
hide_timeout_id = 0;

0 commit comments

Comments
 (0)