WindowManager: explicitly dim and undim (#1298)

This commit is contained in:
Danielle Foré 2021-11-06 15:39:31 -07:00 committed by GitHub
parent 4fac2d838f
commit e1bd8bc306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -722,18 +722,19 @@ namespace Gala {
out x, out y); out x, out y);
} }
private void toggle_dim_parent (Meta.Window window) { private void dim_parent_window (Meta.Window window, bool dim) {
if (window.window_type == Meta.WindowType.MODAL_DIALOG) { if (window.window_type == Meta.WindowType.MODAL_DIALOG) {
var ancestor = window.find_root_ancestor (); var ancestor = window.find_root_ancestor ();
if (ancestor != null && ancestor != window) { if (ancestor != null && ancestor != window) {
var win = (Meta.WindowActor) ancestor.get_compositor_private (); var win = (Meta.WindowActor) ancestor.get_compositor_private ();
if (win.has_effects ()) { // Can't rely on win.has_effects since other effects could be applied
win.clear_effects (); if (dim) {
} else {
var dark_effect = new Clutter.BrightnessContrastEffect (); var dark_effect = new Clutter.BrightnessContrastEffect ();
dark_effect.set_brightness (-0.4f); dark_effect.set_brightness (-0.4f);
win.add_effect (dark_effect); win.add_effect (dark_effect);
} else {
win.clear_effects ();
} }
} }
} }
@ -1387,7 +1388,7 @@ namespace Gala {
} }
}); });
toggle_dim_parent (window); dim_parent_window (window, true);
break; break;
case Meta.WindowType.NOTIFICATION: case Meta.WindowType.NOTIFICATION:
@ -1465,7 +1466,7 @@ namespace Gala {
destroy_completed (actor); destroy_completed (actor);
}); });
toggle_dim_parent (window); dim_parent_window (window, false);
break; break;
case Meta.WindowType.MENU: case Meta.WindowType.MENU: