Skip to content

Commit 5678e1c

Browse files
authored
Add support for Mutter 50 (#867)
1 parent abf8a67 commit 5678e1c

22 files changed

Lines changed: 1160 additions & 15 deletions

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
- version: unstable
2323
mutter_pkg: libmutter-14-dev
2424
- version: development-target
25-
mutter_pkg: libmutter-14-dev
25+
mutter_pkg: libmutter-18-dev
26+
lightdm_vala: lightdm-vala
2627
container:
2728
image: ghcr.io/elementary/docker:${{ matrix.version }}
2829

@@ -31,7 +32,7 @@ jobs:
3132
- name: Install Dependencies
3233
run: |
3334
apt update
34-
apt install -y desktop-file-utils libgdk-pixbuf2.0-dev libgnome-desktop-3-dev libgranite-dev libgtk-3-dev libhandy-1-dev liblightdm-gobject-1-dev ${{ matrix.mutter_pkg }} libx11-dev meson valac
35+
apt install -y desktop-file-utils libgdk-pixbuf-2.0-dev libgnome-desktop-3-dev libgranite-dev libgtk-3-dev libhandy-1-dev libjson-glib-dev liblightdm-gobject-1-dev ${{ matrix.mutter_pkg }} libsoup-3.0-dev libx11-dev ${{ matrix.lightdm_vala }} meson valac
3536
- name: Build
3637
env:
3738
DESTDIR: out
@@ -75,8 +76,8 @@ jobs:
7576
DESTDIR: out
7677
run: |
7778
meson build
78-
ninja -C build install
79-
79+
ninja -C build install
80+
8081
lint:
8182
runs-on: ubuntu-latest
8283

@@ -89,4 +90,3 @@ jobs:
8990
run: |
9091
io.elementary.vala-lint -d compositor
9192
io.elementary.vala-lint -d src
92-

compositor/BackgroundBlurEffect.vala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ public class GreeterCompositor.BackgroundBlurEffect : Clutter.Effect {
3939
}
4040

4141
construct {
42-
#if HAS_MUTTER47
43-
unowned var ctx = actor.context.get_backend ().get_cogl_context ();
44-
#else
4542
unowned var ctx = Clutter.get_default_backend ().get_cogl_context ();
46-
#endif
4743

4844
actor_pipeline = new Cogl.Pipeline (ctx);
4945
actor_pipeline.set_layer_null_texture (0);

compositor/KeyboardManager.vala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public class GreeterCompositor.KeyboardManager : Object {
4848

4949
[CCode (instance_pos = -1)]
5050
public static bool handle_modifiers_accelerator_activated (Meta.Display display, bool backward) {
51+
#if !HAS_MUTTER50
5152
#if HAS_MUTTER46
5253
display.get_compositor ().backend.ungrab_keyboard (display.get_current_time ());
5354
#else
5455
display.ungrab_keyboard (display.get_current_time ());
56+
#endif
5557
#endif
5658

5759
var sources = settings.get_value ("sources");
@@ -79,7 +81,11 @@ public class GreeterCompositor.KeyboardManager : Object {
7981
private void set_keyboard_layout (GLib.Settings settings, string key) {
8082
unowned var backend = display.get_context ().get_backend ();
8183

84+
#if HAS_MUTTER50
85+
if (key == "sources" || key == "xkb-options" || key == "current") {
86+
#else
8287
if (key == "sources" || key == "xkb-options") {
88+
#endif
8389
string[] layouts = {}, variants = {};
8490

8591
var sources = settings.get_value ("sources");
@@ -111,7 +117,12 @@ public class GreeterCompositor.KeyboardManager : Object {
111117
cancellable = new GLib.Cancellable ();
112118
}
113119

120+
#if HAS_MUTTER50
121+
var description = new Meta.KeymapDescription.from_rules (settings.get_string ("xkb-model"), layout, variant, options, layouts, layouts);
122+
backend.set_keymap_async.begin (description, settings.get_uint ("current"), cancellable, (obj, res) => {
123+
#else
114124
backend.set_keymap_async.begin (layout, variant, options, settings.get_string ("xkb-model"), cancellable, (obj, res) => {
125+
#endif
115126
try {
116127
((Meta.Backend) obj).set_keymap_async.end (res);
117128
} catch (Error e) {
@@ -128,6 +139,7 @@ public class GreeterCompositor.KeyboardManager : Object {
128139
#else
129140
backend.set_keymap (layout, variant, options);
130141
#endif
142+
#if !HAS_MUTTER50
131143
} else if (key == "current") {
132144
#if HAS_MUTTER49
133145
if (cancellable != null) {
@@ -148,6 +160,7 @@ public class GreeterCompositor.KeyboardManager : Object {
148160
});
149161
#else
150162
backend.lock_layout_group (settings.get_uint ("current"));
163+
#endif
151164
#endif
152165
}
153166
}

compositor/meson.build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ if mutter49_dep.found()
6868
vala_flags = ['--define', 'HAS_MUTTER46', '--define', 'HAS_MUTTER47', '--define', 'HAS_MUTTER48', '--define', 'HAS_MUTTER49']
6969
endif
7070

71+
mutter50_dep = dependency('libmutter-18', version: ['>= 50', '< 51'], required: false)
72+
if mutter50_dep.found()
73+
libmutter_dep = dependency('libmutter-18', version: '>= 50')
74+
mutter_dep = [
75+
libmutter_dep,
76+
dependency('mutter-mtk-18'), dependency('mutter-cogl-18'),
77+
dependency('mutter-clutter-18')
78+
]
79+
vala_flags = ['--define', 'HAS_MUTTER46', '--define', 'HAS_MUTTER47', '--define', 'HAS_MUTTER48', '--define', 'HAS_MUTTER49', '--define', 'HAS_MUTTER50']
80+
endif
81+
7182
if mutter_dep.length() == 0
7283
error ('No supported mutter library found!')
7384
endif

vapi/Clutter-18.metadata

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Non mini-object
2+
ActorBox struct
3+
Margin struct
4+
PaintVolume struct
5+
Perspective struct
6+
7+
*.ref unowned
8+
* cheader_filename="clutter/clutter.h"
9+
10+
// Fix the few clutter-pango headers
11+
Text cheader_filename="clutter/clutter-pango.h"
12+
TextBuffer cheader_filename="clutter/clutter-pango.h"
13+
TextNode cheader_filename="clutter/clutter-pango.h"
14+
Actor
15+
.get_pango_context cheader_filename="clutter/clutter-pango.h"
16+
.create_pango_context cheader_filename="clutter/clutter-pango.h"
17+
.create_pango_layout cheader_filename="clutter/clutter-pango.h"
18+
19+
20+
Actor
21+
.apply_transform.matrix ref
22+
.get_abs_allocation_vertices.verts out=false
23+
Event.type#method name="get_type"
24+
25+
// ???
26+
Actor.has_pointer#method name="get_has_pointer"
27+
28+
// Not all backing symbols are deprecated
29+
Actor.pick deprecated=false
30+
31+
// Nullable return values
32+
Actor
33+
.get_parent nullable
34+
35+
// The original CType has been overridden by the annotations
36+
Actor
37+
.allocate.box ctype="const ClutterActorBox *"
38+
.get_stage ctype="ClutterActor *"
39+
Action.handle_event.event ctype="const ClutterEvent *"
40+
41+
// method/virtual-method/signal don't match
42+
Actor
43+
.event#method name="emit_event"
44+
.get_paint_volume#virtual_method name="get_paint_volume_vfunc"
45+
.get_paint_volume#virtual_method.volume out
46+
Text
47+
.activate#method name="try_activate"
48+
.insert_text#signal skip
49+
TextBuffer.get_text#virtual_method name="get_text_with_length"
50+
51+
// Default values
52+
Stage.read_pixels
53+
.width default=-1
54+
.height default=-1
55+
Stage.paint_to_buffer
56+
.data type="uint8[]"
57+
Text
58+
.position_to_coords.line_height default=null
59+
60+
// Skipped by g-i for unknown reasons
61+
LayoutManager
62+
.create_child_meta skip=false
63+
64+
// We can use static strings
65+
PaintNode
66+
.set_static_name skip=false
67+
68+
// Variadic arguments
69+
Backend
70+
.get_cogl_context skip=false
71+
Interval
72+
.new skip=false
73+
.get_interval skip=false
74+
.set_final skip=false
75+
.set_initial skip=false
76+
.set_interval skip=false
77+
LayoutManager
78+
.child_get skip=false
79+
.child_set skip=false
80+
81+
// Skipped upstream for unknown reasons
82+
Interval.register_progress_func skip=false
83+
84+
// struct/class confusion
85+
ActorBox
86+
.new skip
87+
.from_vertices skip
88+
Margin
89+
.new skip
90+
91+
// Upstream
92+
Event
93+
.get_position.position out
94+
95+
FrameListenerIface skip
96+
FrameClock.new skip
97+
98+
// Remove for clutter-2.0
99+
/////////////////////////
100+
101+
StageView.layout skip
102+
103+
Stage
104+
.paint_view.redraw_clip type="Cairo.Region"
105+
106+
// *Event should be compact classes derived from Clutter.Event
107+
Event.type skip=false
108+
AnyEvent struct=false base_type="Clutter.Event"
109+
ButtonEvent struct=false base_type="Clutter.Event"
110+
CrossingEvent struct=false base_type="Clutter.Event"
111+
DeviceEvent struct=false base_type="Clutter.Event"
112+
IMEvent struct=false base_type="Clutter.Event"
113+
KeyEvent struct=false base_type="Clutter.Event"
114+
MotionEvent struct=false base_type="Clutter.Event"
115+
PadButtonEvent struct=false base_type="Clutter.Event"
116+
PadDialEvent struct=false base_type="Clutter.Event"
117+
PadRingEvent struct=false base_type="Clutter.Event"
118+
PadStripEvent struct=false base_type="Clutter.Event"
119+
ProximityEvent struct=false base_type="Clutter.Event"
120+
ScrollEvent struct=false base_type="Clutter.Event"
121+
TouchEvent struct=false base_type="Clutter.Event"
122+
TouchpadHoldEvent struct=false base_type="Clutter.Event"
123+
TouchpadPinchEvent struct=false base_type="Clutter.Event"
124+
TouchpadSwipeEvent struct=false base_type="Clutter.Event"
125+
126+
// Keysyms used to be CLUTTER_X instead of CLUTTER_KEY_X
127+
*#constant skip
128+
CURRENT_TIME skip=false
129+
PRIORITY_REDRAW skip=false
130+
131+
// Clutter devs don't like us creating nested namespaces
132+
value_* name="value_(.+)" parent="Clutter.Value"
133+
threads_* name="threads_(.+)" parent="Clutter.Threads"
134+
135+
// There is no way to know sealed classes before GLib 2.70
136+
ColorState sealed
137+
FrameClock sealed
138+
TextureContent sealed
139+
140+
TextureContent.new_from_texture symbol_type="constructor"
141+
142+
// Possibly keep
143+
KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key"
144+
BUTTON_* skip=false name="BUTTON_(.+)" type="uint32" parent="Clutter.Button"
145+
EVENT_STOP skip=false type="bool"
146+
EVENT_PROPAGATE skip=false type="bool"

vapi/Cogl-18-custom.vala

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
namespace Cogl {
2+
public struct Color {
3+
[CCode (cname="cogl_color_init_from_4f")]
4+
public Color.from_4f (float red, float green, float blue, float alpha);
5+
[CCode (cname="cogl_color_init_from_hsl")]
6+
public Color.from_hsl (float hue, float saturation, float luminance);
7+
[CCode (cname = "_vala_cogl_color_from_string")]
8+
public static Cogl.Color? from_string (string str) {
9+
Cogl.Color color = {};
10+
if (color.init_from_string (str))
11+
return color;
12+
13+
return null;
14+
}
15+
}
16+
[CCode (cheader_filename = "cogl/cogl.h", has_type_id = false)]
17+
public struct VertexP2 {
18+
public float x;
19+
public float y;
20+
}
21+
[CCode (cheader_filename = "cogl/cogl.h", has_type_id = false)]
22+
public struct VertexP2C4 {
23+
public float x;
24+
public float y;
25+
public uint8 r;
26+
public uint8 g;
27+
public uint8 b;
28+
public uint8 a;
29+
}
30+
[CCode (cheader_filename = "cogl/cogl.h", has_type_id = false)]
31+
public struct VertexP2T2 {
32+
public float x;
33+
public float y;
34+
public float s;
35+
public float t;
36+
}
37+
[CCode (cheader_filename = "cogl/cogl.h", has_type_id = false)]
38+
public struct VertexP2T2C4 {
39+
public float x;
40+
public float y;
41+
public float s;
42+
public float t;
43+
public uint8 r;
44+
public uint8 g;
45+
public uint8 b;
46+
public uint8 a;
47+
}
48+
[CCode (cheader_filename = "cogl/cogl.h", has_type_id = false)]
49+
public struct VertexP3 {
50+
public float x;
51+
public float y;
52+
public float z;
53+
}
54+
[CCode (cheader_filename = "cogl/cogl.h", has_type_id = false)]
55+
public struct VertexP3T2 {
56+
public float x;
57+
public float y;
58+
public float z;
59+
public float s;
60+
public float t;
61+
}
62+
[CCode (cheader_filename = "cogl/cogl.h", cprefix = "COGL_PIXEL_FORMAT_", type_id = "cogl_pixel_format_get_type ()")]
63+
public enum PixelFormat {
64+
CAIRO_ARGB32_COMPAT;
65+
}
66+
}

vapi/Cogl-18.metadata

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
* cheader_filename="cogl/cogl.h"
2+
3+
Color struct
4+
5+
Color.equal.v1 type="Cogl.Color"
6+
Color.equal.v2 type="Cogl.Color"
7+
Color.from_string name="init_from_string"
8+
9+
Bitmap.* skip=false
10+
Bitmap.new_for_data.data type="owned uint8[]"
11+
Bitmap.get_buffer type="unowned Cogl.Buffer?"
12+
13+
Primitive.new skip=false
14+
15+
Texture
16+
.get_data.data type="uint8[]"
17+
.set_data.data type="uint8[]"
18+
.set_region.data type="uint8[]"
19+
20+
Texture2D
21+
.new_from_data skip=false
22+
23+
Texture.error_quark parent="Cogl.TextureError" name="quark"
24+
25+
RendererError errordomain
26+
SystemError errordomain
27+
TextureError errordomain
28+
FramebufferError errordomain
29+
ScanoutError errordomain
30+
31+
Onscreen
32+
.add_frame_callback unowned
33+
34+
A_BIT parent="Cogl.Bits" name="A"
35+
BGR_BIT parent="Cogl.Bits" name="BGR"
36+
AFIRST_BIT parent="Cogl.Bits" name="AFIRST"
37+
PREMULT_BIT parent="Cogl.Bits" name="PREMULT"
38+
DEPTH_BIT parent="Cogl.Bits" name="DEPTH"
39+
STENCIL_BIT parent="Cogl.Bits" name="STENCIL"
40+
PIXEL_FORMAT_MAX_PLANES parent = "Cogl.PixelFormat" name="MAX_PLANES"

vapi/Meta-18-custom.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Meta.Util {
2+
public static inline bool is_wayland_compositor () {
3+
return true;
4+
}
5+
}

0 commit comments

Comments
 (0)