Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to compile against latest mutter (3.29.4+) #303

Closed
decathorpe opened this issue Jul 19, 2018 · 16 comments
Closed

fails to compile against latest mutter (3.29.4+) #303

decathorpe opened this issue Jul 19, 2018 · 16 comments

Comments

@decathorpe
Copy link

decathorpe commented Jul 19, 2018

This is due to the version bump of the libmutter interfaces from 2 to 3.

Currently meson fails like this:

Dependency libmutter found: NO
Dependency libmutter found: NO
Dependency libmutter found: NO
Dependency libmutter-0 found: NO
Dependency libmutter-1 found: NO
Dependency libmutter-2 found: NO
Dependency libmutter-2 found: NO
meson.build:251:1: ERROR:  Problem encountered: No supported mutter library found!

So, I think new checks (and more?) to add support for libmutter-3 will be necessary.

@decathorpe
Copy link
Author

@ricotz I'm trying to work on this, but I can't seem to figure out how to regenerate the mutter vapi files from the .gir files - it looks like I'm too stupid to use vapigen correctly, I'm only getting errors so far.
I'm sure you know the correct incantation for that?

@ricotz
Copy link
Contributor

ricotz commented Sep 4, 2018

@decathorpe
Copy link
Author

decathorpe commented Sep 4, 2018

Thanks!

Now the build is failing with this on fedora rawhide:

Json-1.0.gir:914.7-918.24: error: `Builder' already contains a definition for `immutable'
Json-1.0.gir:654.7-656.25: note: previous definition of `immutable' was here
Json-1.0.gir:3260.7-3264.24: error: `Parser' already contains a definition for `immutable'
Json-1.0.gir:2882.7-2884.25: note: previous definition of `immutable' was here
Gio-2.0.gir:86796.7-86800.24: error: `UnixSocketAddress' already contains a definition for `abstract'
Gio-2.0.gir:86639.7-86641.21: note: previous definition of `abstract' was here

Is that an error in the .gir files supplied by json-glib and glib, or something else?

@decathorpe
Copy link
Author

Just as a heads-up: I'm working on bringing a mutter328 compat package to fedora 29+, so support for mutter 3.30 is no longer time-critical.

@Dirli
Copy link

Dirli commented Jan 20, 2019

The topic is again relevant.
Gentoo, mutter-3.30

`[dirli pkgconfig]$ ls | grep mutt

