WindowManager: dim parents of modals (#1285)

This commit is contained in:
Danielle Foré 2021-11-06 10:00:51 -07:00 committed by GitHub
parent 65da8f7767
commit de1b897bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 19 deletions

View File

@ -16,6 +16,7 @@
<ul>
<li>Support for high-resolution scroll events</li>
<li>Redesigned Alt + Tab switcher</li>
<li>Dim the parents of modal dialogs</li>
<li>Updated translations</li>
</ul>
</description>

View File

@ -183,10 +183,6 @@
<summary>Arrangement of buttons on the titlebar</summary>
<description>Arrangement of buttons on the titlebar. The value should be a string, such as "menu:minimize,maximize,spacer,close"; the colon separates the left corner of the window from the right corner, and the button names are comma-separated. Duplicate buttons are not allowed. Unknown button names are silently ignored so that buttons can be added in future metacity versions without breaking older versions. A special spacer tag can be used to insert some space between two adjacent buttons.</description>
</key>
<key type="b" name="dim-parents">
<default>false</default>
<summary>Dims parent windows when spawning modal dialogs</summary>
</key>
<key type="d" name="alt-tab-window-opacity">
<range min="0.0" max="1.0"/>
<default>0.0</default>

View File

@ -722,15 +722,21 @@ namespace Gala {
out x, out y);
}
public void dim_window (Meta.Window window, bool dim) {
/*FIXME we need a super awesome blureffect here, the one from clutter is just... bah!
var win = window.get_compositor_private () as Meta.WindowActor;
if (dim) {
if (win.has_effects ())
return;
win.add_effect_with_name ("darken", new Clutter.BlurEffect ());
} else
win.clear_effects ();*/
private void toggle_dim_parent (Meta.Window window) {
if (window.window_type == Meta.WindowType.MODAL_DIALOG) {
var ancestor = window.find_root_ancestor ();
if (ancestor != null && ancestor != window) {
var win = (Meta.WindowActor) ancestor.get_compositor_private ();
if (win.has_effects ()) {
win.clear_effects ();
} else {
var dark_effect = new Clutter.BrightnessContrastEffect ();
dark_effect.set_brightness (-0.4f);
win.add_effect (dark_effect);
}
}
}
}
/**
@ -1381,11 +1387,7 @@ namespace Gala {
}
});
var appearance_settings = new GLib.Settings (Config.SCHEMA + ".appearance");
if (appearance_settings.get_boolean ("dim-parents") &&
window.window_type == Meta.WindowType.MODAL_DIALOG &&
window.is_attached_dialog ())
dim_window (window.find_root_ancestor (), true);
toggle_dim_parent (window);
break;
case Meta.WindowType.NOTIFICATION:
@ -1463,7 +1465,7 @@ namespace Gala {
destroy_completed (actor);
});
dim_window (window.find_root_ancestor (), false);
toggle_dim_parent (window);
break;
case Meta.WindowType.MENU: