coverflow_alt_tab.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import * as Main from "resource:///org/gnome/shell/ui/main.js";
  2. import { PaintSignals } from "../conveniences/paint_signals.js";
  3. import { Pipeline } from "../conveniences/pipeline.js";
  4. export const CoverflowAltTabBlur = class CoverflowAltTabBlur {
  5. constructor(connections, settings, effects_manager) {
  6. this.connections = connections;
  7. this.settings = settings;
  8. this.paint_signals = new PaintSignals(connections);
  9. this.effects_manager = effects_manager;
  10. this.background_actors = [];
  11. this.background_managers = [];
  12. }
  13. enable() {
  14. this._log("blurring coverflow alt-tab");
  15. this.update_backgrounds();
  16. this.connections.connect(
  17. Main.layoutManager.uiGroup,
  18. "child-added",
  19. (_, child) => this.try_blur(child)
  20. );
  21. this.connections.connect(Main.layoutManager, "monitors-changed", (_) => {
  22. this.update_backgrounds();
  23. });
  24. }
  25. update_backgrounds() {
  26. this.remove_background_actors();
  27. Main.layoutManager.uiGroup
  28. .get_children()
  29. .forEach((child) => this.try_blur(child));
  30. }
  31. try_blur(actor) {
  32. if (
  33. actor.constructor.name !== "Meta_BackgroundGroup" ||
  34. actor.get_name() !== "coverflow-alt-tab-background-group"
  35. ) {
  36. return;
  37. }
  38. this._log("found coverflow alt-tab to blur");
  39. for (let i = 0; i < Main.layoutManager.monitors.length; i++) {
  40. const pipeline = new Pipeline(
  41. this.effects_manager,
  42. global.blur_my_shell._pipelines_manager,
  43. this.settings.coverflow_alt_tab.PIPELINE
  44. );
  45. const background_actor = pipeline.create_background_with_effects(
  46. i,
  47. this.background_managers,
  48. actor,
  49. "bms-coverflow-alt-tab-blurred-widget"
  50. );
  51. this.background_actors.push(background_actor);
  52. }
  53. }
  54. remove_background_actors() {
  55. this.background_actors.forEach((actor) => actor.destroy);
  56. this.background_actors = [];
  57. this.background_managers.forEach((background_manager) => {
  58. background_manager._bms_pipeline.destroy();
  59. background_manager.destroy();
  60. });
  61. this.background_managers = [];
  62. }
  63. disable() {
  64. this._log("removing blur from coverflow alt-tab");
  65. this.remove_background_actors();
  66. this.connections.disconnect_all();
  67. }
  68. _log(str) {
  69. if (this.settings.DEBUG) {
  70. console.log(`[Blur my Shell > coverflow alt-tab] ${str}`);
  71. }
  72. }
  73. };