Skip to content

Commit

Permalink
Merge branch 'main' into platform-API-merge-fix-eglstreams
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Oct 19, 2023
2 parents c070fc0 + 182bf7c commit af206e7
Show file tree
Hide file tree
Showing 87 changed files with 623 additions and 348 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/close-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
run: |
snapcraft close mir-libs "22/edge/pr${{ github.event.number }}" || true
snapcraft close confined-shell "edge/mir-pr${{ github.event.number }}" || true
for snap in mir-test-tools miriway ubuntu-frame; do
for snap in confined-shell miriway; do
snapcraft close "$snap" "edge/mir-pr${{ github.event.number }}" || true
done
for snap in mir-test-tools ubuntu-frame; do
snapcraft close "$snap" "22/edge/mir-pr${{ github.event.number }}" || true
done
8 changes: 6 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ jobs:
sudo apt-add-repository --yes ppa:mir-team/dev
sudo apt-get install --no-install-recommends \
dmz-cursor-theme \
glmark2-es2 \
glmark2-es2-wayland \
lcov \
ninja-build
mesa-utils \
ninja-build \
xwayland
# deal with incompataibles preinstalled
sudo apt-get remove --yes \
Expand Down Expand Up @@ -84,7 +88,7 @@ jobs:
run: ccache --show-stats --zero-stats

- name: Test
timeout-minutes: 5
timeout-minutes: 10
env:
CTEST_OUTPUT_ON_FAILURE: 1
XDG_RUNTIME_DIR: /tmp
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ jobs:
fetch-depth: 0 # needed for version determination

- name: Build and publish the snap
uses: canonical/actions/build-snap@multiarch
uses: canonical/actions/build-snap@release
with:
architecture: ${{ matrix.architecture }}
snapcraft-token: ${{ secrets.SNAPCRAFT_TOKEN }}
launchpad-credentials: ${{ secrets.LAUNCHPAD_CREDENTIALS }}
launchpad-accept-public-upload: true
publish: ${{ github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name }}
publish-channel: 22/edge/pr${{ github.event.number }}

Expand Down Expand Up @@ -68,6 +70,7 @@ jobs:
- snap: Miriway/Miriway
track: latest
review-opts: --allow-classic
snapcraft-channel: edge

steps:
- name: Check out code
Expand All @@ -82,10 +85,13 @@ jobs:
sed -i 's@- mir-libs.*$@\0/pr${{ github.event.number }}@' snap/snapcraft.yaml
- name: Build and publish the snap
uses: canonical/actions/build-snap@multiarch
uses: canonical/actions/build-snap@release
with:
architecture: ${{ matrix.architecture }}
review-opts: ${{ matrix.review-opts }}
snapcraft-token: ${{ secrets.SNAPCRAFT_TOKEN }}
launchpad-credentials: ${{ secrets.LAUNCHPAD_CREDENTIALS }}
launchpad-accept-public-upload: true
publish: true
publish-channel: ${{ matrix.track }}/edge/mir-pr${{ github.event.number }}
snapcraft-channel: ${{ matrix.snapcraft-channel || 'stable' }}
16 changes: 11 additions & 5 deletions .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ jobs:
if ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}; then
TASKS='"lxd:ubuntu-22.04:spread/build/ubuntu:asan"
"lxd:ubuntu-22.04:spread/build/ubuntu:tsan"
"lxd:ubuntu-22.04:spread/build/ubuntu:ubsan"
"lxd:ubuntu-22.04:spread/build/ubuntu:asan_clang"
"lxd:ubuntu-22.04:spread/build/ubuntu:tsan_clang"
"lxd:ubuntu-22.04:spread/build/ubuntu:ubsan_clang"'
"lxd:ubuntu-22.04:spread/build/ubuntu:tsan_clang"'
fi
TASKS+='"lxd:alpine-3.18:spread/build/alpine:amd64"
Expand All @@ -50,7 +48,9 @@ jobs:
"lxd:fedora-38:spread/build/fedora:amd64"
"lxd:fedora-rawhide:spread/build/fedora:amd64"
"lxd:ubuntu-22.04:spread/build/sbuild:ubuntu_devel"
"lxd:ubuntu-22.04:spread/build/sbuild:ubuntu_proposed"'
"lxd:ubuntu-22.04:spread/build/sbuild:ubuntu_proposed"
"lxd:ubuntu-22.04:spread/build/ubuntu:ubsan"
"lxd:ubuntu-22.04:spread/build/ubuntu:ubsan_clang"'
echo ${TASKS:-} | jq -cs '{ "spread-task": . }' | awk '{ print "matrix=" $0 }' >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -112,7 +112,13 @@ jobs:
echo "max_size = 800M" > ${CCACHE_DIR}/ccache.conf
- name: Run Spread task
run: snap run spread-mir-ci.spread -v ${{ matrix.spread-task }}
run: snap run spread-mir-ci.spread -reuse -v ${{ matrix.spread-task }}

