Skip to content

Commit b839f53

Browse files
authored
Move panel hiding to the shell clients (#2239)
1 parent 749fa8b commit b839f53

11 files changed

+210
-345
lines changed

src/Gestures/GestureTracker.vala

+5-7
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,16 @@ public class Gala.GestureTracker : Object {
204204
}
205205

206206
/**
207-
* Connects a callback that will only be called if != 0 completions were made.
207+
* Connects a callback that will be called as soon as the gesture finishes.
208208
* If with_gesture is false it will be called immediately, otherwise once {@link on_end} is emitted.
209209
*/
210-
public void add_success_callback (bool with_gesture, owned OnEnd callback) {
210+
public void add_end_callback (bool with_gesture, owned OnEnd callback) {
211211
if (!with_gesture) {
212212
callback (1, 1, min_animation_duration);
213213
} else {
214-
ulong handler_id = on_end.connect ((percentage, completions, duration) => {
215-
if (completions != 0) {
216-
callback (percentage, completions, duration);
217-
}
218-
});
214+
ulong handler_id = on_end.connect ((percentage, cancel_action, duration) =>
215+
callback (percentage, cancel_action, duration)
216+
);
219217
handlers.add (handler_id);
220218
}
221219
}

src/InternalUtils.vala

-10
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,5 @@ namespace Gala {
388388
Clutter.get_default_backend ().get_default_seat ().bell_notify ();
389389
#endif
390390
}
391-
392-
public static void update_transients_visible (Meta.Window window, bool visible) {
393-
window.foreach_transient ((transient) => {
394-
unowned var actor = (Meta.WindowActor) transient.get_compositor_private ();
395-
396-
actor.visible = visible;
397-
398-
return true;
399-
});
400-
}
401391
}
402392
}

src/ShellClients/HideTracker.vala

+4
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ public class Gala.HideTracker : Object {
227227
}
228228

