diff --git a/lib/Drawing/Canvas.vala b/lib/Drawing/Canvas.vala index e629d38f6..6907e1ec0 100644 --- a/lib/Drawing/Canvas.vala +++ b/lib/Drawing/Canvas.vala @@ -9,6 +9,8 @@ public class Gala.Drawing.Canvas : GLib.Object, Clutter.Content { private int height = -1; private float scale_factor = 1.0f; + private Cogl.Context? cogl_context; + private Cogl.Texture? texture = null; private Cogl.Bitmap? bitmap = null; @@ -16,13 +18,24 @@ public class Gala.Drawing.Canvas : GLib.Object, Clutter.Content { public signal void draw (Cairo.Context cr, int width, int height); - private void emit_draw () requires (width > 0 && height > 0) { + public override void attached (Clutter.Actor actor) { +#if HAS_MUTTER47 + cogl_context = actor.context.get_backend ().get_cogl_context (); +#else + cogl_context = Clutter.get_default_backend ().get_cogl_context (); +#endif + } + + public override void detached (Clutter.Actor actor) { + cogl_context = null; + } + + private void emit_draw () requires (width > 0 && height > 0 && cogl_context != null) { dirty = true; int real_width = (int) Math.ceilf (width * scale_factor); int real_height = (int) Math.ceilf (height * scale_factor); if (bitmap == null) { - unowned Cogl.Context ctx = Clutter.get_default_backend ().get_cogl_context (); - bitmap = new Cogl.Bitmap.with_size (ctx, real_width, real_height, Cogl.PixelFormat.CAIRO_ARGB32_COMPAT); + bitmap = new Cogl.Bitmap.with_size (cogl_context, real_width, real_height, Cogl.PixelFormat.CAIRO_ARGB32_COMPAT); } unowned Cogl.Buffer? buffer = bitmap.get_buffer (); diff --git a/lib/ShadowEffect.vala b/lib/ShadowEffect.vala index 79fd89dd1..294924719 100644 --- a/lib/ShadowEffect.vala +++ b/lib/ShadowEffect.vala @@ -55,23 +55,33 @@ 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) { + base.set_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..84d3b11f6 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 = 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);