Fix crash on old vala version

This commit is contained in:
Leonhard 2024-04-02 16:09:45 +02:00
parent 87c6a2f873
commit b362f1a9f1
2 changed files with 8 additions and 40 deletions

View File

@ -4,10 +4,18 @@
*/
public class Gala.CanvasActor : Clutter.Actor {
#if HAS_MUTTER46
private Gala.Drawing.Canvas canvas;
#else
private Clutter.Canvas canvas;
#endif
construct {
#if HAS_MUTTER46
canvas = new Gala.Drawing.Canvas ();
#else
canvas = new Clutter.Canvas ();
#endif
content = canvas;
canvas.draw.connect ((ctx, width, height) => {
draw (ctx, width, height);

View File

@ -120,44 +120,4 @@ public class Gala.Drawing.Canvas : GLib.Object, Clutter.Content {
}
}
}
#else
public class Gala.Drawing.Canvas : GLib.Object, Clutter.Content {
public Clutter.Canvas canvas;
construct {
canvas = new Clutter.Canvas ();
canvas.draw.connect (on_draw);
}
public signal void draw (Cairo.Context cr, int width, int height);
public bool get_preferred_size (out float out_width, out float out_height) {
return canvas.get_preferred_size (out out_width, out out_height);
}
public void invalidate () {
canvas.invalidate ();
}
public void invalidate_size () {
canvas.invalidate_size ();
}
public void paint_content (Clutter.Actor actor, Clutter.PaintNode root, Clutter.PaintContext paint_context) {
canvas.paint_content (actor, root, paint_context);
}
public void set_size (int new_width, int new_height) requires (new_width >= -1 && new_height >= -1) {
canvas.set_size (new_width, new_height);
}
public void set_scale_factor (float new_scale_factor) requires (new_scale_factor > 0.0f) {
canvas.set_scale_factor (new_scale_factor);
}
private bool on_draw (Cairo.Context cr, int width, int height) {
draw (cr, width, height);
return true;
}
}
#endif