229229
private void trigger_hide () {
230+
if (hide_timeout_id != 0) {
231+
return;
232+
}
233+
230234
// Don't hide if we have transients, e.g. an open popover, dialog, etc.
231235
var has_transients = false;
232236
panel.window.foreach_transient (() => {

src/ShellClients/PanelClone.vala

-128
This file was deleted.

src/ShellClients/PanelWindow.vala

+50-22
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,44 @@
55
* Authored by: Leonhard Kargl <[email protected]>
66
*/
77

8-
public class Gala.PanelWindow : Object {
8+
public class Gala.PanelWindow : ShellWindow {
9+
private const int ANIMATION_DURATION = 250;
10+
911
private static HashTable<Meta.Window, Meta.Strut?> window_struts = new HashTable<Meta.Window, Meta.Strut?> (null, null);
1012

1113
public WindowManager wm { get; construct; }
12-
public Meta.Window window { get; construct; }
1314
public Pantheon.Desktop.Anchor anchor { get; construct set; }
1415

15-
private WindowPositioner window_positioner;
16+
public Pantheon.Desktop.HideMode hide_mode {
17+
get {
18+
return hide_tracker == null ? Pantheon.Desktop.HideMode.NEVER : hide_tracker.hide_mode;
19+
}
20+
set {
21+
if (value == NEVER) {
22+
hide_tracker = null;
23+
show ();
24+
make_exclusive ();
25+
return;
26+
} else if (hide_tracker == null) {
27+
unmake_exclusive ();
28+
29+
hide_tracker = new HideTracker (wm.get_display (), this);
30+
hide_tracker.hide.connect (hide);
31+
hide_tracker.show.connect (show);
32+
}
1633

17-
private PanelClone clone;
34+
hide_tracker.hide_mode = value;
35+
}
36+
}
37+
38+
private GestureTracker default_gesture_tracker;
39+
private HideTracker? hide_tracker;
1840

1941
private int width = -1;
2042
private int height = -1;
2143

2244
public PanelWindow (WindowManager wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
23-
Object (wm: wm, window: window, anchor: anchor);
45+
Object (wm: wm, anchor: anchor, window: window, position: Position.from_anchor (anchor));
2446
}
2547

2648
construct {
@@ -30,22 +52,26 @@ public class Gala.PanelWindow : Object {
3052
}
3153
});
3254

33-
window.stick ();
34-
35-
clone = new PanelClone (wm, this);
36-
37-
unowned var display = wm.get_display ();
38-
39-
window_positioner = new WindowPositioner (display, window, WindowPositioner.Position.from_anchor (anchor));
55+
notify["anchor"].connect (() => position = Position.from_anchor (anchor));
4056

41-
notify["anchor"].connect (() => window_positioner.position = WindowPositioner.Position.from_anchor (anchor));
42-
43-
unowned var workspace_manager = display.get_workspace_manager ();
57+
unowned var workspace_manager = window.display.get_workspace_manager ();
4458
workspace_manager.workspace_added.connect (update_strut);
4559
workspace_manager.workspace_removed.connect (update_strut);
4660

4761
window.size_changed.connect (update_strut);
4862
window.position_changed.connect (update_strut);
63+
64+
default_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
65+
66+
window.display.in_fullscreen_changed.connect (() => {
67+
if (wm.get_display ().get_monitor_in_fullscreen (window.get_monitor ())) {
68+
hide ();
69+
} else if (hide_mode == NEVER) {
70+
show ();
71+
} else {
72+
hide_tracker.update_overlap ();
73+
}
74+
});
4975
}
5076

5177
#if HAS_MUTTER45
@@ -78,22 +104,24 @@ public class Gala.PanelWindow : Object {
78104
update_strut ();
79105
}
80106

81-
public void set_hide_mode (Pantheon.Desktop.HideMode hide_mode) {
82-
clone.hide_mode = hide_mode;
107+
private void hide () {
108+
add_state (CUSTOM_HIDDEN, default_gesture_tracker, false);
109+
}
83110

84-
if (hide_mode == NEVER) {
85-
make_exclusive ();
86-
} else {
87-
unmake_exclusive ();
111+
private void show () {
112+
if (window.display.get_monitor_in_fullscreen (window.get_monitor ())) {
113+
return;
88114
}
115+
116+
remove_state (CUSTOM_HIDDEN, default_gesture_tracker, false);
89117
}
90118

91119
private void make_exclusive () {
92120
update_strut ();
93121
}
94122

95123
private void update_strut () {
96-
if (clone.hide_mode != NEVER) {
124+
if (hide_mode != NEVER) {
97125
return;
98126
}
99127

src/ShellClients/WindowPositioner.vala src/ShellClients/PositionedWindow.vala

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Authored by: Leonhard Kargl <[email protected]>
66
*/
77

8-
public class Gala.WindowPositioner : Object {
8+
public class Gala.PositionedWindow : Object {
99
public enum Position {
1010
TOP,
1111
BOTTOM,
@@ -21,7 +21,6 @@ public class Gala.WindowPositioner : Object {
2121
}
2222
}
2323

24-
public Meta.Display display { get; construct; }
2524
public Meta.Window window { get; construct; }
2625
/**
2726
* This may only be set after the window was shown.
@@ -30,8 +29,8 @@ public class Gala.WindowPositioner : Object {
3029
public Position position { get; construct set; }
3130
public Variant? position_data { get; construct set; }
3231

33-
public WindowPositioner (Meta.Display display, Meta.Window window, Position position, Variant? position_data = null) {
34-
Object (display: display, window: window, position: position, position_data: position_data);
32+
public PositionedWindow (Meta.Window window, Position position, Variant? position_data = null) {
33+
Object (window: window, position: position, position_data: position_data);
3534
}
3635

3736
construct {
@@ -41,7 +40,7 @@ public class Gala.WindowPositioner : Object {
4140
window.position_changed.connect (position_window);
4241
window.shown.connect (position_window);
4342

44-
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
43+
unowned var monitor_manager = window.display.get_context ().get_backend ().get_monitor_manager ();
4544
monitor_manager.monitors_changed.connect (position_window);
4645
monitor_manager.monitors_changed_internal.connect (position_window);
4746

@@ -51,8 +50,8 @@ public class Gala.WindowPositioner : Object {
5150

5251
private void position_window () {
5352
int x = 0, y = 0;
54-
5553
var window_rect = window.get_frame_rect ();
54+
unowned var display = window.display;
5655

5756
switch (position) {
5857
case CENTER:

0 commit comments

Comments
 (0)