Skip to content

Commit cc8f515

Browse files
authored
Add support for Mutter 50 (#2764)
1 parent 8e314e7 commit cc8f515

30 files changed

+1255
-17
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- version: unstable
2323
mutter_pkg: libmutter-14-dev
2424
- version: development-target
25-
mutter_pkg: libmutter-17-dev
25+
mutter_pkg: libmutter-18-dev
2626
container:
2727
image: ghcr.io/elementary/docker:${{ matrix.version }}
2828

@@ -31,7 +31,7 @@ jobs:
3131
- name: Install Dependencies
3232
run: |
3333
apt update
34-
apt install -y gettext gsettings-desktop-schemas-dev libatk-bridge2.0-dev libclutter-1.0-dev libgee-0.8-dev libglib2.0-dev libgnome-desktop-4-dev libgnome-bg-4-dev libgranite-dev libgtk-3-dev ${{ matrix.mutter_pkg }} libsqlite3-dev meson systemd-dev valac valadoc
34+
apt install -y gettext gsettings-desktop-schemas-dev libatk-bridge2.0-dev libclutter-1.0-dev libgee-0.8-dev libglib2.0-dev libgnome-desktop-4-dev libgnome-bg-4-dev libgranite-dev libgtk-3-dev ${{ matrix.mutter_pkg }} libsoup-3.0-dev libsqlite3-dev meson systemd-dev valac valadoc
3535
- name: Build
3636
env:
3737
DESTDIR: out

lib/BackgroundBlurEffect.vala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,7 @@ public class Gala.BackgroundBlurEffect : Clutter.Effect {
162162
box_scale_factor = stage_view.get_scale ();
163163
last_box_scale_factor = box_scale_factor;
164164

165-
#if HAS_MUTTER49
166-
stage_view.get_layout (stage_view_layout);
167-
#else
168165
stage_view.get_layout (ref stage_view_layout);
169-
#endif
170166

171167
origin_x -= stage_view_layout.x;
172168
origin_y -= stage_view_layout.y;

meson.build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ if mutter49_dep.found()
139139
vala_flags = ['--define', 'HAS_MUTTER43', '--define', 'HAS_MUTTER44', '--define', 'HAS_MUTTER45', '--define', 'HAS_MUTTER46', '--define', 'HAS_MUTTER47', '--define', 'HAS_MUTTER48', '--define', 'HAS_MUTTER49']
140140
endif
141141

142+
mutter50_dep = dependency('libmutter-18', version: ['>= 50', '< 51'], required: false)
143+
if mutter50_dep.found()
144+
libmutter_dep = dependency('libmutter-18', version: '>= 50')
145+
mutter_dep = [
146+
libmutter_dep,
147+
dependency('mutter-mtk-18'), dependency('mutter-cogl-18'),
148+
dependency('mutter-clutter-18')
149+
]
150+
vala_flags = ['--define', 'HAS_MUTTER43', '--define', 'HAS_MUTTER44', '--define', 'HAS_MUTTER45', '--define', 'HAS_MUTTER46', '--define', 'HAS_MUTTER47', '--define', 'HAS_MUTTER48', '--define', 'HAS_MUTTER49', '--define', 'HAS_MUTTER50']
151+
endif
152+
142153
if mutter_dep.length() == 0
143154
error ('No supported mutter library found!')
144155
endif

plugins/pip/PopupWindow.vala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
198198
}
199199

200200
private Clutter.Actor on_move_begin () {
201-
#if HAS_MUTTER48
201+
#if HAS_MUTTER50
202+
set_cursor_type (Clutter.CursorType.MOVE);
203+
#elif HAS_MUTTER48
202204
display.set_cursor (Meta.Cursor.MOVE);
203205
#else
204206
display.set_cursor (Meta.Cursor.DND_IN_DRAG);
@@ -210,7 +212,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
210212
private void on_move_end () {
211213
reactive = true;
212214
update_screen_position ();
215+
#if HAS_MUTTER50
216+
set_cursor_type (Clutter.CursorType.DEFAULT);
217+
#else
213218
display.set_cursor (Meta.Cursor.DEFAULT);
219+
#endif
214220
}
215221

216222
private bool on_resize_button_press (Clutter.Event event) {
@@ -228,7 +234,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
228234
grab = resize_button.get_stage ().grab (resize_button);
229235
resize_button.event.connect (on_resize_event);
230236

237+
#if HAS_MUTTER50
238+
set_cursor_type (Clutter.CursorType.SE_RESIZE);
239+
#else
231240
display.set_cursor (Meta.Cursor.SE_RESIZE);
241+
#endif
232242

233243
return Clutter.EVENT_PROPAGATE;
234244
}
@@ -289,7 +299,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
289299

290300
update_screen_position ();
291301

302+
#if HAS_MUTTER50
303+
set_cursor_type (Clutter.CursorType.DEFAULT);
304+
#else
292305
display.set_cursor (Meta.Cursor.DEFAULT);
306+
#endif
293307
}
294308

295309
private void on_allocation_changed () {

plugins/pip/SelectionArea.vala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,23 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
115115
}
116116

117117
public void close () {
118+
#if HAS_MUTTER50
119+
set_cursor_type (Clutter.CursorType.DEFAULT);
120+
#else
118121
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
122+
#endif
119123

120124
if (modal_proxy != null) {
121125
wm.pop_modal (modal_proxy);
122126
}
123127
}
124128

125129
public void start_selection () {
130+
#if HAS_MUTTER50
131+
set_cursor_type (Clutter.CursorType.CROSSHAIR);
132+
#else
126133
wm.get_display ().set_cursor (Meta.Cursor.CROSSHAIR);
134+
#endif
127135
grab_key_focus ();
128136

129137
modal_proxy = wm.push_modal (this, true);

src/InternalUtils.vala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Gala {
1818
* set the area where clutter can receive events
1919
**/
2020
public static void set_input_area (Meta.Display display, InputArea area) {
21+
#if !HAS_MUTTER50
2122
if (Meta.Util.is_wayland_compositor ()) {
2223
return;
2324
}
@@ -83,6 +84,7 @@ namespace Gala {
8384
#else
8485
var xregion = X.Fixes.create_region (x11display.get_xdisplay (), rects);
8586
x11display.set_stage_input_region (xregion);
87+
#endif
8688
#endif
8789
}
8890

src/KeyboardManager.vala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ public class Gala.KeyboardManager : Object {
4444
}
4545

4646
private bool switch_input_source (bool backward) {
47+
#if !HAS_MUTTER50
4748
#if HAS_MUTTER46
4849
display.get_compositor ().backend.ungrab_keyboard (display.get_current_time ());
4950
#else
5051
display.ungrab_keyboard (display.get_current_time ());
52+
#endif
5153
#endif
5254

5355
var sources = settings.get_value ("sources");
@@ -71,7 +73,11 @@ public class Gala.KeyboardManager : Object {
7173
private void on_settings_changed (string key) {
7274
unowned var backend = display.get_context ().get_backend ();
7375

76+
#if HAS_MUTTER50
77+
if (key == "sources" || key == "xkb-options" || key == "xkb-model" || key == "current") {
78+
#else
7479
if (key == "sources" || key == "xkb-options" || key == "xkb-model") {
80+
#endif
7581
string[] layouts = {}, variants = {};
7682

7783
var sources = settings.get_value ("sources");
@@ -113,7 +119,12 @@ public class Gala.KeyboardManager : Object {
113119
cancellable = new GLib.Cancellable ();
114120
}
115121

122+
#if HAS_MUTTER50
123+
var description = new Meta.KeymapDescription.from_rules (settings.get_string ("xkb-model"), layout, variant, options, layouts, layouts);
124+
backend.set_keymap_async.begin (description, settings.get_uint ("current"), cancellable, (obj, res) => {
125+
#else
116126
backend.set_keymap_async.begin (layout, variant, options, settings.get_string ("xkb-model"), cancellable, (obj, res) => {
127+
#endif
117128
try {
118129
((Meta.Backend) obj).set_keymap_async.end (res);
119130
} catch (Error e) {
@@ -129,6 +140,7 @@ public class Gala.KeyboardManager : Object {
129140
#else
130141
backend.set_keymap (layout, variant, options);
131142
#endif
143+
#if !HAS_MUTTER50
132144
} else if (key == "current") {
133145
#if HAS_MUTTER49
134146
if (cancellable != null) {
@@ -149,6 +161,7 @@ public class Gala.KeyboardManager : Object {
149161
});
150162
#else
151163
backend.lock_layout_group (settings.get_uint ("current"));
164+
#endif
152165
#endif
153166
}
154167
}

src/Main.vala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ namespace Gala {
7676

7777
try {
7878
ctx.start ();
79+
#if HAS_MUTTER50
80+
if (true) {
81+
#else
7982
if (ctx.get_compositor_type () == Meta.CompositorType.WAYLAND) {
83+
#endif
8084
Gala.init_pantheon_shell (ctx);
8185
}
8286
} catch (Error e) {

src/ScreenshotManager.vala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ public class Gala.ScreenshotManager : Object {
574574
image.get_data (),
575575
image.get_stride (),
576576
Cogl.PixelFormat.BGRA_8888_PRE,
577+
#if HAS_MUTTER50
578+
null,
579+
#endif
577580
paint_flags
578581
);
579582
} else {
@@ -583,6 +586,9 @@ public class Gala.ScreenshotManager : Object {
583586
image.get_data (),
584587
image.get_stride (),
585588
Cogl.PixelFormat.ARGB_8888_PRE,
589+
#if HAS_MUTTER50
590+
null,
591+
#endif
586592
paint_flags
587593
);
588594
}

src/Widgets/MultitaskingView/WindowClone.vala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,9 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
464464
close_button.visible = false;
465465
window_title.visible = false;
466466

467-
#if HAS_MUTTER48
467+
#if HAS_MUTTER50
468+
wm.stage.set_cursor_type (Clutter.CursorType.MOVE);
469+
#elif HAS_MUTTER48
468470
wm.get_display ().set_cursor (Meta.Cursor.MOVE);
469471
#else
470472
wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);
@@ -505,7 +507,11 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
505507

506508
active_shape.show ();
507509

510+
#if HAS_MUTTER50
511+
wm.stage.set_cursor_type (Clutter.CursorType.DEFAULT);
512+
#else
508513
display.set_cursor (Meta.Cursor.DEFAULT);
514+
#endif
509515

510516
bool did_move = false;
511517

@@ -564,7 +570,11 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
564570
close_button.visible = true;
565571
window_title.visible = true;
566572

573+
#if HAS_MUTTER50
574+
wm.stage.set_cursor_type (Clutter.CursorType.DEFAULT);
575+
#else
567576
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
577+
#endif
568578

569579
if (duration > 0) {
570580
ulong handler = 0;

0 commit comments

Comments
 (0)