Skip to content

Commit 794a408

Browse files
committed
Go via Clutter.Actor.context to get Clutter.Backend
1 parent b3f5d6c commit 794a408

File tree

6 files changed

+64
-12
lines changed

6 files changed

+64
-12
lines changed

lib/Drawing/Canvas.vala

+16-3
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,33 @@ public class Gala.Drawing.Canvas : GLib.Object, Clutter.Content {
99
private int height = -1;
1010
private float scale_factor = 1.0f;
1111

12+
private Cogl.Context? cogl_context;
13+
1214
private Cogl.Texture? texture = null;
1315
private Cogl.Bitmap? bitmap = null;
1416

1517
private bool dirty = false;
1618

1719
public signal void draw (Cairo.Context cr, int width, int height);
1820

19-
private void emit_draw () requires (width > 0 && height > 0) {
21+
public override void attached (Clutter.Actor actor) {
22+
#if HAS_MUTTER47
23+
cogl_context = actor.context.get_backend ().get_cogl_context ();
24+
#else
25+
cogl_context = Clutter.get_default_backend ().get_cogl_context ();
26+
#endif
27+
}
28+
29+
public override void detached (Clutter.Actor actor) {
30+
cogl_context = null;
31+
}
32+
33+
private void emit_draw () requires (width > 0 && height > 0 && cogl_context != null) {
2034
dirty = true;
2135
int real_width = (int) Math.ceilf (width * scale_factor);
2236
int real_height = (int) Math.ceilf (height * scale_factor);
2337
if (bitmap == null) {
24-
unowned Cogl.Context ctx = Clutter.get_default_backend ().get_cogl_context ();
25-
bitmap = new Cogl.Bitmap.with_size (ctx, real_width, real_height, Cogl.PixelFormat.CAIRO_ARGB32_COMPAT);
38+
bitmap = new Cogl.Bitmap.with_size (cogl_context, real_width, real_height, Cogl.PixelFormat.CAIRO_ARGB32_COMPAT);
2639
}
2740

2841
unowned Cogl.Buffer? buffer = bitmap.get_buffer ();

lib/ShadowEffect.vala

+15-5
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,33 @@ public class Gala.ShadowEffect : Clutter.Effect {
5555
public int border_radius { get; set; default = 9;}
5656

5757
private int shadow_size;
58-
private Cogl.Pipeline pipeline;
58+
private Cogl.Pipeline? pipeline;
5959
private string? current_key = null;
6060

6161
public ShadowEffect (string css_class = "") {
6262
Object (css_class: css_class);
6363
}
6464

65-
construct {
66-
pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ());
67-
}
68-
6965
~ShadowEffect () {
7066
if (current_key != null) {
7167
decrement_shadow_users (current_key);
7268
}
7369
}
7470

71+
public override void set_actor (Clutter.Actor? actor) {
72+
base.set_actor (actor);
73+
74+
if (actor != null) {
75+
#if HAS_MUTTER47
76+
pipeline = new Cogl.Pipeline (actor.context.get_backend ().get_cogl_context ());
77+
#else
78+
pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ());
79+
#endif
80+
} else {
81+
pipeline = null;
82+
}
83+
}
84+
7585
private Cogl.Texture? get_shadow (Cogl.Context context, int width, int height, int shadow_size) {
7686
var old_key = current_key;
7787
current_key = "%ix%i:%i".printf (width, height, shadow_size);

src/Background/BlurEffect.vala

+12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ public class Gala.BlurEffect : Clutter.Effect {
2929
}
3030

3131
construct {
32+
#if HAS_MUTTER47
33+
unowned var ctx = actor.context.get_backend ().get_cogl_context ();
34+
#else
3235
unowned var ctx = Clutter.get_default_backend ().get_cogl_context ();
36+
#endif
3337

3438
actor_pipeline = new Cogl.Pipeline (ctx);
3539
actor_pipeline.set_layer_null_texture (0);
@@ -98,7 +102,11 @@ public class Gala.BlurEffect : Clutter.Effect {
98102
return true;
99103
}
100104

105+
#if HAS_MUTTER47
106+
unowned var ctx = actor.context.get_backend ().get_cogl_context ();
107+
#else
101108
unowned var ctx = Clutter.get_default_backend ().get_cogl_context ();
109+
#endif
102110

103111
framebuffer = null;
104112
texture = null;
@@ -136,7 +144,11 @@ public class Gala.BlurEffect : Clutter.Effect {
136144

137145
actor_painted = false;
138146

147+
#if HAS_MUTTER47
148+
unowned var ctx = actor.context.get_backend ().get_cogl_context ();
149+
#else
139150
unowned var ctx = Clutter.get_default_backend ().get_cogl_context ();
151+
#endif
140152

141153
actor_framebuffer = null;
142154
actor_texture = null;

src/Widgets/DwellClickTimer.vala

+8-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ namespace Gala {
5151
visible = false;
5252
reactive = false;
5353

54-
pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ());
54+
#if HAS_MUTTER47
55+
unowned var backend = context.get_backend ();
56+
#else
57+
unowned var backend = Clutter.get_default_backend ();
58+
#endif
59+
60+
pipeline = new Cogl.Pipeline (backend.get_cogl_context ());
5561

5662
transition = new Clutter.PropertyTransition ("angle");
5763
transition.set_progress_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
@@ -65,7 +71,7 @@ namespace Gala {
6571

6672
interface_settings = new GLib.Settings ("org.gnome.desktop.interface");
6773

68-
var seat = Clutter.get_default_backend ().get_default_seat ();
74+
var seat = backend.get_default_seat ();
6975
seat.set_pointer_a11y_dwell_click_type (Clutter.PointerA11yDwellClickType.PRIMARY);
7076

7177
seat.ptr_a11y_timeout_started.connect ((device, type, timeout) => {

src/Widgets/PointerLocator.vala

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ namespace Gala {
4646
reactive = false;
4747

4848
settings = new GLib.Settings ("org.gnome.desktop.interface");
49-
pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ());
49+
50+
#if HAS_MUTTER47
51+
unowned var ctx = context.get_backend ().get_cogl_context ();
52+
#else
53+
unowned var ctx = Clutter.get_default_backend ().get_cogl_context ();
54+
#endif
55+
pipeline = new Cogl.Pipeline (ctx);
5056

5157
var pivot = Graphene.Point ();
5258
pivot.init (0.5f, 0.5f);

src/Widgets/WorkspaceClone.vala

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ namespace Gala {
3737
}
3838

3939
construct {
40-
pipeline = new Cogl.Pipeline (Clutter.get_default_backend ().get_cogl_context ());
40+
#if HAS_MUTTER47
41+
unowned var ctx = context.get_backend ().get_cogl_context ();
42+
#else
43+
unowned var ctx = Clutter.get_default_backend ().get_cogl_context ();
44+
#endif
45+
pipeline = new Cogl.Pipeline (ctx);
4146
var primary = display.get_primary_monitor ();
4247
var monitor_geom = display.get_monitor_geometry (primary);
4348

0 commit comments

Comments
 (0)