In fcfe90aa, multiple for loops were replaced with META_WAYLAND_SURFACE_FOREACH_SUBSURFACE. However, this substitution was not side-effect free, and introduced a null-pointer dereference risk as shown in the example below: Old: for (n = g_node_first_child (surface->subsurface_branch_node); n; n = g_node_next_sibling (n)) { if (G_NODE_IS_LEAF (n)) continue; meta_wayland_surface_update_outputs_recursively (n->data); } n is checked for NULL during each loop in the condition expression. Therefore, when `G_NODE_IS_LEAF (n)` is called, `n` is guaranteed not to be NULL. Note also that g_node_first_child is also NULL-safe since it performs a NULL check internally. New: META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface) meta_wayland_surface_update_outputs_recursively (subsurface_surface); = for (GNode *G_PASTE(__n, __LINE__) = meta_get_first_subsurface_node ((surface)); \ (subsurface = (G_PASTE (__n, __LINE__) ? G_PASTE (__n, __LINE__)->data : NULL)); \ G_PASTE (__n, __LINE__) = meta_get_next_subsurface_sibling (G_PASTE (__n, __LINE__))) In the new logic `subsurface` is still checked for NULL in the loop condition. However, in the new loop init: ... meta_get_first_subsurface_node (MetaWaylandSurface *surface) ... n = g_node_first_child (surface->subsurface_branch_node); if (!G_NODE_IS_LEAF (n)) ... The above implementation performs a `G_NODE_IS_LEAF` call, which performs a dereference on `n`, without first checking for NULLs. This NULL dereference triggers the following gnome-shell crash: Core was generated by `/usr/bin/gnome-shell'. Program terminated with signal SIGSEGV, Segmentation fault. #0 meta_get_first_subsurface_node (surface=0x55d589623450) at ../src/wayland/meta-wayland-surface.h:399 #1 pointer_can_grab_surface (pointer=0x7f6dc4012700, surface=0x55d589623450) at ../src/wayland/meta-wayland-pointer.c:1306 #2 0x00007f6ddb94d509 in meta_wayland_pointer_can_grab_surface (pointer=<optimized out>, surface=surface@entry=0x55d589623450, serial=serial@entry=996) at ../src/wayland/meta-wayland-pointer.c:1321 #3 0x00007f6ddb950d05 in meta_wayland_seat_get_grab_info (seat=seat@entry=0x55d586c24f20, surface=0x55d589623450, serial=996, require_pressed=require_pressed@entry=0, x=x@entry=0x0, y=y@entry=0x0) at ../src/wayland/meta-wayland-seat.c:467 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2655>
Mutter
Mutter is a Wayland display server and X11 window manager and compositor library.
When used as a Wayland display server, it runs on top of KMS and libinput. It implements the compositor side of the Wayland core protocol as well as various protocol extensions. It also has functionality related to running X11 applications using Xwayland.
When used on top of Xorg it acts as a X11 window manager and compositing manager.
It contains functionality related to, among other things, window management, window compositing, focus tracking, workspace management, keybindings and monitor configuration.
Internally it uses a fork of Cogl, a hardware acceleration abstraction library used to simplify usage of OpenGL pipelines, as well as a fork of Clutter, a scene graph and user interface toolkit.
Mutter is used by, for example, GNOME Shell, the GNOME core user interface, and by Gala, elementary OS's window manager. It can also be run standalone, using the command "mutter", but just running plain mutter is only intended for debugging purposes.
Contributing
To contribute, open merge requests at https://gitlab.gnome.org/GNOME/mutter.
It can be useful to look at the documentation available at the Wiki.
The API documentation is available at:
- Meta: https://gnome.pages.gitlab.gnome.org/mutter/meta/
- Clutter: https://gnome.pages.gitlab.gnome.org/mutter/clutter/
- Cally: https://gnome.pages.gitlab.gnome.org/mutter/cally/
- Cogl: https://gnome.pages.gitlab.gnome.org/mutter/cogl/
- CoglPango: https://gnome.pages.gitlab.gnome.org/mutter/cogl-pango/
Coding style and conventions
See HACKING.md.
Git messages
Commit messages should follow the GNOME commit message
guidelines. We require an URL
to either an issue or a merge request in each commit. Try to always prefix
commit subjects with a relevant topic, such as compositor:
or
clutter/actor:
, and it's always better to write too much in the commit
message body than too little.
Default branch
The default development branch is main
. If you still have a local
checkout under the old name, use:
git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
License
Mutter is distributed under the terms of the GNU General Public License, version 2 or later. See the COPYING file for detalis.