libmutter-3.pc
mutter-clutter-3.pc
mutter-clutter-x11-3.pc
mutter-cogl-3.pc
mutter-cogl-gles2-3.pc
mutter-cogl-pango-3.pc
mutter-cogl-path-3.pc`

In dependencies only libmutter-2

P.S. mutter-3.28 ok

@worldofpeace
Copy link
Contributor

In NixOS we've also kept the mutter 3.28 package around for this.

@Dirli
Copy link

Dirli commented Jan 20, 2019

in gentoo, it's easier. The current official version of mutter-3.26. I was just being proactive)

@decathorpe
Copy link
Author

I need to do increasingly nasty things to keep supporting mutter 3.28 on fedora:

https://src.fedoraproject.org/rpms/mutter328/c/fff28bebda02111b4c534952465ff967ba7efced?branch=master

Is there any progress with porting gala to the newer mutter versions?

@worldofpeace
Copy link
Contributor

Why exactly did you need patches 70-75?

@decathorpe
Copy link
Author

Because some functionality was moved from gnome-settings-daemon to mutter with GNOME 3.32, and some GSettings keys were renamed in gsettings-desktop-schemas 3.32 - which made gala and elementary-greeter (master) SEGFAULT due to the now missing GSettings key.

So, the patch-set both adapts to the renamed GSettings key, and also adds the functionality that was moved from gnome-settings-daemon to mutter with 3.32.

The patches are backports of this upstream MR: https://gitlab.gnome.org/GNOME/mutter/merge_requests/133/commits

@Tireg
Copy link
Contributor

Tireg commented May 8, 2019

In fact I just succeeded (today) to build against mutter 3.30 on Gentoo (which is finally the official latest stable release, switching from 3.24 to 3.30, it seems that all the major distros have switched to 3.30+).

Patches are still a bit ugly so I didn't open a PR yet, but here are the instructions if anyone is interested.

Notes on the following solution

  • The file are provided as is and is still a work in progress.
  • Gala compiles with some warning, and runs almost without any flows.
  • There are still some bugs anyway, for example, I can't drag a Firefox or a Spotify window to any other workspace without crashing gala. It seems GTK windows can be moved to another workspace without any problem.
  • libmutter-3.vapi will need to be merged with the current libmutter.vapi using macros conditionnals in order to avoid breaking compatibility with any other mutter version.

Generate VAPI files

I only regenerated libmutter-3.vapi file from scratch, any other vapi are just symlinked like their v2 (mutter-clutter-3.vapi, mutter-cogl-3.vapi, mutter-cogl-pango-3.vapi and mutter-cogl-path-3.vapi)

Generation is done through the vapigen tool, provided with vala.

This can be done properly by providing the gir file provided in the mutter package of your distribution (maybe mutter-dev on binary distros like Debian or Fedora).
You will also need to provide some metadatas to vapigen so that generated vala code is correct. Metadata needs to be written by hand in order to get what you want, so this is a loooong task.

More details can be found on those links :
https://wiki.gnome.org/Projects/Vala/Bindings
https://wiki.gnome.org/Projects/Vala/Manual/GIR%20metadata%20format

The vapi files provided with gala are vala front-end for C code, and generated through the gir files provided with mutter. Gir files are introspection of Gobject code used within C code.
Mutter provides multiple gir files, one for Mutter himself (Meta-3.gir) and other are introspection of (maybe modified ?) other component (Clutter-3.gir for clutter, Cogl-3.gir for cogl, ...).

So we have a mapping like :
Meta-3.gir ==> libmutter-3.vapi
Clutter-3.gir ==> mutter-clutter-3.vapi
Cogl-3.gir ==> mutter-cogl-3.vapi
CoglPango-3.gir ==> mutter-cogl-pango-3.vapi
??? ==> mutter-cogl-path-3.vapi

On Gentoo, the GIR files of mutter are installed within /usr/lib64/mutter.

To generate the file, you can do something like this :

META_GIR="/usr/lib64/mutter/Meta-3.gir"
MUTTER_GIR_DIR=" /usr/lib64/mutter"
VAPI_DIR="./"
METADATA_DIR="./metadata/"
FINAL_LIB_NAME="libmutter-3"
vapigen-0.42 "${META_GIR}" --library "${FINAL_LIB_NAME}" --girdir "${MUTTER_GIR_DIR}" --vapidir="${VAPI_DIR}" --metadatadir="${METADATA_DIR}"

With the following statements :

  • META_GIR should be the path to the GIR file to generate from (Meta-3.gir)
  • MUTTER_GIR_DIR should be the path to the directory containing all the mutter GIR files
  • VAPI_DIR should be the path where additionnal vapi resides (the directory of gala/vapi for example).
    You will need at least mutter-clutter-3.vapi, mutter-cogl-3.vapi and mutter-cogl-pango-3.vapi in this dir.
  • METADATA_DIR should be the path to a directory containing the metadata to fix vala code generation
  • FINAL_LIB_NAME should be the name of the produced vapi (without vapi extension)

As for the metadata dir, it should contain files named after the GIR they applies to. After 3 full days of work, I ended with this metadata file :
https://gist.github.com/Tireg/d94c04e30ead7a16f24c49d96901e910

Add the new vapi file

Once you have generated the libmutter-3.vapi, you will need to :

  • Erase the old libmutter.vapi within gala/vapi with this one
  • Create a symlink libmutter-3.vapi pointing to libmutter.vapi

(it seems to work by just dropping the file as libmutter-3.vapi without erasing any file on gala, but fails on other projects like wingpanel and pantheon-greeter)

In addition to this, we need to :

  • Create a new symlink ${file}-3.vapi pointing to ${file}.vapi
  • For each file in mutter-clutter, mutter-cogl, mutter-cogl-pango, mutter-cogl-path

Fix meson dependencies

Currently, the meson files still references libmutter-2.vapi for mutter-3.30.
We need to fix the dependencies right within the meson files :
https://gist.github.com/Tireg/840230b3e1b16c740945ef64109a2629

(Note : I removed dependency on the compat.vapi because I had trouble with it since the beginning but maybe it just works with it now. I don't know what it the purpose of this file anyway.)

Fix API Changes

Mutter 3.30 removed the Screen class and moved most of its old method within Display and the new WorkspaceManager and MonitorManager classes.

After digging out, I ended up with the following patch :
https://gist.github.com/Tireg/22482d842e12864bba97784a64eca41d

Note : I needed to cast most of the loop using Clutter.Actor to Meta.WindowActor because the current vapi may still be not perfect. The Meta.Compositor.get_window_actors currently returns Clutter.Actor when it seems to always return Meta.WindowActor.

Add schema override for mutter

You may have notice a TODO in the previous patch. I found the fix latter, within a budgie-desktop PR.
Mutter dropped the support for overriding schema because GLib 2.57+ allows to do per desktop schemas override (solus-project/budgie-desktop#1523).
The following patch repairs the overrides settings :
https://gist.github.com/Tireg/a4fe6b798dcce93b9c5df6690cd4d29e

Fix header

I still had trouble because of some missing import statement within mutter headers, and I did a manual change within /usr/include/mutter/meta/meta-background.h.
You need to add within the includes :

#include <meta/display.h>

Compile

You should now be able to build it using the common meson / ninja build instructions.

@worldofpeace
Copy link
Contributor

this thread has been helpful for insights solus-project/budgie-desktop#1591

@ricotz
Copy link
Contributor

ricotz commented May 9, 2019

Binding updates can be found here https://github.com/elementary/gala/tree/wip/mutter-3.3x

@tintou
Copy link
Member

tintou commented Jun 24, 2019

I've continued the mutter-3.3x branch but the compilation fails because of MetaBackgroundGroup being a final class, I've opened a PR upstream to fix it https://gitlab.gnome.org/GNOME/mutter/merge_requests/640

@Tireg
Copy link
Contributor

Tireg commented Nov 8, 2019

This should be closed now that #566 has been merged.
Discussions upon the related issues are available in this bug report: #634

@decathorpe
Copy link
Author

Yeah, I'll close this issue since we've actually got it to compile against all mutter versions now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants