Expose keep-below windows (#162)

Creates a little animation when a bottom-stack window appears
on the stage: fades out all the windows except the keep-below
window, and animates it's scale to highlight it more.
This commit is contained in:
Adam Bieńkowski 2018-06-03 08:16:34 +02:00 committed by Rico Tzschichholz
parent 96f7799533
commit 4d4c18f570
2 changed files with 99 additions and 2 deletions

View File

@ -334,6 +334,18 @@ namespace Gala
return result;
}
public static inline bool get_window_is_normal (Meta.Window window)
{
switch (window.get_window_type ()) {
case Meta.WindowType.NORMAL:
case Meta.WindowType.DIALOG:
case Meta.WindowType.MODAL_DIALOG:
return true;
default:
return false;
}
}
/* TODO needs porting
public List<Meta.Rectangle?> natural_placement (Meta.Rectangle area, List<Meta.Rectangle?> windows)
{

View File

@ -477,6 +477,79 @@ namespace Gala
InternalUtils.set_input_area (screen, InputArea.DEFAULT);
}
void show_bottom_stack_window (Meta.Window bottom_window)
{
unowned Meta.Workspace workspace = bottom_window.get_workspace ();
if (Utils.get_n_windows (workspace) == 0) {
return;
}
bool enable_animations = AnimationSettings.get_default ().enable_animations;
var bottom_actor = bottom_window.get_compositor_private () as Meta.WindowActor;
if (enable_animations) {
animate_bottom_window_scale (bottom_actor);
}
uint fade_out_duration = 900U;
double[] op_keyframes = { 0.1, 0.9 };
GLib.Value[] opacity = { 20U, 20U };
var top_stack = new Gee.ArrayList<unowned Meta.Window> ();
workspace.list_windows ().@foreach ((window) => {
if (window.get_xwindow () == bottom_window.get_xwindow ()
|| !InternalUtils.get_window_is_normal (window)
|| window.minimized) {
return;
}
var actor = window.get_compositor_private () as Clutter.Actor;
if (enable_animations) {
var op_trans = new Clutter.KeyframeTransition ("opacity");
op_trans.duration = fade_out_duration;
op_trans.remove_on_complete = true;
op_trans.progress_mode = Clutter.AnimationMode.EASE_IN_OUT_QUAD;
op_trans.set_from_value (255.0f);
op_trans.set_to_value (255.0f);
op_trans.set_key_frames (op_keyframes);
op_trans.set_values (opacity);
actor.add_transition ("opacity-hide", op_trans);
} else {
Timeout.add ((uint)(fade_out_duration * op_keyframes[0]), () => {
actor.opacity = (uint)opacity[0];
return false;
});
Timeout.add ((uint)(fade_out_duration * op_keyframes[1]), () => {
actor.opacity = 255U;
return false;
});
}
});
}
void animate_bottom_window_scale (Meta.WindowActor actor)
{
const string[] props = { "scale-x", "scale-y" };
foreach (string prop in props) {
double[] scale_keyframes = { 0.2, 0.3, 0.8 };
GLib.Value[] scale = { 1.0f, 1.07f, 1.07f };
var scale_trans = new Clutter.KeyframeTransition (prop);
scale_trans.duration = 500;
scale_trans.remove_on_complete = true;
scale_trans.progress_mode = Clutter.AnimationMode.EASE_IN_QUAD;
scale_trans.set_from_value (1.0f);
scale_trans.set_to_value (1.0f);
scale_trans.set_key_frames (scale_keyframes);
scale_trans.set_values (scale);
actor.add_transition ("magnify-%s".printf (prop), scale_trans);
}
}
public uint32[] get_all_xids ()
{
var list = new Gee.ArrayList<uint32> ();
@ -1066,14 +1139,18 @@ namespace Gala
{
unowned AnimationSettings animation_settings = AnimationSettings.get_default ();
var window = actor.get_meta_window ();
if (!animation_settings.enable_animations) {
actor.show ();
map_completed (actor);
if (InternalUtils.get_window_is_normal (window) && window.get_layer () == Meta.StackLayer.BOTTOM) {
show_bottom_stack_window (window);
}
return;
}
var window = actor.get_meta_window ();
actor.remove_all_transitions ();
actor.show ();
@ -1108,6 +1185,10 @@ namespace Gala
actor.disconnect (map_handler_id);
mapping.remove (actor);
map_completed (actor);
if (window.get_layer () == Meta.StackLayer.BOTTOM) {
show_bottom_stack_window (window);
}
});
break;
case WindowType.MENU:
@ -1161,6 +1242,10 @@ namespace Gala
actor.disconnect (map_handler_id);
mapping.remove (actor);
map_completed (actor);
if (window.get_layer () == Meta.StackLayer.BOTTOM) {
show_bottom_stack_window (window);
}
});
if (AppearanceSettings.get_default ().dim_parents &&