Skip to content

Commit

Permalink
Go via Clutter.Actor.context to get Clutter.Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Jan 8, 2025
1 parent b3f5d6c commit 6a081f5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lib/Drawing/Canvas.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
18 changes: 13 additions & 5 deletions lib/ShadowEffect.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions src/Background/BlurEffect.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions src/Widgets/DwellClickTimer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down
8 changes: 7 additions & 1 deletion src/Widgets/PointerLocator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/Widgets/WorkspaceClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6a081f5

Please sign in to comment.