From 6a081f543a1455d0e4dea706c3749bf08f3c99d3 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 8 Jan 2025 12:36:08 +0100 Subject: [PATCH] Go via Clutter.Actor.context to get Clutter.Backend --- lib/Drawing/Canvas.vala | 4 ++++ lib/ShadowEffect.vala | 18 +++++++++++++----- src/Background/BlurEffect.vala | 12 ++++++++++++ src/Widgets/DwellClickTimer.vala | 10 ++++++++-- src/Widgets/PointerLocator.vala | 8 +++++++- src/Widgets/WorkspaceClone.vala | 7 ++++++- 6 files changed, 50 insertions(+), 9 deletions(-) diff --git a/lib/Drawing/Canvas.vala b/lib/Drawing/Canvas.vala index e629d38f6..35f276460 100644 --- a/lib/Drawing/Canvas.vala +++ b/lib/Drawing/Canvas.vala @@ -21,7 +21,11 @@ public class Gala.Drawing.Canvas : GLib.Object, Clutter.Content { int real_width = (int) Math.ceilf (width * scale_factor); int real_height = (int) Math.ceilf (height * scale_factor); if (bitmap == null) { +#if HAS_MUTTER47 + unowned Cogl.Context ctx = actor.context.get_backend ().get_cogl_context (); +#else unowned Cogl.Context ctx = Clutter.get_default_backend ().get_cogl_context (); +#endif bitmap = new Cogl.Bitmap.with_size (ctx, real_width, real_height, Cogl.PixelFormat.CAIRO_ARGB32_COMPAT); } diff --git a/lib/ShadowEffect.vala b/lib/ShadowEffect.vala index 79fd89dd1..f6a928ab4 100644 --- a/lib/ShadowEffect.vala +++ b/lib/ShadowEffect.vala @@ -55,23 +55,31 @@ public class Gala.ShadowEffect : Clutter.Effect { public int border_radius { get; set; default = 9;} private int shadow_size; - private Cogl.Pipeline pipeline; + private Cogl.Pipeline? pipeline; private string? current_key = null; public ShadowEffect (string css_class = "") { Object (css_class: css_class); } - construct { - pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ()); - } - ~ShadowEffect () { if (current_key != null) { decrement_shadow_users (current_key); } } + public override void set_actor (Clutter.Actor? actor) { + if (actor != null) { +#if HAS_MUTTER47 + pipeline = new Cogl.Pipeline (actor.context.get_backend ().get_cogl_context ()); +#else + pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ()); +#endif + } else { + pipeline = null; + } + } + private Cogl.Texture? get_shadow (Cogl.Context context, int width, int height, int shadow_size) { var old_key = current_key; current_key = "%ix%i:%i".printf (width, height, shadow_size); diff --git a/src/Background/BlurEffect.vala b/src/Background/BlurEffect.vala index f396d3d84..8245bf5cf 100644 --- a/src/Background/BlurEffect.vala +++ b/src/Background/BlurEffect.vala @@ -29,7 +29,11 @@ public class Gala.BlurEffect : Clutter.Effect { } construct { +#if HAS_MUTTER47 + unowned var ctx = actor.context.get_backend ().get_cogl_context (); +#else unowned var ctx = Clutter.get_default_backend ().get_cogl_context (); +#endif actor_pipeline = new Cogl.Pipeline (ctx); actor_pipeline.set_layer_null_texture (0); @@ -98,7 +102,11 @@ public class Gala.BlurEffect : Clutter.Effect { return true; } +#if HAS_MUTTER47 + unowned var ctx = actor.context.get_backend ().get_cogl_context (); +#else unowned var ctx = Clutter.get_default_backend ().get_cogl_context (); +#endif framebuffer = null; texture = null; @@ -136,7 +144,11 @@ public class Gala.BlurEffect : Clutter.Effect { actor_painted = false; +#if HAS_MUTTER47 + unowned var ctx = actor.context.get_backend ().get_cogl_context (); +#else unowned var ctx = Clutter.get_default_backend ().get_cogl_context (); +#endif actor_framebuffer = null; actor_texture = null; diff --git a/src/Widgets/DwellClickTimer.vala b/src/Widgets/DwellClickTimer.vala index cf7f5afa7..217f9f090 100644 --- a/src/Widgets/DwellClickTimer.vala +++ b/src/Widgets/DwellClickTimer.vala @@ -51,7 +51,13 @@ namespace Gala { visible = false; reactive = false; - pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ()); +#if HAS_MUTTER47 + unowned var backend = actor.context.get_backend (); +#else + unowned var backend = Clutter.get_default_backend (); +#endif + + pipeline = new Cogl.Pipeline (backend.get_cogl_context ()); transition = new Clutter.PropertyTransition ("angle"); transition.set_progress_mode (Clutter.AnimationMode.EASE_OUT_QUAD); @@ -65,7 +71,7 @@ namespace Gala { interface_settings = new GLib.Settings ("org.gnome.desktop.interface"); - var seat = Clutter.get_default_backend ().get_default_seat (); + var seat = backend.get_default_seat (); seat.set_pointer_a11y_dwell_click_type (Clutter.PointerA11yDwellClickType.PRIMARY); seat.ptr_a11y_timeout_started.connect ((device, type, timeout) => { diff --git a/src/Widgets/PointerLocator.vala b/src/Widgets/PointerLocator.vala index e4924d792..43469bc25 100644 --- a/src/Widgets/PointerLocator.vala +++ b/src/Widgets/PointerLocator.vala @@ -46,7 +46,13 @@ namespace Gala { reactive = false; settings = new GLib.Settings ("org.gnome.desktop.interface"); - pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ()); + +#if HAS_MUTTER47 + unowned var ctx = context.get_backend ().get_cogl_context (); +#else + unowned var ctx = Clutter.get_default_backend ().get_cogl_context (); +#endif + pipeline = new Cogl.Pipeline (ctx); var pivot = Graphene.Point (); pivot.init (0.5f, 0.5f); diff --git a/src/Widgets/WorkspaceClone.vala b/src/Widgets/WorkspaceClone.vala index cd47fb55d..0b624c87d 100644 --- a/src/Widgets/WorkspaceClone.vala +++ b/src/Widgets/WorkspaceClone.vala @@ -37,7 +37,12 @@ namespace Gala { } construct { - pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ()); +#if HAS_MUTTER47 + unowned var ctx = context.get_backend ().get_cogl_context (); +#else + unowned var ctx = Clutter.get_default_backend ().get_cogl_context (); +#endif + pipeline = new Cogl.Pipeline (ctx); var primary = display.get_primary_monitor (); var monitor_geom = display.get_monitor_geometry (primary);