Skip to content

Commit 6f27cba

Browse files
authored
ModalGroup: Blur background (#2715)
1 parent 8fb60a9 commit 6f27cba

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

src/Widgets/ModalGroup.vala

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,53 @@
1010
* the desktop behind them and only allow interaction with them.
1111
* Not to be confused with WindowManager.push_modal which only
1212
* works for our own Clutter.Actors.
13+
* Note that windows shouldn't be added to this actor directly but
14+
* instead to {@link window_group}.
1315
*/
1416
public class Gala.ModalGroup : Clutter.Actor {
1517
public WindowManager wm { private get; construct; }
1618
public ShellClientsManager shell_clients { private get; construct; }
1719

20+
public Clutter.Actor window_group { get; construct; }
21+
22+
private Clutter.Actor background;
1823
private Gee.Set<Clutter.Actor> dimmed;
1924
private ModalProxy? modal_proxy = null;
2025

2126
public ModalGroup (WindowManager wm, ShellClientsManager shell_clients) {
2227
Object (wm: wm, shell_clients: shell_clients);
2328
}
2429

30+
class construct {
31+
set_layout_manager_type (typeof (Clutter.BinLayout));
32+
}
33+
2534
construct {
35+
background = new Clutter.Actor () {
36+
background_color = { 0, 0, 0, 125 },
37+
x_expand = true,
38+
y_expand = true,
39+
};
40+
background.add_effect (new BackgroundBlurEffect (10, 0, 1));
41+
42+
window_group = new Clutter.Actor () {
43+
x_expand = true,
44+
y_expand = true,
45+
};
46+
47+
add_child (background);
48+
add_child (window_group);
49+
2650
dimmed = new Gee.HashSet<Clutter.Actor> ();
2751

2852
visible = false;
2953
reactive = true;
3054
#if HAS_MUTTER46
31-
child_added.connect (on_child_added);
32-
child_removed.connect (on_child_removed);
55+
window_group.child_added.connect (on_child_added);
56+
window_group.child_removed.connect (on_child_removed);
3357
#else
34-
actor_added.connect (on_child_added);
35-
actor_removed.connect (on_child_removed);
58+
window_group.actor_added.connect (on_child_added);
59+
window_group.actor_removed.connect (on_child_removed);
3660
#endif
3761
}
3862

@@ -41,36 +65,36 @@ public class Gala.ModalGroup : Clutter.Actor {
4165
dimmed.add (child);
4266
}
4367

44-
if (get_n_children () == 1) {
68+
if (window_group.get_n_children () == 1) {
4569
assert (modal_proxy == null);
4670

4771
visible = true;
4872
modal_proxy = wm.push_modal (this, false);
4973
}
5074

5175
if (dimmed.size == 1) {
52-
save_easing_state ();
53-
set_easing_duration (Utils.get_animation_duration (AnimationDuration.OPEN));
54-
background_color = { 0, 0, 0, 200 };
55-
restore_easing_state ();
76+
background.save_easing_state ();
77+
background.set_easing_duration (Utils.get_animation_duration (AnimationDuration.OPEN));
78+
background.opacity = 255u;
79+
background.restore_easing_state ();
5680
}
5781
}
5882

5983
private void on_child_removed (Clutter.Actor child) {
6084
dimmed.remove (child);
6185

6286
if (dimmed.size == 0) {
63-
save_easing_state ();
64-
set_easing_duration (Utils.get_animation_duration (AnimationDuration.CLOSE));
65-
background_color = { 0, 0, 0, 0 };
66-
restore_easing_state ();
87+
background.save_easing_state ();
88+
background.set_easing_duration (Utils.get_animation_duration (AnimationDuration.CLOSE));
89+
background.opacity = 0u;
90+
background.restore_easing_state ();
6791
}
6892

69-
if (get_n_children () == 0) {
93+
if (window_group.get_n_children () == 0) {
7094
wm.pop_modal (modal_proxy);
7195
modal_proxy = null;
7296

73-
var transition = get_transition ("background-color");
97+
var transition = background.get_transition ("opacity");
7498
if (transition != null) {
7599
transition.completed.connect (() => visible = false);
76100
} else {

src/WindowManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ namespace Gala {
10281028
unowned var window = actor.get_meta_window ();
10291029

10301030
if (ShellClientsManager.get_instance ().is_system_modal_window (window)) {
1031-
InternalUtils.clutter_actor_reparent (actor, modal_group);
1031+
InternalUtils.clutter_actor_reparent (actor, modal_group.window_group);
10321032
return;
10331033
}
10341034

0 commit comments

Comments
 (0)