Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/.jira_sync_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ settings:
- Testing
label_mapping:
enhancement: Story

15 changes: 12 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**What is WLCS**: A protocol-conformance test suite for Wayland compositors. Unlike previous test suites that use protocol extensions, WLCS uses compositor-provided integration modules loaded as shared libraries (.so files). Tests run in-process with the compositor, enabling easier debugging and consistent timing.

**Core Components**:

- `include/wlcs/display_server.h`: Integration API that compositors must implement (`WlcsServerIntegration`, `WlcsDisplayServer` structs)
- `src/`: Test infrastructure (test runner, client/server helpers, protocol wrappers)
- `tests/`: Protocol conformance tests for wl_compositor, xdg_shell, layer_shell, input methods, etc.
Expand All @@ -15,17 +16,20 @@
## Test Infrastructure

**Base Classes** (see `include/in_process_server.h`):

- `InProcessServer`: GTest fixture that creates a `Server` instance. Use `SetUp()/TearDown()` explicitly
- `StartedInProcessServer`: Auto-starts the server in constructor. Most tests inherit from this

**Creating Test Clients**:

```cpp
wlcs::Client client{the_server()}; // Creates Wayland client connection
wlcs::Surface surface{client}; // Creates wl_surface
client.roundtrip(); // Block until server processes requests
```

**Simulating Input** (see `include/wlcs/pointer.h`, `include/wlcs/touch.h`):

```cpp
auto pointer = the_server().create_pointer();
pointer.move_to(100, 200); // Absolute coordinates
Expand All @@ -46,16 +50,19 @@ touch.up();
Follow the [Canonical Mir C++ Guide](https://canonical-mir.readthedocs-hosted.com/stable/contributing/reference/cppguide/).

**Requirements**:

- C++20 required (`CMAKE_CXX_STANDARD 20`)
- Strict warnings: `-Werror` enabled by default (toggle with `WLCS_FATAL_COMPILE_WARNINGS`)

**Key Conventions**:

- Headers use include guards (`#ifndef WLCS_*_H_`)
- Wayland objects wrapped in RAII types (see `WlHandle<T>` in `wl_handle.h`)
- Helper timeouts: `wlcs::helpers::a_short_time()` (for negative tests), `wlcs::helpers::a_long_time()` (for operation timeouts)
- Test structure: Arrange (create surfaces/clients), Act (inject input/commit), Assert (check window focus/position)

**Testing Protocol Errors**: Use `expect_protocol_error.h` to verify compositor rejects invalid client requests:

```cpp
EXPECT_PROTOCOL_ERROR(client, &interface_name, error_code, {
// code that should trigger error
Expand All @@ -65,12 +72,14 @@ EXPECT_PROTOCOL_ERROR(client, &interface_name, error_code, {
## Common Tasks

**Adding Protocol Tests**:

1. Add `.xml` to `src/protocol/` if not present
2. Create wrapper class in `include/` (follow pattern from `layer_shell_v1.h`)
3. Implement wrapper in `src/` (generate protocol bindings in CMake)
4. Write tests in `tests/` inheriting from `StartedInProcessServer`
1. Create wrapper class in `include/` (follow pattern from `layer_shell_v1.h`)
1. Implement wrapper in `src/` (generate protocol bindings in CMake)
1. Write tests in `tests/` inheriting from `StartedInProcessServer`

**Protocol Version Handling**: Use `VersionSpecifier` (see `version_specifier.h`) to bind interfaces:

```cpp
auto shell = client.bind_if_supported<xdg_wm_base>(wlcs::AtLeast(2));
```
26 changes: 26 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PreCommit

on:
pull_request:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
PreCommit:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.1
- uses: pre-commit-ci/lite-action@v1.1.0
if: always()
with:
msg: "pre-commit: apply automatic fixes"
2 changes: 1 addition & 1 deletion .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Set up Spread
run: |
set -euo pipefail
set -euo pipefail
sudo snap install spread-mir-ci
sudo snap run lxd init --auto

Expand Down
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Recommended workflow:
# - `git add --verbose --patch` to stage changes
# - `git commit` to commit them
# - rinse and repeat, if pre-commit wants / applied changes

exclude: ^COPYING

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.22
hooks:
- id: mdformat
additional_dependencies:
- mdformat-black
- mdformat-beautysh
- mdformat-gfm
- mdformat-myst
- setuptools # Necessary until beautysh fix their stuff, see: https://github.com/hukkin/mdformat/issues/442

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.32
hooks:
- id: pymarkdown
args:
- --config=.pymarkdown.json
- fix
46 changes: 46 additions & 0 deletions .pymarkdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"plugins": {
"selectively_enable_rules": true,
"heading-style": {
"enabled": true,
"style": "atx"
},
"commands-show-output": {
"enabled": true
},
"no-missing-space-atx": {
"enabled": true
},
"blanks-around-headings": {
"enabled": true
},
"heading-start-left": {
"enabled": true
},
"no-trailing-punctuation": {
"enabled": true,
"punctuation": ".,;。,;"
},
"blanks-around-fences": {
"enabled": true,
"list_items": false
},
"blanks-around-lists": {
"enabled": true
},
"hr-style": {
"enabled": true
},
"no-empty-links": {
"enabled": true
},
"no-alt-text": {
"enabled": true
}
},
"extensions": {
"front-matter" : {
"enabled" : true
}
}
}
1 change: 0 additions & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ License: GPL-2+
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".

1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,3 @@ int main(int argc, char** argv)
}
return EXIT_SUCCESS;
}

2 changes: 1 addition & 1 deletion src/protocol/gtk-primary-selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@
</description>
</event>
</interface>
</protocol>
</protocol>
2 changes: 1 addition & 1 deletion src/protocol/input-method-unstable-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,4 @@
</request>
</interface>

</protocol>
</protocol>
2 changes: 1 addition & 1 deletion src/protocol/input-method-unstable-v2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<event name="deactivate">
<description summary="deactivate event">
Notification that no focused text input currently needs an active
Notification that no focused text input currently needs an active
input method on this seat.

This event marks the zwp_input_method_v2 object as inactive. The
Expand Down
2 changes: 1 addition & 1 deletion tests/text_input_v2_with_input_method_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,4 @@ TEST_F(TextInputV2WithInputMethodV1Test, input_method_can_set_direction)
input_method_context->serial,
direction);
app_client_wait_for_input_client_roundtrip([&]() { return has_received_text_direction; });
}
}
1 change: 0 additions & 1 deletion tools/make_release_tarball
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ fi

mv $SCRATCH_DIR/$VERSIONED_NAME.tar.xz .
echo "$VERSIONED_NAME.tar.xz successfully created and tested"