Skip to content

Commit

Permalink
Add initial support for Mutter 40
Browse files Browse the repository at this point in the history
  • Loading branch information
tintou committed Aug 2, 2021
1 parent d12d294 commit 97313e1
Show file tree
Hide file tree
Showing 26 changed files with 1,366 additions and 34 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Expand Up @@ -32,6 +32,10 @@ jobs:
image: valalang/lint

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Lint
run: io.elementary.vala-lint -d .
run: |
io.elementary.vala-lint -d deamon
io.elementary.vala-lint -d lib
io.elementary.vala-lint -d plugins
io.elementary.vala-lint -d src
13 changes: 13 additions & 0 deletions meson.build
Expand Up @@ -126,6 +126,19 @@ if mutter338_dep.found()
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API'], language: 'c')
endif

mutter40_dep = dependency('libmutter-8', version: ['>= 40', '< 41'], required: false)
if mutter40_dep.found()
libmutter_dep = dependency('libmutter-8', version: '>= 40')
mutter_dep = [
libmutter_dep,
dependency('mutter-cogl-8'), dependency('mutter-cogl-pango-8'),
dependency('mutter-clutter-8')
]
vala_flags = ['--define', 'HAS_MUTTER330', '--define', 'HAS_MUTTER332', '--define', 'HAS_MUTTER334', '--define', 'HAS_MUTTER336', '--define', 'HAS_MUTTER338', '--define', 'HAS_MUTTER40']
add_project_arguments(['-DCLUTTER_ENABLE_COMPOSITOR_API', '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API'], language: 'c')
endif

if mutter_dep.length() == 0
error ('No supported mutter library found!')
endif
Expand Down
4 changes: 4 additions & 0 deletions plugins/pip/ShadowEffect.vala
Expand Up @@ -109,7 +109,11 @@ namespace Gala.Plugins.PIP {
shadow_cache.unset (key);
}

