From edfd1880c9e20d5a154530de73387f3a5570f85f Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 18 Dec 2023 17:30:53 +0100 Subject: [PATCH] docs: Move the gitlab wiki and other docs to the docs/ directory Let's try to consolidate our documentation in doc/ in the repo. This includes some documentation from README.md, the HACKING.md coding style and the gitlab wiki. The README.md file now links to all top-level topics (i.e. not reachable via other topics). This also includes a few small changes to make things more consistent. Part-of: --- README.md | 78 +++-------------- doc/code-overview.md | 25 ++++++ HACKING.md => doc/coding-style.md | 0 doc/debugging.md | 92 ++++++++++++++++++++ doc/frame-scheduling.md | 14 ++++ doc/git-conventions.md | 49 +++++++++++ doc/monitor-configuration.md | 15 ++-- doc/mutter-relationships.md | 135 ++++++++++++++++++++++++++++++ tools/uncrustify.cfg | 2 +- 9 files changed, 331 insertions(+), 79 deletions(-) create mode 100644 doc/code-overview.md rename HACKING.md => doc/coding-style.md (100%) create mode 100644 doc/debugging.md create mode 100644 doc/frame-scheduling.md create mode 100644 doc/git-conventions.md create mode 100644 doc/mutter-relationships.md diff --git a/README.md b/README.md index a6bd29b87..fdaac7f45 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,17 @@ debugging purposes. 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](https://gitlab.gnome.org/GNOME/mutter/-/wikis/home). +It can be useful to look at the documentation and API references below first. -The API documentation is available at: +## Documentation + +- [Coding style and conventions](doc/coding-style.md) +- [Git conventions](doc/git-conventions.md) +- [Code overview](doc/code-overview.md) +- [Debugging](doc/debugging.md) +- [Monitor configuration](doc/monitor-configuration.md) + +## API Reference - Meta: - Clutter: @@ -38,71 +45,6 @@ The API documentation is available at: - CoglPango: - Mtk: -## Coding style and conventions - -See [HACKING.md](./HACKING.md). - -## Git messages - -Commit messages should follow the [GNOME commit message -guidelines](https://wiki.gnome.org/Git/CommitMessages). 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. - -If a commit fixes an issue and that issue should be closed, add URL to it in -the bottom of the commit message and prefix with `Closes:`. - -Do not add any `Part-of:` line, as that will be handled automatically when -merging. - -### The Fixes tag - -If a commit fixes a regression caused by a particular commit, it can be marked -with the `Fixes:` tag. To produce such a tag, use - -``` -git show -s --pretty='format:Fixes: %h (\"%s\")' -``` - -or create an alias - -``` -git config --global alias.fixes "show -s --pretty='format:Fixes: %h (\"%s\")'" -``` - -and then use - -``` -git fixes -``` - -### Example - -``` -compositor: Also consider dark matter when calculating paint volume - -Ignoring dark matter when calculating the paint volume missed the case where -compositing happens in complete vacuum. - -Fixes: 123abc123ab ("compositor: Calculate paint volume ourselves") -Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1234 -``` - -## Default branch - -The default development branch is `main`. If you still have a local -checkout under the old name, use: -```sh -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, diff --git a/doc/code-overview.md b/doc/code-overview.md new file mode 100644 index 000000000..4f4b78a98 --- /dev/null +++ b/doc/code-overview.md @@ -0,0 +1,25 @@ +# Code Overview + +Mutter consists of four relatively distinguished and isolated parts. + +## Cogl + +Hardware acceleration pipeline abstraction layer. Handles things like allocating framebuffer, allocating, importing and drawing textures, internally using OpenGL. Originally a fork of [the Cogl project](https://gitlab.gnome.org/GNOME/cogl). + +## Clutter + +Compositing toolkit, containing an actor and render node based scene graph, and has features such as input event routing, transformation and animation. Handles compositing, both Wayland surfaces, X11 windows, and is the basis of the UI toolkit implemented by [GNOME Shell](https://gitlab.gnome.org/GNOME/gnome-shell). Originally a fork of [the Clutter project](https://gitlab.gnome.org/GNOME/clutter). + +* [Frame Scheduling](frame-scheduling.md) + +## Mtk + +The Meta Toolkit containing utilities shared by other parts of mutter. + +## Mutter + +The display server and window manager library. Contains a X11 window manager and compositing manager implementation, as well as a Wayland display server implementation. + +* [Compositor stage and hardware relationships](mutter-relationships.md) +* [Window constraints](how-constraints-works.txt) +* [How to get focus right](how-to-get-focus-right.txt) diff --git a/HACKING.md b/doc/coding-style.md similarity index 100% rename from HACKING.md rename to doc/coding-style.md diff --git a/doc/debugging.md b/doc/debugging.md new file mode 100644 index 000000000..807c3cc98 --- /dev/null +++ b/doc/debugging.md @@ -0,0 +1,92 @@ +# Debugging + +## Nested D-Bus session + +### Installing + +Download and place [dbus-session.sh](uploads/a209c8f1fe6b51df669b58bab1300199/dbus-session.sh) in `~/.local/bin/` and make it executable. + +### Using + +To create a nested D-Bus user session, run + +```sh +dbus-session.sh -n +``` + +This will create a D-Bus session, and attach to it. + +To attach to the same session from another terminal, run + +```sh +dbus-session.sh -x +``` + +## Nested mutter or gnome-shell + +To run a nested mutter or gnome-shell instance, i.e. when you are presented with a floating window running mutter or gnome-shell, first enter a [nested D-Bus session](#nested-d-bus-session), then pass `--nested` to either gnome-shell or mutter. E.g. + +```sh +mutter --nested +``` + +## Headless GNOME Shell and GNOME Remote Desktop + +First create [nested D-Bus session](#nested-d-bus-session). In this, run gnome-shell in headless mode with a virtual monitor. E.g. + +```sh +[jonas@localhost gnome-shell]$ dbus-session.sh -n +[ D-Bus 60ff ][jonas@localhost gnome-shell]$ gnome-shell --headless --virtual-monitor 1280x720 +``` + +```sh +[jonas@localhost gnome-remote-desktop]$ dbus-session.sh -x +[ D-Bus 60ff ][jonas@localhost gnome-remote-desktop]$ ./build/src/gnome-remote-desktop-daemon +``` + + + +## Reproducing CI test failures locally + +1. Create a podman that can run gdb locally using the same image used in CI. The example below uses the tag `x86_64-2022-01-20` but this will depend on the image used by the failed CI job. The Fedora version may also differ. + + ```sh + podman pull registry.gitlab.gnome.org/gnome/mutter/fedora/35:x86_64-2022-01-20 + podman run -t -i --cap-add=SYS_PTRACE registry.gitlab.gnome.org/gnome/mutter/fedora/35:x86_64-2022-01-20 bash -l + ``` + +2. Clone, build and install mutter inside the container + + ```sh + git clone https://gitlab.gnome.org/[your-user]/mutter.git -b [merge-request-branch] + cd mutter + meson build + ninja -C build install + ``` + +3. Install debug utilities + + ```sh + dnf install -y gdb + ``` + +4. Replicate a environment and run the test inside gdb. What you need here depends on the test that needs investigation. In the simplest case, the following is enough: + + ```sh + export XDG_RUNTIME_DIR=$PWD/runtime-dir + mkdir -p $XDG_RUNTIME_DIR + ./src/tests/meta-dbus-runner.py xvfb-run meson test -C build --setup plain --gdb failing-test-case + ``` + + The need for `xvfb-run` depends on whether the test case uses the nested backend or the headless backend. + + If it involves screen casting, it becomes a bit more complicated: + + ```sh + export XDG_RUNTIME_DIR=$PWD/runtime-dir + mkdir -p $XDG_RUNTIME_DIR + ./src/tests/meta-dbus-runner.py bash -l + pipewire& + wireplumber& + meson test -C build --setup plain --gdb failing-test-case + ``` diff --git a/doc/frame-scheduling.md b/doc/frame-scheduling.md new file mode 100644 index 000000000..7fa550cb2 --- /dev/null +++ b/doc/frame-scheduling.md @@ -0,0 +1,14 @@ +# Frame scheduling + +`ClutterFrameClock` state diagram. + +```mermaid +stateDiagram + Init --> Scheduled : schedule update() -> now + Idle --> Scheduled : schedule update() -> given presentation time + Scheduled --> Dispatching : target time hit + Dispatching --> PendingPresented : queued page flip + Dispatching --> Idle : no queued page flip + PendingPresented --> Scheduled : page flipped, if recent schedule update + PendingPresented --> Idle : page flipped +``` diff --git a/doc/git-conventions.md b/doc/git-conventions.md new file mode 100644 index 000000000..3c59ed81a --- /dev/null +++ b/doc/git-conventions.md @@ -0,0 +1,49 @@ +# Git conventions + +## Commit Messages + +Commit messages should follow the [GNOME commit message +guidelines](https://wiki.gnome.org/Git/CommitMessages). 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. + +If a commit fixes an issue and that issue should be closed, add URL to it in +the bottom of the commit message and prefix with `Closes:`. + +Do not add any `Part-of:` line, as that will be handled automatically when +merging. + +### The Fixes tag + +If a commit fixes a regression caused by a particular commit, it can be marked +with the `Fixes:` tag. To produce such a tag, use + +``` +git show -s --pretty='format:Fixes: %h (\"%s\")' +``` + +or create an alias + +``` +git config --global alias.fixes "show -s --pretty='format:Fixes: %h (\"%s\")'" +``` + +and then use + +``` +git fixes +``` + +### Example + +``` +compositor: Also consider dark matter when calculating paint volume + +Ignoring dark matter when calculating the paint volume missed the case where +compositing happens in complete vacuum. + +Fixes: 123abc123ab ("compositor: Calculate paint volume ourselves") +Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1234 +``` diff --git a/doc/monitor-configuration.md b/doc/monitor-configuration.md index 46c107837..a061ee5c2 100644 --- a/doc/monitor-configuration.md +++ b/doc/monitor-configuration.md @@ -1,8 +1,6 @@ -Monitor configuration -===================== +# Monitor configuration -File locations --------------- +## File locations Monitor configurations are stored as XML files called `monitors.xml` on the file system. There are two types of locations for the XML file: the system level and @@ -16,8 +14,7 @@ The directory for the user level configuration is defined in accordance to the $XDG_CONFIG_HOME environment variable defined in the XDG Base Directory Specification. The default is `~/.config/monitors.xml` -File contents -------------- +## File contents A configuration file consists of an XML document with the root element ``. In this document multiple configurations are stored as @@ -28,8 +25,7 @@ Each configuration corresponds to a specific hardware setup, where a given set of monitors are connected to the computer. There can only be one configuration per hardware setup. -Writing configuration ---------------------- +## Writing configuration Monitor configurations are managed by Mutter via the Display panel in Settings, which uses a D-Bus API to communicate with Mutter. Each time a new configuration @@ -39,8 +35,7 @@ updated content. Previously defined monitor configurations for hardware state other than the current are left intact. -Configuration policy --------------------- +## Configuration policy The monitor configuration policy determines how Mutter configures monitors. This can mean for example in what order configuration files should be preferred, or diff --git a/doc/mutter-relationships.md b/doc/mutter-relationships.md new file mode 100644 index 000000000..7d6dcc720 --- /dev/null +++ b/doc/mutter-relationships.md @@ -0,0 +1,135 @@ +# Compositor stage and hardware relationships + +## Brief description of components + + - `MetaLogicalMonitor` is one monitor or more monitor occupying the same region of the compositor space. E.g. when mirroring two monitors, both belong to the same logical monitor. + - `MetaMonitor` is a single physical monitor, but it can sometimes consist of more than one separate panel (for instance, 5K tiled monitors which literally require 2 cables due to lack of bandwidth) + - `MetaOuptut` is a connector e.g. a DisplayPort connector or HDMI connector. + - `MetaCrtc` represents a component on the display hardware that channels video memory to connectors. + +## Entity relationship diagram + +```mermaid +erDiagram + MetaBackend ||--|| MetaMonitorManager : owns + MetaBackend ||--|{ MetaGpu : owns + MetaBackend ||--|| ClutterStage : owns + MetaGpu ||--|{ MetaCrtc : owns + MetaGpu ||--|{ MetaOutput : owns + MetaCrtc |o..o{ MetaOutput : assigned + MetaBackend ||--|{ MetaVirtualMonitor : owns + MetaVirtualMonitor ||--|| MetaCrtc : owns + MetaVirtualMonitor ||--|| MetaOutput : owns + MetaMonitorManager ||--|{ MetaMonitor : owns + MetaMonitorManager ||--|{ MetaLogicalMonitor : owns + MetaLogicalMonitor ||..|{ MetaMonitor : has + MetaMonitor ||..|{ MetaOutput : has + ClutterStage ||--|{ ClutterStageView : has + ClutterStageView ||..|| MetaCrtc : corresponds + ClutterStageView ||--|| ClutterFrameClock : owns + ClutterStageView ||..|| MetaLogicalMonitor : derive-scale +``` + +## Class diagrams + +`MetaBackend`, `MetaGpu` and `MetaMonitorManager` class diagrams. + +```mermaid +classDiagram + MetaBackend <-- MetaBackendNative + MetaBackend <-- MetaBackendX11 + class MetaBackend{ + MetaMonitorManager monitor_manager + List~MetaGpu~ gpus + } + MetaGpu <-- MetaGpuKms + MetaGpu <-- MetaGpuXrandr + class MetaGpu{ + List~MetaOutput~ + List~MetaCrtc~ + } + MetaMonitorManager <-- MetaMonitorManagerNative + MetaMonitorManager <-- MetaMonitorManagerXrandr + class MetaMonitorManager{ + List~MetaMonitor~ monitors + List~MetaLogicalMonitor~ logical_monitors + } +``` + +`MetaLogicalMonitor`, `MetaMonitor`, `MetaOutput` and `MetaCrtc` class diagrams. + +```mermaid +classDiagram + MetaLogicalMonitor + class MetaLogicalMonitor{ + List~MetaMonitor~ + } + MetaMonitor <-- MetaMonitorNormal + MetaMonitor <-- MetaMonitorTiled + class MetaMonitorNormal{ + MetaOutput output + } + class MetaMonitorTiled{ + List~MetaOutput~ output + } + MetaOutput <-- MetaOutputNative + MetaOutputNative <-- MetaOutputKms + MetaOutputNative <-- MetaOutputVirtual + MetaOutput <-- MetaOutputXrandr + MetaCrtc <-- MetaCrtcNative + MetaCrtcNative <-- MetaCrtcKms + MetaCrtcNative <-- MetaCrtcVirtual + MetaCrtc <-- MetarCrtcXrandr +``` + +`ClutterStage` and `ClutterStageView` class diagram when using the Wayland session. + +```mermaid +classDiagram + class ClutterStage{ + List~ClutterStageView~ + } + class ClutterStageView{ + MetaCrtc crtc + } +``` + +`MetaKms` class diagram. + +```mermaid +classDiagram + class MetaKms{ + List~MetaKmsDevice~ devices + } + class MetaKmsDevice{ + List~MetaKmsConnector~ + List~MetaKmsCrtc~ + List~MetaKmsPlane~ + MetaKmsImplDevice impl_device + } + MetaKms "many" --> MetaKmsDevice : Owns + MetaKmsDevice --> MetaKmsImplDevice : Owns + MetaKmsImplDevice <-- MetaKmsImplDeviceAtomic + MetaKmsImplDevice <-- MetaKmsImplDeviceSimple +``` + +## Native backend and mode setting + + * `MetaGpuKms`, `MetaCrtcKms` and `MetaOutputKms` are used for configuration. + * `MetaKmsDevice`, `MetaKmsCrtc`, `MetaKmsConnector` and `MetaKmsPlane` are abstractions on top of kernel mode setting concepts. + +```mermaid +erDiagram + MetaBackendNative ||--|{ MetaGpuKms : owns + MetaBackendNative ||--|| MetaKms : owns + MetaKms ||--|{ MetaKmsDevice : owns + MetaKmsDevice ||--|{ MetaKmsCrtc : owns + MetaKmsDevice ||--|{ MetaKmsConnector : owns + MetaKmsDevice ||--|{ MetaKmsPlane : owns + MetaGpuKms ||--|{ MetaCrtcKms : owns + MetaGpuKms ||--|{ MetaOutputKms : owns + MetaCrtcKms |o..o{ MetaOutputKms : assigned + MetaGpuKms |o..o| MetaKmsDevice : associated + MetaCrtcKms |o..o| MetaKmsCrtc : associated + MetaOutputKms |o..o| MetaKmsConnector : associated +``` diff --git a/tools/uncrustify.cfg b/tools/uncrustify.cfg index f32b94186..3ab65140d 100644 --- a/tools/uncrustify.cfg +++ b/tools/uncrustify.cfg @@ -1,6 +1,6 @@ # Run `uncrustify --show-config` to see documentation for these options. # -# See also: https://gitlab.gnome.org/GNOME/mutter/-/blob/master/HACKING.md +# See also: https://gitlab.gnome.org/GNOME/mutter/-/blob/main/doc/coding-style.md ################################################################################# # CHANGES