- name: CCache stats
run: cat ${CCACHE_DIR}/ccache.stats

- if: ${{ failure() && runner.debug }}
name: Setup upterm session
uses: lhotari/action-upterm@v1
with:
limit-access-to-actor: true
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sophie Winter <[email protected]> <[email protected]>
Sophie Winter <[email protected]> <[email protected]>
Sophie Winter <[email protected]> <[email protected]>
Sophie Winter <[email protected]> <[email protected]>
45 changes: 8 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,51 +144,22 @@ if(cmake_build_type_lower MATCHES "coverage")
endif()

if(cmake_build_type_lower MATCHES "addresssanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
if (CMAKE_COMPILER_IS_GNUCXX)
# Work around GCC bug. It should automatically link to asan when
# -fsanitize=address is used, but doesn't.
#
# Linking everything with asan is harmless and simple, so do that.
link_libraries(asan) # Workaround for LP:1413474
endif()
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
elseif(cmake_build_type_lower MATCHES "threadsanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=thread")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread")
if (CMAKE_COMPILER_IS_GNUCXX)
# Work around GCC bug. It should automatically link to tsan when
# -fsanitize=thread is used, but doesn't.
#
# Linking everything with tsan is harmless and simple, so do that.
link_libraries(tsan) # Workaround for LP:1413474
endif()
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
add_link_options(-fsanitize=thread)
elseif(cmake_build_type_lower MATCHES "ubsanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=undefined")
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
add_link_options(-fsanitize=undefined)
# "Symbol already defined" errors occur with pre-compiled headers
SET(MIR_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "Use precompiled headers" FORCE)
if (CMAKE_COMPILER_IS_GNUCXX)
# Work around GCC bug. It should automatically link to asan when
# -fsanitize=undefined is used, but doesn't.
#
# Linking everything with ubsan is harmless and simple, so do that.
link_libraries(ubsan) # Workaround for LP:1413474
endif()
# We have inline classes as interfaces used by .so's and implemented elsewhere.
# This results in multiple trivial implementations. So let's not warn about that.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=vptr")
add_compile_options(-fno-sanitize=vptr)
else()
# AddressSanitizer builds fail if we disallow undefined symbols
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
add_link_options(-Wl,--no-undefined)
endif()

enable_testing()
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindGtestGmock.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(FindPackageHandleStandardArgs)

pkg_check_modules(GTEST QUIET "gtest >= 1.8.0")
pkg_check_modules(GTEST_MAIN QUIET "gtest_main >= 1.8.0")
pkg_check_modules(GTEST QUIET gtest>=1.8.0)
pkg_check_modules(GTEST_MAIN QUIET gtest_main>=1.8.0)
if (GTEST_FOUND AND GTEST_MAIN_FOUND)
# If we can find package configuration for gtest use it!
set(GTEST_LIBRARY ${GTEST_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cmake/MirCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function (mir_generate_protocol_wrapper TARGET_NAME NAME_PREFIX PROTOCOL_FILE)
get_filename_component(PROTOCOL_NAME "${PROTOCOL_FILE}" NAME_WE)
set(OUTPUT_PATH_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${PROTOCOL_NAME}_wrapper.h")
set(OUTPUT_PATH_SRC "${CMAKE_CURRENT_BINARY_DIR}/${PROTOCOL_NAME}_wrapper.cpp")
set(PROTOCOL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_FILE}")
set(PROTOCOL_PATH "${PROJECT_SOURCE_DIR}/wayland-protocols/${PROTOCOL_FILE}")
add_custom_command(
OUTPUT "${OUTPUT_PATH_HEADER}" "${OUTPUT_PATH_SRC}"
VERBATIM
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends},
${shlibs:Depends},
xwayland,
glmark2-es2,
glmark2-es2-x11 | glmark2-es2,
glmark2-es2-wayland,
mesa-utils-extra,
dmz-cursor-theme,
Expand Down
1 change: 1 addition & 0 deletions doc/sphinx/.sphinx/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ sphinxcontrib-jquery
sphinx-notfound-page
breathe
exhale
sphinxcontrib-mermaid
69 changes: 69 additions & 0 deletions doc/sphinx/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Architecture
This document introduces the architecture of *Mir* at a high-level.

## Audience
This document is intended to provide contributors to *Mir* an overview of *Mir*'s systems. It is *not* intended to guide compositor authors.

## Index
- [APIs for compositor authors](#apis-for-compositor-authors)
- [The Mir Engine](#the-mir-engine)
- [Platforms](#platforms)
- [Supporting Libraries](#supporting-libraries)

## APIs for compositor authors
```{mermaid} high_level_diagram.mmd
```

*Mir* provides compositor authors with a set of libraries that they can use to build Wayland based shells. These libraries are:
- *miral*
- *miroil*
- *mirwayland*

### Miral
The most commonly used library is **miral**. `miral` (the "*Mir* Abstraction Layer") is an API that makes *Mir* easy for compositor authors to work with. It provides core window management concepts and an interface that is more ABI stable than Mir's internal API. While `miral` is built on the [*Mir* engine](#the-mir-engine), compositor authors are encouraged to only interact with the high-level `miral` library.

### Miroil
**miroil** is a custom library for the [Lomiri](https://lomiri.com/) folks. It is like `miral` in that it provides an abstraction over the [*Mir* engine](#the-mir-engine). However, most compositor authors will not interact with `miroil`.

### Mirwayland
Compositor authors may want to define their own wayland protocol extensions in addition to the ones that the core *Mir* implementation defines. The `mirwayland` library satisfies this requirement. This library may be used in conjunction with either `miral` or `miroil`.

## The Mir engine
```{mermaid} mirserver.mmd
```

The **mirserver** library is the core implementation of *Mir*. It serves as the engine for both `miral` and `miroil`. This library does the heavy-lifting for the compositor and, as a result, is the largest piece of *Mir*. This section will explain the primary concepts that drive the engine.

### Core Concepts
At the heart of `mirserver` are two interfaces: the **Shell** and the **Scene**. The `Shell` is responsible for fielding requests from the rest system. The `Shell` modifies the state of the `Scene` to reflect the requested changes.

For example, the `Frontend` would ask the `Shell` to initiate dragging a window. The `Shell` would then decide how to move that window to and update the state of the `Scene` to reflect that change.

### From Scene to Screen
Knowing that the `Scene` holds the state of what is to be displayed, we can talk about the **Compositor**. The `Compositor` gets the collection of items to render from the `Scene`,
renders them with the help of the [rendering platform](#platforms), and sends them off to the [display platform](#platforms) to be displayed.

### From Interaction to Shell
As stated previously, the `Shell` handles requests from the system and updates the state of the `Scene` accordingly. These requests come from a variety of sources, which we will investigate now.

**Frontend Wayland**: Responsible for connecting the Wayland protocol with the rest of *Mir*. The `WaylandConnector` class connects requests made via the Wayland protocol to the core state of the compositor.

**Frontend XWayland**: Responsible for connecting requests sent by an `XWayland` server to the rest of *Mir*. The `XWaylandConnector` establishes this connection. This frontend spawns an `XWayland` server as a subprocess.

**Input**: Handles everything having to do with input, including mouse, keyboard, touch, and more. This system interacts with the specific [input platform](#platforms) and bubbles up events through a list of `InputDispatcher`s, which enables different pieces of the software to react to events.

For example, a compositor's window manager may respond to a key press event by opening up a new terminal via a request to the `Shell`.

## Platforms
We briefly hinted at the existence of so-called "platforms" previously, but they are deserving of a dedicated section. A **Platform** is an adapter that allows the system to work across different graphics, input, and rendering stacks. They come in three flavors:
- **Display Platform**: Determines what the compositor is rendering to. This may be a physical monitor via GBM/KMS (or EGLStreams for Nvidia), an X11 or Wayland window, or a completely virtual buffer.
- **Input Platform**: Determines where the compositor is getting input from. This could be native event via `libinput`, X input events, or Wayland input events.
- **Rendering Platform**: Determines how the compositor renders the final image. For now, only a GL backend is supported.

The GBM/KMS platform is most typically what will be used, as it is the native platform. The X11 platform is useful for development. The Wayland platform is specifically useful for Ubuntu Touch, where they are hosting *Mir* in another Wayland compositor.

## Supporting Libraries
*Mir* leans on a few core libraries to support the entire system. These libraries contain data structures and utilities that are shared throughout the project, including `miral` and `miroil`.

- **Core**: Fundamental data concepts, like file descriptors and rectangles. These data structures tend not to be *Mir*-specific.
- **Common**: *Mir*-specific data concepts like *Mir* event building, logging, and timing utilities.
1 change: 0 additions & 1 deletion doc/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

extensions = [
'sphinx_design',
'sphinx_tabs.tabs',
'sphinx_reredirects',
'youtube-links',
'related-links',
Expand Down
5 changes: 5 additions & 0 deletions doc/sphinx/custom_conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ custom_extensions = [
'breathe',
'exhale',
'sphinx.ext.graphviz',
'sphinxcontrib.mermaid'
]

# Add files or directories that should be excluded from processing.
Expand Down Expand Up @@ -172,3 +173,7 @@ breathe_projects = {"Mir": "./xml/"}
breathe_default_project = "Mir"
breathe_default_members = ('members', 'undoc-members')
breathe_order_parameters_first = True

# Mermaid
mermaid_version = "10.5.0"
mermaid_d3_zoom = True
8 changes: 5 additions & 3 deletions doc/sphinx/getting_involved_in_mir.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ from the corresponding files under `spread/build`.
This creates an example shell (miral-shell) in the bin directory. This can be
run directly:

bin/miral-shell
bin/miral-app

With the default options this runs in a window on X (which is convenient for
development).

The miral-shell example is simple, don’t expect to see a sophisticated launcher
by default. You can start mir apps from the command-line. For example:
by default. Within this window you can start a terminal with Ctrl-Alt-Shift-T
(the "Shift" is needed to avoid Ubuntu's DE intercepting the input). From this
terminal you can start apps. For example:

bin/miral-run qterminal
$ gedit

To exit from miral-shell press Ctrl-Alt-BkSp.

Expand Down
14 changes: 14 additions & 0 deletions doc/sphinx/high_level_diagram.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

classDiagram
CompositorAuthor --> miral: Uses
CompositorAuthor --> miroil: Uses
CompositorAuthor --> mirwayland: Uses

miral --> mirserver: Uses
miroil --> mirserver: Uses
mirwayland --> mirserver: Uses

note for core "Universal"
note for common "Universal"
class core
class common
1 change: 1 addition & 0 deletions doc/sphinx/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ The server API is introduced here: [Introducing the MirAL API](introducing_the_m
getting_and_using_mir
getting_involved_in_mir
architecture
api/library_root
```
20 changes: 20 additions & 0 deletions doc/sphinx/mirserver.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

classDiagram
Compositor --> Scene: Get renderables
Compositor --> Display: Get outputs
Compositor --> RenderingPlatform: Handles rendering
Compositor --> DisplayPlatform: Outputs image to
Shell --> miral: Get shell behavior
Shell --> Scene: Updates
InputDispatcher <-- InputPlatform: Sends events to
Seat <-- InputDispatcher: Sends events to
Seat --> Shell: Sends events to
FrontendWayland --> Shell: Makes requests to
FrontendXWayland --> Shell: Makes request to
Scene o-- IdleHub
Scene o-- Clipboard
Scene o-- SceneChangeNotifiers


%%Server --> Core
%%Server --> Common
14 changes: 13 additions & 1 deletion examples/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
mir_add_wrapped_executable(mir_demo_client_wayland wayland_client.c)
set(OUTPUT_PATH_HEADER "${CMAKE_CURRENT_BINARY_DIR}/xdg-shell.h")
set(OUTPUT_PATH_SRC "${CMAKE_CURRENT_BINARY_DIR}/xdg-shell.c")
set(PROTOCOL_PATH "${PROJECT_SOURCE_DIR}/wayland-protocols/xdg-shell.xml")

add_custom_command(
OUTPUT "${OUTPUT_PATH_HEADER}" "${OUTPUT_PATH_SRC}"
VERBATIM
COMMAND "sh" "-c" "wayland-scanner client-header ${PROTOCOL_PATH} ${OUTPUT_PATH_HEADER}"
COMMAND "sh" "-c" "wayland-scanner private-code ${PROTOCOL_PATH} ${OUTPUT_PATH_SRC}"
)

mir_add_wrapped_executable(mir_demo_client_wayland wayland_client.c ${OUTPUT_PATH_HEADER} ${OUTPUT_PATH_SRC})
target_link_libraries (mir_demo_client_wayland PkgConfig::WAYLAND_CLIENT)
target_include_directories(mir_demo_client_wayland PRIVATE ${CMAKE_CURRENT_BINARY_DIR})


mir_add_wrapped_executable(mir_demo_client_wayland_egl_spinner spinner.cpp)
Expand Down
Loading

0 comments on commit af206e7

Please sign in to comment.