#if HAS_MUTTER40
public override void paint (Clutter.PaintNode node, Clutter.PaintContext context, Clutter.EffectPaintFlags flags) {
#else
public override void paint (Clutter.PaintContext context, EffectPaintFlags flags) {
#endif
var bounding_box = get_bounding_box ();

var shadow = get_shadow (context.get_framebuffer ().get_context (), (int) (bounding_box.x2 - bounding_box.x1),
Expand Down
5 changes: 5 additions & 0 deletions src/DBus.vala
Expand Up @@ -93,8 +93,13 @@ namespace Gala {
class DummyOffscreenEffect : Clutter.OffscreenEffect {
public signal void done_painting ();

#if HAS_MUTTER40
public override void post_paint (Clutter.PaintNode node, Clutter.PaintContext context) {
base.post_paint (node, context);
#else
public override void post_paint (Clutter.PaintContext context) {
base.post_paint (context);
#endif
done_painting ();
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/DBusAccelerator.vala
Expand Up @@ -50,8 +50,13 @@ namespace Gala {
foreach (string accelerator in grabbed_accelerators.get_keys ()) {
if (grabbed_accelerators[accelerator] == action) {
var parameters = new GLib.HashTable<string, Variant> (null, null);
#if !HAS_MUTTER40
parameters.set ("device-id", new Variant.uint32 (device.id));
#endif
parameters.set ("timestamp", new Variant.uint32 (timestamp));
if (device.device_node != null) {
parameters.set ("device-node", new Variant.string (device.device_node));
}

accelerator_activated (action, parameters);
}
Expand Down
19 changes: 12 additions & 7 deletions src/ScreenshotManager.vala
Expand Up @@ -353,11 +353,12 @@ namespace Gala {
paint_flags |= Clutter.PaintFlag.FORCE_CURSORS;
}

unowned var data = image.get_data ();
if (GLib.ByteOrder.HOST == GLib.ByteOrder.LITTLE_ENDIAN) {
wm.stage.paint_to_buffer (
{x, y, width, height},
scale,
image.get_data (),
ref data,
image.get_stride (),
Cogl.PixelFormat.BGRA_8888_PRE,
paint_flags
Expand All @@ -366,7 +367,7 @@ namespace Gala {
wm.stage.paint_to_buffer (
{x, y, width, height},
scale,
image.get_data (),
ref data,
image.get_stride (),
Cogl.PixelFormat.ARGB_8888_PRE,
paint_flags
Expand Down Expand Up @@ -415,11 +416,15 @@ namespace Gala {

Cairo.ImageSurface composite_stage_cursor (Cairo.ImageSurface image, Cairo.RectangleInt image_rect) {
unowned Meta.CursorTracker cursor_tracker = wm.get_display ().get_cursor_tracker ();
int x, y;
cursor_tracker.get_pointer (out x, out y, null);
Graphene.Point coords = {};
#if HAS_MUTTER40
cursor_tracker.get_pointer (coords, null);
#else
cursor_tracker.get_pointer (out coords.x, out coords.y, null);
#endif

var region = new Cairo.Region.rectangle (image_rect);
if (!region.contains_point (x, y)) {
if (!region.contains_point ((int) coords.x, (int) coords.y)) {
return image;
}

Expand All @@ -443,15 +448,15 @@ namespace Gala {
cr.paint ();

cr.set_operator (Cairo.Operator.OVER);
cr.set_source_surface (cursor_image, x - image_rect.x, y - image_rect.y);
cr.set_source_surface (cursor_image, coords.x - image_rect.x, coords.y - image_rect.y);
cr.paint ();

return (Cairo.ImageSurface)cr.get_target ();
}

async void wait_stage_repaint () {
ulong signal_id = 0UL;
signal_id = wm.stage.paint.connect_after (() => {
signal_id = wm.stage.after_paint.connect (() => {
wm.stage.disconnect (signal_id);
Idle.add (wait_stage_repaint.callback);
});
Expand Down
4 changes: 4 additions & 0 deletions src/ShadowEffect.vala
Expand Up @@ -121,7 +121,11 @@ namespace Gala {
shadow_cache.unset (key);
}

#if HAS_MUTTER40
public override void paint (Clutter.PaintNode node, Clutter.PaintContext context, Clutter.EffectPaintFlags flags) {
#else
public override void paint (Clutter.PaintContext context, EffectPaintFlags flags) {
#endif
var bounding_box = get_bounding_box ();
var width = (int) (bounding_box.x2 - bounding_box.x1);
var height = (int) (bounding_box.y2 - bounding_box.y1);
Expand Down
14 changes: 9 additions & 5 deletions src/Widgets/DwellClickTimer.vala
Expand Up @@ -73,11 +73,15 @@ namespace Gala {

seat.ptr_a11y_timeout_started.connect ((device, type, timeout) => {
var tracker = wm.get_display ().get_cursor_tracker ();
int x, y;
tracker.get_pointer (out x, out y, null);

this.x = x - (width / 2);
this.y = y - (width / 2);
Graphene.Point coords = {};
#if HAS_MUTTER40
tracker.get_pointer (coords, null);
#else
tracker.get_pointer (out coords.x, out coords.y, null);
#endif

x = coords.x - (width / 2);
y = coords.y - (width / 2);

transition.set_duration (timeout);
visible = true;
Expand Down
14 changes: 9 additions & 5 deletions src/Widgets/PointerLocator.vala
Expand Up @@ -128,11 +128,15 @@ namespace Gala {
}

var tracker = wm.get_display ().get_cursor_tracker ();
int x, y;
tracker.get_pointer (out x, out y, null);

this.x = x - (width / 2);
this.y = y - (width / 2);
Graphene.Point coords = {};
#if HAS_MUTTER40
tracker.get_pointer (coords, null);
#else
tracker.get_pointer (out coords.x, out coords.y, null);
#endif

x = coords.x - (width / 2);
y = coords.y - (width / 2);

var pivot = Graphene.Point ();
pivot.x = 0.5f;
Expand Down
42 changes: 42 additions & 0 deletions vapi/Clutter-8-custom.vala
@@ -0,0 +1,42 @@
namespace Clutter {

public struct Color {
[CCode (cname = "clutter_color_from_hls")]
public Color.from_hls (float hue, float luminance, float saturation);
[CCode (cname = "clutter_color_from_pixel")]
public Color.from_pixel (uint32 pixel);
[CCode (cname = "clutter_color_from_string")]
public Color.from_string (string str);
[CCode (cname = "clutter_color_from_string")]
public bool parse_string (string str);
}

public interface Container : GLib.Object {
public void add (params Clutter.Actor[] actors);
[CCode (cname = "clutter_container_class_find_child_property")]
public class unowned GLib.ParamSpec find_child_property (string property_name);
[CCode (cname = "clutter_container_class_list_child_properties")]
public class unowned GLib.ParamSpec[] list_child_properties ();
}

public struct Units {
[CCode (cname = "clutter_units_from_cm")]
public Units.from_cm (float cm);
[CCode (cname = "clutter_units_from_em")]
public Units.from_em (float em);
[CCode (cname = "clutter_units_from_em_for_font")]
public Units.from_em_for_font (string font_name, float em);
[CCode (cname = "clutter_units_from_mm")]
public Units.from_mm (float mm);
[CCode (cname = "clutter_units_from_pixels")]
public Units.from_pixels (int px);
[CCode (cname = "clutter_units_from_pt")]
public Units.from_pt (float pt);
[CCode (cname = "clutter_units_from_string")]
public Units.from_string (string str);
}

[CCode (cheader_filename = "clutter/clutter.h", has_copy_function = false, has_destroy_function = false, has_type_id = false)]
public struct Capture {
}
}

0 comments on commit 97313e1

Please sign in to comment.