diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..93002767f9 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: MIT +# Copyright (C) 2024 Roman Gilg + +WarningsAsErrors: "*, +-clang-diagnostic-unused-lambda-capture, +-clang-diagnostic-deprecated-declarations +" + +Checks: "-*, +clang-analyzer-cplusplus.NewDelete, +clang-analyzer-unix.Malloc +" diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..c200a78a0a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT +github: romangg diff --git a/.github/actions/coverage/action.yml b/.github/actions/coverage/action.yml new file mode 100644 index 0000000000..3f327a1d04 --- /dev/null +++ b/.github/actions/coverage/action.yml @@ -0,0 +1,40 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT +name: Report Coverage +description: Uses gcovr to report coverage +inputs: + gcov-exe: + description: Set custom gcov executable, e.g. 'llvm-cov gcov' for clang. + required: false + default: "gcov" +runs: + using: "composite" + steps: + - run: python -m venv venv && source venv/bin/activate + shell: sh + - run: source venv/bin/activate && pip install --upgrade gcovr==7.2 + shell: sh + - run: mkdir coverage-html + shell: sh + # TODO(romangg): --gcov-ignore-errors=no_working_dir_found is set because + # gcov executable is failing to find Catch2 from FetchContent. Needs to be + # reported as an issue in respective projects and tested again later on. + - run: + "source venv/bin/activate && gcovr -s \ + --xml-pretty --xml coverage.xml \ + --html-details coverage-html/coverage.html \ + --gcov-executable '${{ inputs.gcov-exe }}' \ + --gcov-ignore-errors=no_working_dir_found \ + --exclude-throw-branches \ + -e build -r . build" + shell: sh + - name: Upload xml + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage.xml + - name: Upload html + uses: actions/upload-artifact@v4 + with: + name: coverage-html + path: coverage-html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eee9e07abc..8ab52d2415 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Build on: workflow_call: @@ -16,6 +18,11 @@ on: required: false type: string default: '' + cmake-args: + description: Specify additional CMake arguments + required: false + type: string + default: '' jobs: build: name: Build @@ -36,7 +43,7 @@ jobs: if: ${{ inputs.cmake-preset != '' }} run: echo "cmake-preset=--preset ${{ inputs.cmake-preset }}" >> $GITHUB_ENV - name: Configure - run: cmake ${{ env.cmake-preset }} -S . -B build + run: cmake ${{ env.cmake-preset }} ${{ inputs.cmake-args }} -S . -B build - name: Build run: cmake --build build - name: Tar artifact (keep permissions) diff --git a/.github/workflows/change.yml b/.github/workflows/change.yml index c051e3127d..5621b9187c 100644 --- a/.github/workflows/change.yml +++ b/.github/workflows/change.yml @@ -1,45 +1,82 @@ -name: Main Checks +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT +name: CI on: - push - pull_request jobs: + get: + runs-on: ubuntu-latest + outputs: + image: ${{ steps.setvar.outputs.result }} + env: + prefix: registry.gitlab.com/kwinft/ci-images/archlinux/como-base + result: '' + branch: '' + steps: + - run: echo "branch=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV + - run: echo "result=${{ env.prefix }}-master" >> $GITHUB_ENV + - if: startsWith(env.branch, '0.') || github.ref_type == 'tag' + run: echo "result=${{ env.prefix }}-stable" >> $GITHUB_ENV + - id: setvar + run: echo "result=${{ env.result }}" >> $GITHUB_OUTPUT + message-lint: + if: endsWith(needs.get.outputs.image, '-master') uses: ./.github/workflows/commit-lint.yml + needs: get with: upstream-repo: https://github.com/winft/como.git + reuse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: REUSE Compliance + uses: fsfe/reuse-action@v2 + clang-format: uses: ./.github/workflows/clang-format.yml clang-build: uses: ./.github/workflows/build.yml + needs: get with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + image: ${{ needs.get.outputs.image }} artifact-name: clang-build - cmake-preset: coverage + cmake-preset: clang - secondary-builds: + builds: strategy: matrix: - preset: [gcc, release] + preset: [gcc-cov, release] uses: ./.github/workflows/build.yml + needs: get with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + image: ${{ needs.get.outputs.image }} + artifact-name: ${{ matrix.preset }}-build cmake-preset: ${{ matrix.preset }} + cmake-args: -DBUILD_TESTING=ON install: uses: ./.github/workflows/install.yml - needs: clang-build + needs: [builds, get] with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master - artifact-name: clang-build + image: ${{ needs.get.outputs.image }} + artifact-name: release-build - test: + tests: + strategy: + fail-fast: false + matrix: + preset: [gcc-cov, release] uses: ./.github/workflows/test.yml - needs: clang-build + needs: [builds, get] + secrets: inherit with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master - artifact-name: clang-build + image: ${{ needs.get.outputs.image }} + artifact-prefix: ${{ matrix.preset }} + coverage: ${{ matrix.preset == 'gcc-cov' }} # Following tests are currently disabled on CI: # * lockscreen, modifier-only-shortcut: flaky on CI because the lockscreen greeter process likes to # freeze off. Also see: https://bugreports.qt.io/browse/QTBUG-82911 @@ -51,10 +88,17 @@ jobs: |no crash aurorae destroy deco|slidingpopups|scripted effects|window open close animation\ |subspace switching animation|minimize animation'" + clang-tidy: + uses: ./.github/workflows/clang-tidy.yml + needs: [clang-build, get] + with: + image: ${{ needs.get.outputs.image }} + artifact-name: clang-build + package: uses: ./.github/workflows/package.yml - needs: clang-build + needs: [builds, get] with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master - artifact-name: clang-build + image: ${{ needs.get.outputs.image }} + artifact-name: release-build package-name: como diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 91972dee25..b18a61b515 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Clang-Format on: workflow_call jobs: diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 0000000000..0614197963 --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT +name: Clang-Tidy +on: + workflow_call: + inputs: + image: + description: Image to run tests on + required: true + type: string + artifact-name: + description: Artifact name of build dir + required: true + type: string + threads: + description: Parallel execution count + required: false + type: number + default: 0 + +jobs: + clang-tidy: + name: Clang-Tidy + runs-on: ubuntu-latest + container: + image: ${{ inputs.image }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Install Dependencies + uses: ./.github/actions/dep-artifacts + with: + secret: ${{ secrets.GITHUB_TOKEN }} + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + - name: Untar artifact + run: tar -xzf build-dir.tar + - name: Run Clang-Tidy + run: tooling/analysis/clang-tidy.py -p build -j ${{ inputs.threads }} + shell: bash diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index e3d16ad29c..373a037cf4 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Commit Message Lint on: workflow_call: diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 44381ae26d..fa50a40ea2 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Build on: workflow_call: diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index c0a9768ea3..adfc137442 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Package on: workflow_call: diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 9a6e849099..91e38dbed1 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Weekly Project Rebuild on: schedule: @@ -7,7 +9,7 @@ jobs: if: github.repository == 'winft/como' uses: ./.github/workflows/build.yml with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + image: registry.gitlab.com/kwinft/ci-images/archlinux/como-base-master artifact-name: build cmake-preset: release @@ -15,5 +17,5 @@ jobs: uses: ./.github/workflows/package.yml needs: build with: - image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + image: registry.gitlab.com/kwinft/ci-images/archlinux/como-base-master package-name: como diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0bf91430d6..63f3492161 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT name: Test on: workflow_call: @@ -6,8 +8,8 @@ on: description: Image to run tests on required: true type: string - artifact-name: - description: Artifact name of build dir + artifact-prefix: + description: Artifact prefix of build dir required: true type: string ctest-args: @@ -15,6 +17,11 @@ on: required: false type: string default: '' + coverage: + description: Option to create coverage + required: false + type: boolean + default: false jobs: test: @@ -32,7 +39,7 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: ${{ inputs.artifact-name }} + name: ${{ inputs.artifact-prefix }}-build - name: Untar artifact run: tar -xzf build-dir.tar - name: List all tests @@ -49,6 +56,18 @@ jobs: run: "Xvfb :1 -ac -screen 0 1920x1080x24 > /dev/null 2>&1 & - dbus-run-session ctest --test-dir build -T Test \ + dbus-run-session ctest --test-dir build --output-junit junit-test-results.xml \ --output-on-failure --no-compress-output ${{ inputs.ctest-args }}" shell: bash + - name: Generate a code coverage report + if: ${{ inputs.coverage }} + uses: ./.github/actions/coverage + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v4 + if: ${{ inputs.coverage && (github.repository == 'winft/como' || github.event_name == 'pull_request') }} + with: + file: coverage.xml + fail_ci_if_error: true + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.reuse/dep5 b/.reuse/dep5 index 1b42e30602..db06a74377 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -1,18 +1,27 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: KWinFT +Upstream-Name: The Compositor Modules Upstream-Contact: Roman Gilg -Source: https://gitlab.com/kwinft/kwinft.git +Source: https://github.com/winft/como.git Files: .versionrc.json - autotests/integration/fakes/org.kde.kdecoration2/fakedecoration_with_shadows.json - autotests/libkwineffects/data/glplatform/* - lib/data/icons/* - lib/data/org_kde_kwin.categories - lib/desktop/kde/dbus/org.kde.KWin.xml - lib/desktop/kde/org.kde.kwin.VirtualKeyboard.xml - lib/win/tabbox/switchers/thumbnail_grid/metadata.json - docs/* + CMakePresets.json + como/data/icons/* + como/data/org_kde_kwin.categories + como/desktop/kde/dbus/org.kde.KWin.xml + como/desktop/kde/org.kde.kwin.VirtualKeyboard.xml + como/render/dbus/org.kde.kwin.Compositing.xml + como/render/dbus/org.kde.KWin.NightLight.xml + como/render/effect/interface/org.kde.kwin.Effects.xml + como/script/org.kde.kwin.Script.xml + como/win/dbus/org.kde.KWin.Session.xml + como/win/dbus/org.kde.KWin.VirtualDesktopManager.xml + como/win/dbus/org.kde.kappmenu.xml + como/win/tabbox/switchers/thumbnail_grid/metadata.json + docs/assets/* + docs/kwindecoration/* + docs/kwineffects/* + docs/windowspecific/* plugins/effects/backgroundcontrast/metadata.json plugins/effects/blendchanges/metadata.json plugins/effects/blur/metadata.json @@ -67,19 +76,6 @@ Files: plugins/effects/windowview/metadata.json plugins/effects/wobblywindows/metadata.json plugins/effects/zoom/metadata.json - kcms/common/generic_scripted_config.json - kcms/compositing/kwincompositing.json - kcms/decoration/declarative-plugin/qmldir - kcms/decoration/kcm_kwindecoration.json - kcms/desktop/kcm_kwin_virtualdesktops.json - kcms/effects/kcm_kwin_effects.json - kcms/options/kcm_kwinoptions.json - kcms/rules/kcm_kwinrules.json - kcms/screenedges/kcm_kwinscreenedges.json - kcms/screenedges/kcm_kwintouchscreen.json - kcms/scripts/kcm_kwin_scripts.json - kcms/tabbox/kcm_kwintabbox.json - kcms/tabbox/thumbnails/* plugins/idletime/kwin.json plugins/kdecorations/aurorae/src/aurorae.json plugins/kdecorations/aurorae/src/config/kcm_auroraeconfig.json @@ -94,16 +90,11 @@ Files: plugins/kpackage/windowswitcher/windowswitcher.json plugins/qpa/kwin.json plugins/windowsystem/kwindowsystem.json - lib/render/dbus/org.kde.kwin.ColorCorrect.xml - lib/render/dbus/org.kde.kwin.Compositing.xml - lib/render/effect/interface/org.kde.kwin.Effects.xml - lib/script/org.kde.kwin.Script.xml plugins/scripts/desktopchangeosd/package/metadata.json plugins/scripts/minimizeall/package/metadata.json plugins/scripts/synchronizeskipswitcher/package/metadata.json plugins/scripts/videowall/package/metadata.json - lib/win/dbus/org.kde.KWin.Session.xml - lib/win/dbus/org.kde.KWin.VirtualDesktopManager.xml - lib/win/dbus/org.kde.kappmenu.xml + tests/integration/fakes/org.kde.kdecoration2/fakedecoration_with_shadows.json + tests/unit/effects/data/glplatform/* Copyright: 2023 Roman Gilg License: GPL-2.0-or-later diff --git a/.versionrc.json b/.versionrc.json index 2f3157a5db..8ceea206ea 100644 --- a/.versionrc.json +++ b/.versionrc.json @@ -1,5 +1,5 @@ { - "header": "# Changelog\nAll notable changes to KWinFT will be documented in this file.", + "header": "\n# Changelog\nAll notable changes to The Compositor Modules will be documented in this file.", "types": [ {"type": "feat", "section": "Features"}, {"type": "fix", "section": "Bug Fixes"}, diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ab842009..cec0780ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,67 @@ - # Changelog All notable changes to The Compositor Modules will be documented in this file. +## [0.2.0](https://github.com/winft/como/compare/v0.1.0...v0.2.0) (2024-06-19) + + +### ⚠ BREAKING CHANGES + +* consumer creates screen locker for desktop platform + +### Features + +* add a placeholder message in the thumbnails grid switcher ([a7902ec](https://github.com/winft/como/commit/a7902ecb3ef0724b9de996d8ac89c4da200e0f5e)) +* adds a border around hovered and selected desktop in desktopGrid ([ecdba0d](https://github.com/winft/como/commit/ecdba0d18e524ca76046bc4c5ccfa95592903172)) +* drop "" window caption suffix ([0478703](https://github.com/winft/como/commit/0478703e7f86e3febfe5e994e59edc1c20e81326)) +* implement new overview layout algorithm ([c31e091](https://github.com/winft/como/commit/c31e0911f04e5d390ef9d1119907827ff322f7e1)) +* **input:** remove the terminate server shortcut ([885d504](https://github.com/winft/como/commit/885d504bc4df2ef192e89afce5021c4e9eea6683)) +* mark risky KNS content ([84b3a22](https://github.com/winft/como/commit/84b3a22e2d84a4f26ddc4603cfa895b1552fe595)) +* **plugin:** provide a way to reserve a screen edge for grid mode ([bedfb80](https://github.com/winft/como/commit/bedfb80ee54d3e4293551e763f8a0afa412b7f15)) +* **plugin:** remove middle click to close virtual desktop ([a89f065](https://github.com/winft/como/commit/a89f065a39d2e3cdc3b4f36e847ef0a488196706)) +* provide KDE screen locker in desktop module ([4b46eb9](https://github.com/winft/como/commit/4b46eb94de55fe06372eb0920ae137526f805e2e)) + + +### Bug Fixes + +* adapt to wlroots pointer enum name change ([5f25519](https://github.com/winft/como/commit/5f255190d74d6b8d2ade74ed572e882b38c72892)) +* add screen locked hook to windowing integration ([86df2ac](https://github.com/winft/como/commit/86df2ac3cfa1c08693443fef7a4e7a36b1dc4789)) +* add some missing includes ([7586d3c](https://github.com/winft/como/commit/7586d3cd718e08e9610d4fd53ed3667bc602c175)) +* assert not dividing by zero ([8c28b86](https://github.com/winft/como/commit/8c28b8677e608dd19da8e12790f827fe9422651b)) +* clarify strings for inhibition ([4080777](https://github.com/winft/como/commit/408077738e9b52b0b35988e7422f3a904ad9e47d)) +* define decoration spacer button ([3155ada](https://github.com/winft/como/commit/3155adace1ceeb4b34589236f196cad731544f20)) +* discard return value ([c944f4f](https://github.com/winft/como/commit/c944f4f11cbe426cfaaa8e2262fd315e3c9a6930)) +* do not take ownership of QuickEffect::delegate ([a3a7249](https://github.com/winft/como/commit/a3a72493d31d78f68211b8fd20254abe17efcd5f)) +* don't build SPI support if Qt wasn't build with it ([70c9ee6](https://github.com/winft/como/commit/70c9ee66f7adba864162f3744de156836b2bdf8f)) +* fix oversights on shortcut handling within Overview/Grid effect ([3f1ae13](https://github.com/winft/como/commit/3f1ae1339f1d9f6064b25b7a75e1ae79584a98da)) +* **plugin:** fix autohidden panels blinking when plasmashell launches ([ae65a28](https://github.com/winft/como/commit/ae65a28571e03257046eb979d352a61e691d5d85)) +* **plugin:** fix mainscript for declarative effects ([352a8a4](https://github.com/winft/como/commit/352a8a4766fc79209e011a3d08082a46b1a264c7)) +* **plugin:** search bar can be clicked without closing effect ([9aa0d25](https://github.com/winft/como/commit/9aa0d25782adb34ab17fae192e8dcf9aef67fede)) +* **plugin:** store expo layout without QPointer ([dc2d2c6](https://github.com/winft/como/commit/dc2d2c6ad7375c15da7a9bc9729fcf50940c12a4)) +* **plugin:** store internal window handle without QPointer ([bc7cea9](https://github.com/winft/como/commit/bc7cea976a6110ad68945fb24ecf06cdd4ed4652)) +* prevent including "show desktop" entry if there are no other windows ([156fc65](https://github.com/winft/como/commit/156fc65fd2ef331c1f69345b619b33f96cd9bd2e)) +* store event filters as raw pointers ([ff291bd](https://github.com/winft/como/commit/ff291bd9099015a40c65f2455625ea6dd7d09d94)) +* store implict grab without QPointer ([dc1443e](https://github.com/winft/como/commit/dc1443e1638beb8897d03ca32db40e54e599212e)) +* store window thumbnail item fields without QPointers ([8d71539](https://github.com/winft/como/commit/8d715390eb6eb73ce467406416d5cc8b6e021aa1)) +* use correct enum value for `PointerDevice` ([5ca52a4](https://github.com/winft/como/commit/5ca52a4f1c35238c0980b3e3ee0eac1bbd7cbbda)) +* use new wayland enums ([b7a040a](https://github.com/winft/como/commit/b7a040a39d4785c25810ae0d1f90703078d787b7)) +* use QKeyCombination::toCombined() ([81834c1](https://github.com/winft/como/commit/81834c12146016fcda69c6d4da305726c2252ce7)) + + +### Refactors + +* adapt to Wrapland subsurface change ([92e6581](https://github.com/winft/como/commit/92e65816fc652f173b6f477edff325c6e039d830)) +* make NETRootInfo initialization reasonable ([5e5adfb](https://github.com/winft/como/commit/5e5adfb3a3ab7158518fe695c32d281a2ab16d15)) +* optimize saving discarded rules to config ([1105f71](https://github.com/winft/como/commit/1105f717a27de307d83b570e37bffc915c1471de)) +* remove Q_D macro ([24a43a9](https://github.com/winft/como/commit/24a43a90c694fac8e4f71d80eda7dfcf58e13b8d)) +* remove screen locker init signal ([95cfefb](https://github.com/winft/como/commit/95cfefbbc6db5a38a259f074d7acacd226858961)) +* replace Qt smart pointers with STL ones ([5828bc2](https://github.com/winft/como/commit/5828bc2231eee9c4084614b0c01a3bead8419ecb)) +* round all the things consistently ([07b946f](https://github.com/winft/como/commit/07b946f00b4ac929670bb1f5511b7b4598c93557)) +* slight code cleanup ([6470ed1](https://github.com/winft/como/commit/6470ed17a3896af7ff09c09722fd145d944c56d9)) +* use smart pointer ([36fa216](https://github.com/winft/como/commit/36fa216d207d6d0518a4ea7cd9f81a9fa761ae33)) +* **wl:** create server connections in free function ([504561f](https://github.com/winft/como/commit/504561f7eec7ff7107153520a2fd812b59d31aea)) ## [0.1.0](https://github.com/winft/como/compare/cfa93fa9db90b2219f21940be69e323fd7f68355...v0.1.0) (2024-02-27) diff --git a/CMakeLists.txt b/CMakeLists.txt index 681cc18d46..e15abb1eff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.23 FATAL_ERROR) -project("The Compositor Modules" VERSION 0.1.0) +project("The Compositor Modules" VERSION 0.2.0) set(QT_MIN_VERSION "6.6.0") set(KF6_MIN_VERSION "6.0.0") @@ -77,8 +77,8 @@ ecm_setup_version(PROJECT # required frameworks by Core find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS Auth + ColorScheme Config - ConfigWidgets CoreAddons Crash GlobalAccel @@ -92,7 +92,6 @@ find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS ) # required frameworks by config modules find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS - Declarative KCMUtils NewStuff Service @@ -219,6 +218,7 @@ if (${wlroots_VERSION} VERSION_GREATER_EQUAL 0.18) set(WLR_HAVE_UTIL_TRANSFORM_HEADER 1) set(WLR_HAVE_NEW_PIXEL_COPY_API 1) set(WLR_HAVE_BACKEND_CREATE_WITH_LOOP 1) + set(WLR_HAVE_WL_POINTER_ENUMS 1) endif() find_package(X11) @@ -301,6 +301,7 @@ ecm_find_qmlmodule(org.kde.kquickcontrolsaddons 2.0) ecm_find_qmlmodule(org.kde.plasma.core 2.0) ecm_find_qmlmodule(org.kde.plasma.components 2.0) +option(BUILD_EXAMPLES "Enable building examples." ON) option(COMO_BUILD_DECORATIONS "Enable building of decorations." ON) option(COMO_BUILD_KCMS "Enable building of configuration modules." ON) option(COMO_BUILD_TABBOX "Enable building of Tabbox functionality" ON) @@ -341,7 +342,9 @@ if (BUILD_TESTING) add_subdirectory(tests) endif() -add_subdirectory(examples) +if (BUILD_EXAMPLES) + add_subdirectory(examples) +endif() if (KF6DocTools_FOUND) add_subdirectory(docs) diff --git a/CMakePresets.json b/CMakePresets.json index 254c8b18a0..6768bf0bac 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -11,7 +11,11 @@ "hidden": true, "generator": "Ninja", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": { + "type": "BOOL", + "value": "ON" + } }, "environment": { "DEBUG_COMMON_FLAGS": "-Wall -Wextra -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef", @@ -20,7 +24,8 @@ "DEBUG_SHARED_LINKER_FLAGS": "-Wl,--fatal-warnings", "DEBUG_MODULE_LINKER_FLAGS": "-Wl,--fatal-warnings", "NOUNDEF_LINKER_FLAGS": "-Wl,--no-undefined", - "DEBUG_CXX_FLAGS_CLANG": "$env{DEBUG_CXX_FLAGS} -fno-operator-names -Wno-gnu-zero-variadic-macro-arguments -Wno-cast-align -Werror -Wno-error=deprecated-declarations -Wno-error=unused-lambda-capture" + "DEBUG_CXX_FLAGS_CLANG": "$env{DEBUG_CXX_FLAGS} -fno-operator-names -Wno-gnu-zero-variadic-macro-arguments -Wno-cast-align -Werror -Wno-error=deprecated-declarations -Wno-error=unused-lambda-capture", + "DEBUG_CXX_FLAGS_GCC": "$env{DEBUG_CXX_FLAGS} -Wsuggest-override -Wlogical-op -Wmissing-include-dirs -Wno-missing-field-initializers -Werror -Wno-error=unknown-pragmas -Wno-error=deprecated-declarations -Wno-error=missing-include-dirs" } }, { @@ -46,7 +51,7 @@ "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++", "CMAKE_C_FLAGS": "$env{DEBUG_C_FLAGS}", - "CMAKE_CXX_FLAGS": "$env{DEBUG_CXX_FLAGS} -Wsuggest-override -Wlogical-op -Wmissing-include-dirs -Wno-missing-field-initializers -Werror -Wno-error=unknown-pragmas -Wno-error=deprecated-declarations -Wno-error=missing-include-dirs", + "CMAKE_CXX_FLAGS": "$env{DEBUG_CXX_FLAGS_GCC}", "CMAKE_SHARED_LINKER_FLAGS": "$env{DEBUG_SHARED_LINKER_FLAGS} $env{NOUNDEF_LINKER_FLAGS}", "CMAKE_MODULE_LINKER_FLAGS": "$env{DEBUG_MODULE_LINKER_FLAGS} $env{NOUNDEF_LINKER_FLAGS}" } @@ -67,22 +72,16 @@ } }, { - "name": "coverage", - "inherits": "debug-base", - "displayName": "Tests with Coverage", - "description": "Build with tests and coverage reporting enabled", + "name": "gcc-cov", + "inherits": "gcc", + "displayName": "GCC Tests Coverage", + "description": "GCC Build with tests and coverage reporting enabled", "cacheVariables": { - "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_C_FLAGS": "$env{DEBUG_C_FLAGS}", - "CMAKE_CXX_FLAGS": "$env{DEBUG_CXX_FLAGS_CLANG} --coverage", - "CMAKE_SHARED_LINKER_FLAGS": "$env{DEBUG_SHARED_LINKER_FLAGS} $env{NOUNDEF_LINKER_FLAGS}", - "CMAKE_MODULE_LINKER_FLAGS": "$env{DEBUG_MODULE_LINKER_FLAGS} $env{NOUNDEF_LINKER_FLAGS}", - "CMAKE_EXE_LINKER_FLAGS": "--coverage", - "CMAKE_EXPORT_COMPILE_COMMANDS": { - "type": "BOOL", - "value": "ON" - } + "CMAKE_C_FLAGS": "$env{DEBUG_C_FLAGS} --coverage -fprofile-abs-path", + "CMAKE_CXX_FLAGS": "$env{DEBUG_CXX_FLAGS_GCC} --coverage -fprofile-abs-path", + "CMAKE_SHARED_LINKER_FLAGS": "$env{DEBUG_SHARED_LINKER_FLAGS} $env{NOUNDEF_LINKER_FLAGS} --coverage -fprofile-abs-path", + "CMAKE_MODULE_LINKER_FLAGS": "$env{DEBUG_MODULE_LINKER_FLAGS} $env{NOUNDEF_LINKER_FLAGS} --coverage -fprofile-abs-path", + "CMAKE_EXE_LINKER_FLAGS": "--coverage -fprofile-abs-path" } }, { @@ -97,6 +96,10 @@ "BUILD_TESTING": { "type": "BOOL", "value": "OFF" + }, + "BUILD_EXAMPLES": { + "type": "BOOL", + "value": "OFF" } } } diff --git a/LICENSES/LGPL-2.0-only.txt b/LICENSES/LGPL-2.0-only.txt deleted file mode 100644 index ec9eedc542..0000000000 --- a/LICENSES/LGPL-2.0-only.txt +++ /dev/null @@ -1,444 +0,0 @@ -GNU LIBRARY GENERAL PUBLIC LICENSE - -Version 2, June 1991 - -Copyright (C) 1991 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is numbered 2 -because it goes with version 2 of the ordinary GPL.] - -Preamble - -The licenses for most software are designed to take away your freedom to share -and change it. By contrast, the GNU General Public Licenses are intended to -guarantee your freedom to share and change free software--to make sure the -software is free for all its users. - -This license, the Library General Public License, applies to some specially -designated Free Software Foundation software, and to any other libraries whose -authors decide to use it. You can use it for your libraries, too. - -When we speak of free software, we are referring to freedom, not price. Our -General Public Licenses are designed to make sure that you have the freedom -to distribute copies of free software (and charge for this service if you -wish), that you receive source code or can get it if you want it, that you -can change the software or use pieces of it in new free programs; and that -you know you can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to -deny you these rights or to ask you to surrender the rights. These restrictions -translate to certain responsibilities for you if you distribute copies of -the library, or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for -a fee, you must give the recipients all the rights that we gave you. You must -make sure that they, too, receive or can get the source code. If you link -a program with the library, you must provide complete object files to the -recipients so that they can relink them with the library, after making changes -to the library and recompiling it. And you must show them these terms so they -know their rights. - -Our method of protecting your rights has two steps: (1) copyright the library, -and (2) offer you this license which gives you legal permission to copy, distribute -and/or modify the library. - -Also, for each distributor's protection, we want to make certain that everyone -understands that there is no warranty for this free library. If the library -is modified by someone else and passed on, we want its recipients to know -that what they have is not the original version, so that any problems introduced -by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We -wish to avoid the danger that companies distributing free software will individually -obtain patent licenses, thus in effect transforming the program into proprietary -software. To prevent this, we have made it clear that any patent must be licensed -for everyone's free use or not licensed at all. - -Most GNU software, including some libraries, is covered by the ordinary GNU -General Public License, which was designed for utility programs. This license, -the GNU Library General Public License, applies to certain designated libraries. -This license is quite different from the ordinary one; be sure to read it -in full, and don't assume that anything in it is the same as in the ordinary -license. - -The reason we have a separate public license for some libraries is that they -blur the distinction we usually make between modifying or adding to a program -and simply using it. Linking a program with a library, without changing the -library, is in some sense simply using the library, and is analogous to running -a utility program or application program. However, in a textual and legal -sense, the linked executable is a combined work, a derivative of the original -library, and the ordinary General Public License treats it as such. - -Because of this blurred distinction, using the ordinary General Public License -for libraries did not effectively promote software sharing, because most developers -did not use the libraries. We concluded that weaker conditions might promote -sharing better. - -However, unrestricted linking of non-free programs would deprive the users -of those programs of all benefit from the free status of the libraries themselves. -This Library General Public License is intended to permit developers of non-free -programs to use free libraries, while preserving your freedom as a user of -such programs to change the free libraries that are incorporated in them. -(We have not seen how to achieve this as regards changes in header files, -but we have achieved it as regards changes in the actual functions of the -Library.) The hope is that this will lead to faster development of free libraries. - -The precise terms and conditions for copying, distribution and modification -follow. Pay close attention to the difference between a "work based on the -library" and a "work that uses the library". The former contains code derived -from the library, while the latter only works together with the library. - -Note that it is possible for a library to be covered by the ordinary General -Public License rather than by this special one. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library which contains a -notice placed by the copyright holder or other authorized party saying it -may be distributed under the terms of this Library General Public License -(also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared -so as to be conveniently linked with application programs (which use some -of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has -been distributed under these terms. A "work based on the Library" means either -the Library or any derivative work under copyright law: that is to say, a -work containing the Library or a portion of it, either verbatim or with modifications -and/or translated straightforwardly into another language. (Hereinafter, translation -is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications -to it. For a library, complete source code means all the source code for all -modules it contains, plus any associated interface definition files, plus -the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered -by this License; they are outside its scope. The act of running a program -using the Library is not restricted, and output from such a program is covered -only if its contents constitute a work based on the Library (independent of -the use of the Library in a tool for writing it). Whether that is true depends -on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source -code as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and disclaimer -of warranty; keep intact all the notices that refer to this License and to -the absence of any warranty; and distribute a copy of this License along with -the Library. - -You may charge a fee for the physical act of transferring a copy, and you -may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, -thus forming a work based on the Library, and copy and distribute such modifications -or work under the terms of Section 1 above, provided that you also meet all -of these conditions: - - a) The modified work must itself be a software library. - -b) You must cause the files modified to carry prominent notices stating that -you changed the files and the date of any change. - -c) You must cause the whole of the work to be licensed at no charge to all -third parties under the terms of this License. - -d) If a facility in the modified Library refers to a function or a table of -data to be supplied by an application program that uses the facility, other -than as an argument passed when the facility is invoked, then you must make -a good faith effort to ensure that, in the event an application does not supply -such function or table, the facility still operates, and performs whatever -part of its purpose remains meaningful. - -(For example, a function in a library to compute square roots has a purpose -that is entirely well-defined independent of the application. Therefore, Subsection -2d requires that any application-supplied function or table used by this function -must be optional: if the application does not supply it, the square root function -must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable -sections of that work are not derived from the Library, and can be reasonably -considered independent and separate works in themselves, then this License, -and its terms, do not apply to those sections when you distribute them as -separate works. But when you distribute the same sections as part of a whole -which is a work based on the Library, the distribution of the whole must be -on the terms of this License, whose permissions for other licensees extend -to the entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest your -rights to work written entirely by you; rather, the intent is to exercise -the right to control the distribution of derivative or collective works based -on the Library. - -In addition, mere aggregation of another work not based on the Library with -the Library (or with a work based on the Library) on a volume of a storage -or distribution medium does not bring the other work under the scope of this -License. - -3. You may opt to apply the terms of the ordinary GNU General Public License -instead of this License to a given copy of the Library. To do this, you must -alter all the notices that refer to this License, so that they refer to the -ordinary GNU General Public License, version 2, instead of to this License. -(If a newer version than version 2 of the ordinary GNU General Public License -has appeared, then you can specify that version instead if you wish.) Do not -make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, -so the ordinary GNU General Public License applies to all subsequent copies -and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library -into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of -it, under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you accompany it with the complete corresponding -machine-readable source code, which must be distributed under the terms of -Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated -place, then offering equivalent access to copy the source code from the same -place satisfies the requirement to distribute the source code, even though -third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but -is designed to work with the Library by being compiled or linked with it, -is called a "work that uses the Library". Such a work, in isolation, is not -a derivative work of the Library, and therefore falls outside the scope of -this License. - -However, linking a "work that uses the Library" with the Library creates an -executable that is a derivative of the Library (because it contains portions -of the Library), rather than a "work that uses the library". The executable -is therefore covered by this License. Section 6 states terms for distribution -of such executables. - -When a "work that uses the Library" uses material from a header file that -is part of the Library, the object code for the work may be a derivative work -of the Library even though the source code is not. Whether this is true is -especially significant if the work can be linked without the Library, or if -the work is itself a library. The threshold for this to be true is not precisely -defined by law. - -If such an object file uses only numerical parameters, data structure layouts -and accessors, and small macros and small inline functions (ten lines or less -in length), then the use of the object file is unrestricted, regardless of -whether it is legally a derivative work. (Executables containing this object -code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute -the object code for the work under the terms of Section 6. Any executables -containing that work also fall under Section 6, whether or not they are linked -directly with the Library itself. - -6. As an exception to the Sections above, you may also compile or link a "work -that uses the Library" with the Library to produce a work containing portions -of the Library, and distribute that work under terms of your choice, provided -that the terms permit modification of the work for the customer's own use -and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library -is used in it and that the Library and its use are covered by this License. -You must supply a copy of this License. If the work during execution displays -copyright notices, you must include the copyright notice for the Library among -them, as well as a reference directing the user to the copy of this License. -Also, you must do one of these things: - -a) Accompany the work with the complete corresponding machine-readable source -code for the Library including whatever changes were used in the work (which -must be distributed under Sections 1 and 2 above); and, if the work is an -executable linked with the Library, with the complete machine-readable "work -that uses the Library", as object code and/or source code, so that the user -can modify the Library and then relink to produce a modified executable containing -the modified Library. (It is understood that the user who changes the contents -of definitions files in the Library will not necessarily be able to recompile -the application to use the modified definitions.) - -b) Accompany the work with a written offer, valid for at least three years, -to give the same user the materials specified in Subsection 6a, above, for -a charge no more than the cost of performing this distribution. - -c) If distribution of the work is made by offering access to copy from a designated -place, offer equivalent access to copy the above specified materials from -the same place. - -d) Verify that the user has already received a copy of these materials or -that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must -include any data and utility programs needed for reproducing the executable -from it. However, as a special exception, the source code distributed need -not include anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the operating -system on which the executable runs, unless that component itself accompanies -the executable. - -It may happen that this requirement contradicts the license restrictions of -other proprietary libraries that do not normally accompany the operating system. -Such a contradiction means you cannot use both them and the Library together -in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side -in a single library together with other library facilities not covered by -this License, and distribute such a combined library, provided that the separate -distribution of the work based on the Library and of the other library facilities -is otherwise permitted, and provided that you do these two things: - -a) Accompany the combined library with a copy of the same work based on the -Library, uncombined with any other library facilities. This must be distributed -under the terms of the Sections above. - -b) Give prominent notice with the combined library of the fact that part of -it is a work based on the Library, and explaining where to find the accompanying -uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library -except as expressly provided under this License. Any attempt otherwise to -copy, modify, sublicense, link with, or distribute the Library is void, and -will automatically terminate your rights under this License. However, parties -who have received copies, or rights, from you under this License will not -have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed -it. However, nothing else grants you permission to modify or distribute the -Library or its derivative works. These actions are prohibited by law if you -do not accept this License. Therefore, by modifying or distributing the Library -(or any work based on the Library), you indicate your acceptance of this License -to do so, and all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), -the recipient automatically receives a license from the original licensor -to copy, distribute, link with or modify the Library subject to these terms -and conditions. You may not impose any further restrictions on the recipients' -exercise of the rights granted herein. You are not responsible for enforcing -compliance by third parties to this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement -or for any other reason (not limited to patent issues), conditions are imposed -on you (whether by court order, agreement or otherwise) that contradict the -conditions of this License, they do not excuse you from the conditions of -this License. If you cannot distribute so as to satisfy simultaneously your -obligations under this License and any other pertinent obligations, then as -a consequence you may not distribute the Library at all. For example, if a -patent license would not permit royalty-free redistribution of the Library -by all those who receive copies directly or indirectly through you, then the -only way you could satisfy both it and this License would be to refrain entirely -from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents -or other property right claims or to contest validity of any such claims; -this section has the sole purpose of protecting the integrity of the free -software distribution system which is implemented by public license practices. -Many people have made generous contributions to the wide range of software -distributed through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing to -distribute software through any other system and a licensee cannot impose -that choice. - -This section is intended to make thoroughly clear what is believed to be a -consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain -countries either by patents or by copyrighted interfaces, the original copyright -holder who places the Library under this License may add an explicit geographical -distribution limitation excluding those countries, so that distribution is -permitted only in or among countries not thus excluded. In such case, this -License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of -the Library General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to address -new problems or concerns. - -Each version is given a distinguishing version number. If the Library specifies -a version number of this License which applies to it and "any later version", -you have the option of following the terms and conditions either of that version -or of any later version published by the Free Software Foundation. If the -Library does not specify a license version number, you may choose any version -ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs -whose distribution conditions are incompatible with these, write to the author -to ask for permission. For software which is copyrighted by the Free Software -Foundation, write to the Free Software Foundation; we sometimes make exceptions -for this. Our decision will be guided by the two goals of preserving the free -status of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR -THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE -STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY -"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE -OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE -THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE -OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA -OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES -OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH -HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest possible -use to the public, we recommend making it free software that everyone can -redistribute and change. You can do so by permitting redistribution under -these terms (or, alternatively, under the terms of the ordinary General Public -License). - -To apply these terms, attach the following notices to the library. It is safest -to attach them to the start of each source file to most effectively convey -the exclusion of warranty; and each file should have at least the "copyright" -line and a pointer to where the full notice is found. - - one line to give the library's name and an idea of what it does. - Copyright (C) year name of author - -This library is free software; you can redistribute it and/or modify it under -the terms of the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for -more details. - -You should have received a copy of the GNU Library General Public License -along with this library; if not, write to the Free Software Foundation, Inc., -51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, -if any, to sign a "copyright disclaimer" for the library, if necessary. Here -is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice - -That's all there is to it! diff --git a/README.md b/README.md index 16ddd2b6df..7d438c63c2 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,32 @@
-

- - - - The Compositor Modules wide logo - -

- -

-The Compositor Modules (COMO) are a robust and versatile set of libraries -
-to create compositors for the Wayland and X11 windowing systems on Linux. -

+

+ + + + The Compositor Modules wide logo + +

+ +

+ The Compositor Modules (COMO) are a robust and versatile set of libraries +
+ to create compositors for the Wayland and X11 windowing systems on Linux. +

+ +
+ + [![Badge CI]][CI] + [![Badge Codecov]][Codecov] + [![Badge License]][License] + [![Badge SemVer]][SemVer]
+ [![Badge REUSE]][REUSE] + [![Badge AUR]][AUR] + [![Badge Matrix]][Matrix]
# Features @@ -133,3 +142,23 @@ as a more complex one demonstrate this in a straightforward way. # Contact Issue tickets can be created for feature requests, bug reports or general discussions. For direct communication join our [Matrix room](https://matrix.to/#/#como:matrix.org). + + +[AUR]: https://aur.archlinux.org/packages/como +[CI]: https://github.com/winft/como/actions/workflows/change.yml +[Codecov]: https://codecov.io/gh/winft/como +[License]: LICENSE +[Matrix]: https://matrix.to/#/#como:matrix.org +[REUSE]: https://api.reuse.software/info/github.com/winft/como +[SemVer]: https://semver.org/spec/v2.0.0.html + + + +[Badge AUR]: https://img.shields.io/aur/version/como +[Badge CI]: https://github.com/winft/como/actions/workflows/change.yml/badge.svg?event=push +[Badge Codecov]: https://codecov.io/gh/winft/como/graph/badge.svg?token=YK9NKRP7FB +[Badge License]: https://img.shields.io/github/license/winft/como +[Badge Matrix]: https://img.shields.io/matrix/como%3Amatrix.org?logo=matrix&logoColor=048cad&label=chat&labelColor=ffffff&color=048cad +[Badge REUSE]: https://api.reuse.software/badge/github.com/winft/como +[Badge SemVer]: https://img.shields.io/badge/SemVer-2.0.0-83649e?logo=semver + diff --git a/como-config.cmake.in b/como-config.cmake.in index 42af56d37a..0ec9f3e2cb 100644 --- a/como-config.cmake.in +++ b/como-config.cmake.in @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: GPL-2.0-or-later + @PACKAGE_INIT@ include(CMakeFindDependencyMacro) @@ -10,10 +13,9 @@ find_dependency(wlroots @WLROOTS_MIN_VERSION@) find_dependency(Qt6Gui @QT_MIN_VERSION@) find_dependency(KF6 @KF6_MIN_VERSION@ COMPONENTS Auth + ColorScheme Config - ConfigWidgets CoreAddons - Declarative GlobalAccel I18n IdleTime diff --git a/como/base/CMakeLists.txt b/como/base/CMakeLists.txt index bcdf81fc33..302054eb67 100644 --- a/como/base/CMakeLists.txt +++ b/como/base/CMakeLists.txt @@ -133,7 +133,6 @@ add_library(base-wl SHARED) target_link_libraries(base-wl PUBLIC KF6::Service - PW::KScreenLocker WraplandServer base ) @@ -149,8 +148,8 @@ target_sources(base-wl wayland/output_transform.h wayland/platform.h wayland/platform_helpers.h - wayland/screen_lock.h wayland/server.h + wayland/server_helpers.h wayland/xwl_platform.h PRIVATE wayland/filtered_display.cpp diff --git a/como/base/config-como.h.cmake b/como/base/config-como.h.cmake index 0366fc4c81..908b7fc8a6 100644 --- a/como/base/config-como.h.cmake +++ b/como/base/config-como.h.cmake @@ -20,6 +20,7 @@ #cmakedefine01 WLR_HAVE_UTIL_TRANSFORM_HEADER #cmakedefine01 WLR_HAVE_NEW_PIXEL_COPY_API #cmakedefine01 WLR_HAVE_BACKEND_CREATE_WITH_LOOP +#cmakedefine01 WLR_HAVE_WL_POINTER_ENUMS #if HAVE_BREEZE_DECO #define BREEZE_KDECORATION_PLUGIN_ID "${BREEZE_KDECORATION_PLUGIN_ID}" diff --git a/como/base/wayland/screen_lock.h b/como/base/wayland/screen_lock.h deleted file mode 100644 index 48f2c6ee9b..0000000000 --- a/como/base/wayland/screen_lock.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - SPDX-FileCopyrightText: 2023 Roman Gilg - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#pragma once - -namespace como::base::wayland -{ - -template -bool is_screen_locked(Base const& base) -{ - if constexpr (requires(decltype(base) base) { base.server; }) { - return base.server->is_screen_locked(); - } - return false; -} - -} diff --git a/como/base/wayland/server.h b/como/base/wayland/server.h index 9d538adeaf..e652af37ab 100644 --- a/como/base/wayland/server.h +++ b/como/base/wayland/server.h @@ -1,7 +1,6 @@ /* SPDX-FileCopyrightText: 2015 Martin Gräßlin - SPDX-FileCopyrightText: 2021 Roman Gilg - + SPDX-FileCopyrightText: 2024 Roman Gilg SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once @@ -12,8 +11,8 @@ #include "como_export.h" #include #include +#include -#include #include #include #include @@ -42,9 +41,6 @@ namespace como::base::wayland class COMO_EXPORT server_qobject : public QObject { - Q_OBJECT -Q_SIGNALS: - void screenlocker_initialized(); }; template @@ -79,7 +75,7 @@ class server */ int create_xwayland_connection() { - const auto socket = create_connection(); + auto const socket = server_create_connection(*display); if (!socket.connection) { return -1; } @@ -101,23 +97,6 @@ class server m_xwayland.client = nullptr; } - bool is_screen_locked() const - { - if (!has_screen_locker_integration()) { - return false; - } - return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked - || ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock; - } - - /** - * @returns whether integration with KScreenLocker is available. - */ - bool has_screen_locker_integration() const - { - return flags(m_initFlags & start_options::lock_screen_integration); - } - /** * @returns whether any kind of global shortcuts are supported. */ @@ -131,95 +110,6 @@ class server return m_xwayland.client; } - /** - * Struct containing information for a created Wayland connection through a - * socketpair. - */ - struct socket_pair_connection { - /** - * ServerSide Connection - */ - Wrapland::Server::Client* connection = nullptr; - /** - * client-side file descriptor for the socket - */ - int fd = -1; - }; - /** - * Creates a Wayland connection using a socket pair. - */ - socket_pair_connection create_connection() - { - socket_pair_connection ret; - int sx[2]; - if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) { - qCWarning(KWIN_CORE) << "Could not create socket"; - return ret; - } - ret.connection = display->createClient(sx[0]); - ret.fd = sx[1]; - return ret; - } - - void init_screen_locker() - { - if (!has_screen_locker_integration()) { - return; - } - - auto* screenLockerApp = ScreenLocker::KSldApp::self(); - - ScreenLocker::KSldApp::self()->setGreeterEnvironment(base.process_environment); - ScreenLocker::KSldApp::self()->initialize(); - - QObject::connect(ScreenLocker::KSldApp::self(), - &ScreenLocker::KSldApp::aboutToLock, - qobject.get(), - [this, screenLockerApp]() { - if (screen_locker_client_connection) { - // Already sent data to KScreenLocker. - return; - } - int clientFd = create_screen_locker_connection(); - if (clientFd < 0) { - return; - } - ScreenLocker::KSldApp::self()->setWaylandFd(clientFd); - - for (auto& seat : seats) { - QObject::connect(seat.get(), - &Wrapland::Server::Seat::timestampChanged, - screenLockerApp, - &ScreenLocker::KSldApp::userActivity); - } - }); - - QObject::connect(ScreenLocker::KSldApp::self(), - &ScreenLocker::KSldApp::unlocked, - qobject.get(), - [this, screenLockerApp]() { - if (screen_locker_client_connection) { - screen_locker_client_connection->destroy(); - delete screen_locker_client_connection; - screen_locker_client_connection = nullptr; - } - - for (auto& seat : seats) { - QObject::disconnect(seat.get(), - &Wrapland::Server::Seat::timestampChanged, - screenLockerApp, - &ScreenLocker::KSldApp::userActivity); - } - ScreenLocker::KSldApp::self()->setWaylandFd(-1); - }); - - if (flags(m_initFlags & start_options::lock_screen)) { - ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); - } - - Q_EMIT qobject->screenlocker_initialized(); - } - std::unique_ptr qobject; std::unique_ptr display; std::unique_ptr output_manager; @@ -239,8 +129,6 @@ class server std::unique_ptr relative_pointer_manager_v1; std::unique_ptr security_context_manager_v1; - Wrapland::Server::Client* screen_locker_client_connection{nullptr}; - private: explicit server(Base& base, start_options flags) : qobject{std::make_unique()} @@ -312,20 +200,6 @@ class server = std::make_unique(display.get()); } - int create_screen_locker_connection() - { - const auto socket = create_connection(); - if (!socket.connection) { - return -1; - } - screen_locker_client_connection = socket.connection; - QObject::connect(screen_locker_client_connection, - &Wrapland::Server::Client::disconnected, - qobject.get(), - [this] { screen_locker_client_connection = nullptr; }); - return socket.fd; - } - struct { Wrapland::Server::Client* client = nullptr; QMetaObject::Connection destroyConnection; diff --git a/como/base/wayland/server_helpers.h b/como/base/wayland/server_helpers.h new file mode 100644 index 0000000000..8a5bcc56fb --- /dev/null +++ b/como/base/wayland/server_helpers.h @@ -0,0 +1,36 @@ +/* + SPDX-FileCopyrightText: 2024 Roman Gilg + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#pragma once + +#include + +#include +#include +#include + +namespace como::base::wayland +{ + +struct socket_pair_connection { + Wrapland::Server::Client* connection{nullptr}; + int fd = -1; +}; + +inline socket_pair_connection server_create_connection(Wrapland::Server::Display& display) +{ + socket_pair_connection ret; + int sx[2]; + + if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) { + qCWarning(KWIN_CORE) << "Could not create socket"; + return ret; + } + + ret.connection = display.createClient(sx[0]); + ret.fd = sx[1]; + return ret; +} + +} diff --git a/como/base/x11/event_filter_container.h b/como/base/x11/event_filter_container.h index 8104c540f1..bbf4bd923c 100644 --- a/como/base/x11/event_filter_container.h +++ b/como/base/x11/event_filter_container.h @@ -17,8 +17,6 @@ class event_filter; class COMO_EXPORT event_filter_container : public QObject { - Q_OBJECT - public: explicit event_filter_container(event_filter* filter); diff --git a/como/base/x11/event_filter_manager.cpp b/como/base/x11/event_filter_manager.cpp index 9088093fca..a729fce079 100644 --- a/como/base/x11/event_filter_manager.cpp +++ b/como/base/x11/event_filter_manager.cpp @@ -21,7 +21,7 @@ void event_filter_manager::register_filter(event_filter* filter) } static event_filter_container* take_filter(event_filter* filter, - std::vector>& filters) + std::vector& filters) { auto it = std::find_if(filters.cbegin(), filters.cend(), [filter](auto container) { return container->filter() == filter; diff --git a/como/base/x11/event_filter_manager.h b/como/base/x11/event_filter_manager.h index 4a3e3c13e8..a8e5e87051 100644 --- a/como/base/x11/event_filter_manager.h +++ b/como/base/x11/event_filter_manager.h @@ -6,8 +6,7 @@ #pragma once #include - -#include +#include namespace como::base::x11 { @@ -17,8 +16,8 @@ class event_filter_container; class COMO_EXPORT event_filter_manager { public: - std::vector> filters; - std::vector> generic_filters; + std::vector filters; + std::vector generic_filters; void register_filter(event_filter* filter); void unregister_filter(event_filter* filter); diff --git a/como/data/CMakeLists.txt b/como/data/CMakeLists.txt index d0117417cc..22d07b617c 100644 --- a/como/data/CMakeLists.txt +++ b/como/data/CMakeLists.txt @@ -1,8 +1,15 @@ # SPDX-FileCopyrightText: 2023 Roman Gilg -# # SPDX-License-Identifier: GPL-2.0-or-later -add_subdirectory(icons) +ecm_install_icons( + ICONS + icons/16-apps-kwin.png + icons/32-apps-kwin.png + icons/48-apps-kwin.png + icons/sc-apps-kwin.svgz + DESTINATION ${KDE_INSTALL_ICONDIR} + THEME hicolor +) ########### next target ############### add_executable(kwin5_update_default_rules update_default_rules.cpp) diff --git a/como/data/icons/CMakeLists.txt b/como/data/icons/CMakeLists.txt deleted file mode 100644 index 263b423a1d..0000000000 --- a/como/data/icons/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Roman Gilg -# -# SPDX-License-Identifier: GPL-2.0-or-later - -ecm_install_icons( - ICONS - 16-apps-kwin.png - 32-apps-kwin.png - 48-apps-kwin.png - sc-apps-kwin.svgz - DESTINATION - ${KDE_INSTALL_ICONDIR} - THEME - hicolor -) diff --git a/como/desktop/CMakeLists.txt b/como/desktop/CMakeLists.txt index b0b2ec2df2..a86134b2ac 100644 --- a/como/desktop/CMakeLists.txt +++ b/como/desktop/CMakeLists.txt @@ -26,6 +26,7 @@ target_sources(desktop FILE_SET HEADERS FILES platform.h + screen_locker.h screen_locker_watcher.h PRIVATE screen_locker_watcher.cpp @@ -60,7 +61,25 @@ target_sources(desktop-kde ${desktop_kde_dbus_src} ) -set_target_properties(desktop desktop-kde PROPERTIES +add_library(desktop-kde-wl SHARED) + +target_link_libraries(desktop-kde-wl + PUBLIC + desktop-kde + PW::KScreenLocker + WraplandServer +) + +target_sources(desktop-kde-wl + PUBLIC + FILE_SET HEADERS + FILES + kde/screen_locker.h + PRIVATE + kde/screen_locker.cpp +) + +set_target_properties(desktop desktop-kde desktop-kde-wl PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR} PREFIX libcomo- @@ -102,7 +121,7 @@ ecm_install_configured_files( @ONLY DESTINATION ${KDE_INSTALL_SYSTEMDUSERUNITDIR} ) -install(TARGETS desktop desktop-kde +install(TARGETS desktop desktop-kde desktop-kde-wl EXPORT como-export LIBRARY NAMELINK_SKIP FILE_SET HEADERS DESTINATION ${KDE_INSTALL_INCLUDEDIR}/como/desktop diff --git a/como/desktop/kde/screen_locker.cpp b/como/desktop/kde/screen_locker.cpp new file mode 100644 index 0000000000..e3a8816f00 --- /dev/null +++ b/como/desktop/kde/screen_locker.cpp @@ -0,0 +1,37 @@ +/* + SPDX-FileCopyrightText: 2024 Roman Gilg + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#include "screen_locker.h" + +#include + +namespace como::desktop::kde +{ + +bool screen_locker::is_locked() const +{ + return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked + || ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock; +} + +Wrapland::Server::Client* screen_locker::get_client() const +{ + return client; +} + +int screen_locker::create_client(Wrapland::Server::Display& display) +{ + auto const socket = base::wayland::server_create_connection(display); + if (!socket.connection) { + return -1; + } + + client = socket.connection; + QObject::connect( + client, &Wrapland::Server::Client::disconnected, this, [this] { client = nullptr; }); + + return socket.fd; +} + +} diff --git a/como/desktop/kde/screen_locker.h b/como/desktop/kde/screen_locker.h new file mode 100644 index 0000000000..d705982d29 --- /dev/null +++ b/como/desktop/kde/screen_locker.h @@ -0,0 +1,86 @@ +/* + SPDX-FileCopyrightText: 2024 Roman Gilg + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#pragma once + +#include +#include +#include +#include +#include + +#include +#include + +namespace como::desktop::kde +{ + +class COMO_EXPORT screen_locker : public desktop::screen_locker +{ +public: + template + screen_locker(Server& server, QProcessEnvironment const& env, bool start_locked) + { + auto sld_app = ScreenLocker::KSldApp::self(); + + ScreenLocker::KSldApp::self()->setGreeterEnvironment(env); + ScreenLocker::KSldApp::self()->initialize(); + + QObject::connect(ScreenLocker::KSldApp::self(), + &ScreenLocker::KSldApp::aboutToLock, + this, + [this, &server, sld_app]() { + if (client) { + // Already sent data to KScreenLocker. + return; + } + + int client_fd = create_client(*server.display); + if (client_fd < 0) { + return; + } + + ScreenLocker::KSldApp::self()->setWaylandFd(client_fd); + + for (auto&& seat : server.seats) { + QObject::connect(seat.get(), + &Wrapland::Server::Seat::timestampChanged, + sld_app, + &ScreenLocker::KSldApp::userActivity); + } + }); + + QObject::connect(ScreenLocker::KSldApp::self(), + &ScreenLocker::KSldApp::unlocked, + this, + [this, &server, sld_app]() { + if (client) { + client->destroy(); + delete client; + client = nullptr; + } + + for (auto& seat : server.seats) { + QObject::disconnect(seat.get(), + &Wrapland::Server::Seat::timestampChanged, + sld_app, + &ScreenLocker::KSldApp::userActivity); + } + ScreenLocker::KSldApp::self()->setWaylandFd(-1); + }); + + if (start_locked) { + ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); + } + } + + bool is_locked() const override; + Wrapland::Server::Client* get_client() const override; + +private: + int create_client(Wrapland::Server::Display& display); + Wrapland::Server::Client* client{nullptr}; +}; + +} diff --git a/como/desktop/platform.h b/como/desktop/platform.h index 1be652e7db..7e881c377f 100644 --- a/como/desktop/platform.h +++ b/como/desktop/platform.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include @@ -29,6 +30,7 @@ class platform virtual ~platform() = default; + std::unique_ptr screen_locker; std::unique_ptr screen_locker_watcher; }; diff --git a/como/desktop/screen_locker.h b/como/desktop/screen_locker.h new file mode 100644 index 0000000000..db3c5dd4bc --- /dev/null +++ b/como/desktop/screen_locker.h @@ -0,0 +1,32 @@ +/* + SPDX-FileCopyrightText: 2024 Roman Gilg + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#pragma once + +#include + +#include + +namespace Wrapland::Server +{ +class Client; +} + +namespace como::desktop +{ + +class COMO_EXPORT screen_locker : public QObject +{ + Q_OBJECT +public: + virtual bool is_locked() const = 0; + + virtual Wrapland::Server::Client* get_client() const = 0; + +Q_SIGNALS: + void locked(bool locked); + void unlocked(); +}; + +} diff --git a/como/input/CMakeLists.txt b/como/input/CMakeLists.txt index 6c37d33e8b..e1396cf73e 100644 --- a/como/input/CMakeLists.txt +++ b/como/input/CMakeLists.txt @@ -7,6 +7,8 @@ add_library(input SHARED) target_link_libraries(input PUBLIC win + # TODO(romangg): for lock_screen.h, remove. + PW::KScreenLocker ) target_sources(input @@ -30,7 +32,6 @@ target_sources(input filters/popup.h filters/screen_edge.h filters/tabbox.h - filters/terminate_server.h filters/virtual_terminal.h filters/window_action.h filters/window_selector.h diff --git a/como/input/backend/wlroots/pointer.h b/como/input/backend/wlroots/pointer.h index 36641a64a1..8e774f3704 100644 --- a/como/input/backend/wlroots/pointer.h +++ b/como/input/backend/wlroots/pointer.h @@ -82,13 +82,20 @@ void handle_button(struct wl_listener* listener, void* data) auto pointer = event_receiver_struct->receiver; auto wlr_event = reinterpret_cast(data); - auto event = button_event{ + auto event = button_event + { wlr_event->button, - wlr_event->state == WLR_BUTTON_RELEASED ? button_state::released : button_state::pressed, - { - pointer, - wlr_event->time_msec, - }, +#if WLR_HAVE_WL_POINTER_ENUMS + wlr_event->state == WL_POINTER_BUTTON_STATE_RELEASED ? button_state::released + : button_state::pressed, +#else + wlr_event->state == WLR_BUTTON_RELEASED ? button_state::released + : button_state::pressed, +#endif + { + pointer, + wlr_event->time_msec, + }, }; Q_EMIT pointer->button_changed(event); @@ -104,6 +111,16 @@ void handle_axis(struct wl_listener* listener, void* data) auto get_source = [](auto wlr_source) { switch (wlr_source) { +#if WLR_HAVE_WL_POINTER_ENUMS + case WL_POINTER_AXIS_SOURCE_WHEEL: + return axis_source::wheel; + case WL_POINTER_AXIS_SOURCE_FINGER: + return axis_source::finger; + case WL_POINTER_AXIS_SOURCE_CONTINUOUS: + return axis_source::continuous; + case WL_POINTER_AXIS_SOURCE_WHEEL_TILT: + return axis_source::wheel_tilt; +#else case WLR_AXIS_SOURCE_WHEEL: return axis_source::wheel; case WLR_AXIS_SOURCE_FINGER: @@ -112,6 +129,7 @@ void handle_axis(struct wl_listener* listener, void* data) return axis_source::continuous; case WLR_AXIS_SOURCE_WHEEL_TILT: return axis_source::wheel_tilt; +#endif default: return axis_source::unknown; } diff --git a/como/input/event_filter.h b/como/input/event_filter.h index 1a75cca395..a7a12d903d 100644 --- a/como/input/event_filter.h +++ b/como/input/event_filter.h @@ -31,7 +31,7 @@ namespace como::input template void process_filters(Filters const& filters, UnaryPredicate function) { - std::any_of(filters.cbegin(), filters.cend(), function); + static_cast(std::any_of(filters.cbegin(), filters.cend(), function)); } /** diff --git a/como/input/filters/lock_screen.h b/como/input/filters/lock_screen.h index e97609ff72..5f81d846aa 100644 --- a/como/input/filters/lock_screen.h +++ b/como/input/filters/lock_screen.h @@ -7,11 +7,11 @@ #include "helpers.h" -#include #include #include #include #include +#include #include #include @@ -34,7 +34,7 @@ class lock_screen_filter : public event_filter bool button(button_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } @@ -53,7 +53,7 @@ class lock_screen_filter : public event_filter bool motion(motion_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } @@ -71,7 +71,7 @@ class lock_screen_filter : public event_filter bool axis(axis_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } @@ -88,7 +88,7 @@ class lock_screen_filter : public event_filter bool key(key_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } @@ -120,12 +120,12 @@ class lock_screen_filter : public event_filter bool key_repeat(key_event const& /*event*/) override { // If screen is locked Wayland client takes care of it. - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } bool touch_down(touch_down_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } auto seat = this->redirect.platform.base.server->seat(); @@ -138,7 +138,7 @@ class lock_screen_filter : public event_filter bool touch_motion(touch_motion_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } auto seat = this->redirect.platform.base.server->seat(); @@ -154,7 +154,7 @@ class lock_screen_filter : public event_filter bool touch_up(touch_up_event const& event) override { - if (!base::wayland::is_screen_locked(this->redirect.platform.base)) { + if (!win::wayland::screen_lock_is_locked(this->redirect.space)) { return false; } auto seat = this->redirect.platform.base.server->seat(); @@ -172,37 +172,37 @@ class lock_screen_filter : public event_filter bool pinch_begin(pinch_begin_event const& /*event*/) override { // no touchpad multi-finger gestures on lock screen - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } bool pinch_update(pinch_update_event const& /*event*/) override { // no touchpad multi-finger gestures on lock screen - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } bool pinch_end(pinch_end_event const& /*event*/) override { // no touchpad multi-finger gestures on lock screen - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } bool swipe_begin(swipe_begin_event const& /*event*/) override { // no touchpad multi-finger gestures on lock screen - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } bool swipe_update(swipe_update_event const& /*event*/) override { // no touchpad multi-finger gestures on lock screen - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } bool swipe_end(swipe_end_event const& /*event*/) override { // no touchpad multi-finger gestures on lock screen - return base::wayland::is_screen_locked(this->redirect.platform.base); + return win::wayland::screen_lock_is_locked(this->redirect.space); } private: diff --git a/como/input/filters/terminate_server.h b/como/input/filters/terminate_server.h deleted file mode 100644 index b0946f252b..0000000000 --- a/como/input/filters/terminate_server.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - SPDX-FileCopyrightText: 2021 Roman Gilg - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#pragma once - -#include -#include -#include -#include -#include - -namespace como::input -{ - -template -class terminate_server_filter : public event_filter -{ -public: - explicit terminate_server_filter(Redirect& redirect) - : event_filter(redirect) - { - } - - bool key(key_event const& event) override - { - if (event.state == key_state::pressed) { - if (event.base.dev->xkb->to_keysym(event.keycode) == XKB_KEY_Terminate_Server) { - qCWarning(KWIN_CORE) << "Request to terminate server"; - QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection); - return true; - } - } - return false; - } -}; - -} diff --git a/como/input/wayland/cursor_image.h b/como/input/wayland/cursor_image.h index 6b668d524a..0b4fbcf94a 100644 --- a/como/input/wayland/cursor_image.h +++ b/como/input/wayland/cursor_image.h @@ -9,10 +9,10 @@ #pragma once #include "como_export.h" -#include #include #include #include +#include #include #include @@ -67,7 +67,7 @@ class cursor_image reevaluteSource(); }); - if (redirect.platform.base.server->has_screen_locker_integration()) { + if (win::wayland::screen_lock_is_supported(redirect.space)) { QObject::connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, qobject.get(), @@ -284,7 +284,7 @@ class cursor_image setSource(CursorSource::DragAndDrop); return; } - if (base::wayland::is_screen_locked(cursor.redirect.platform.base)) { + if (win::wayland::screen_lock_is_locked(cursor.redirect.space)) { setSource(CursorSource::LockScreen); return; } diff --git a/como/input/wayland/device_redirect.h b/como/input/wayland/device_redirect.h index a1233b7ebe..fbc4da6ee8 100644 --- a/como/input/wayland/device_redirect.h +++ b/como/input/wayland/device_redirect.h @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -227,7 +228,7 @@ QWindow* device_redirect_find_internal_window(Space& space, QPoint const& pos) if (space.windows.empty()) { return nullptr; } - if (base::wayland::is_screen_locked(space.base)) { + if (win::wayland::screen_lock_is_locked(space)) { return nullptr; } diff --git a/como/input/wayland/keyboard_redirect.h b/como/input/wayland/keyboard_redirect.h index 32e452a6a4..fd6f9f9a28 100644 --- a/como/input/wayland/keyboard_redirect.h +++ b/como/input/wayland/keyboard_redirect.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -121,7 +122,7 @@ class keyboard_redirect } update(); }); - if (redirect->platform.base.server->has_screen_locker_integration()) { + if (win::wayland::screen_lock_is_supported(redirect->space)) { QObject::connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, qobject.get(), diff --git a/como/input/wayland/pointer_redirect.h b/como/input/wayland/pointer_redirect.h index b0d7b995ab..136bbcf06f 100644 --- a/como/input/wayland/pointer_redirect.h +++ b/como/input/wayland/pointer_redirect.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -73,7 +74,7 @@ class pointer_redirect &base::platform_qobject::topology_changed, qobject.get(), [this] { updateAfterScreenChange(); }); - if (redirect->platform.base.server->has_screen_locker_integration()) { + if (win::wayland::screen_lock_is_supported(redirect->space)) { QObject::connect( ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, diff --git a/como/input/wayland/redirect.h b/como/input/wayland/redirect.h index 9bb984ac60..134160cc2e 100644 --- a/como/input/wayland/redirect.h +++ b/como/input/wayland/redirect.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -357,9 +356,6 @@ class redirect m_spies.push_back(new activity_spy(*this)); m_spies.push_back(new touch_hide_cursor_spy(*this)); - if (has_global_shortcuts) { - m_filters.emplace_back(new terminate_server_filter(*this)); - } m_filters.emplace_back(new drag_and_drop_filter(*this)); m_filters.emplace_back(new lock_screen_filter(*this)); m_filters.emplace_back(new popup_filter(*this)); diff --git a/como/input/wayland/touch_redirect.h b/como/input/wayland/touch_redirect.h index 81274434c2..6e67db5526 100644 --- a/como/input/wayland/touch_redirect.h +++ b/como/input/wayland/touch_redirect.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,7 @@ class touch_redirect { device_redirect_init(this); - if (redirect->platform.base.server->has_screen_locker_integration()) { + if (win::wayland::screen_lock_is_supported(redirect->space)) { QObject::connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, qobject.get(), diff --git a/como/input/window_find.h b/como/input/window_find.h index a170c232d3..dabd84292a 100644 --- a/como/input/window_find.h +++ b/como/input/window_find.h @@ -7,6 +7,7 @@ #include #include +#include namespace como::input { @@ -15,7 +16,7 @@ template auto find_controlled_window(Redirect const& redirect, QPoint const& pos) -> std::optional { - auto const isScreenLocked = base::wayland::is_screen_locked(redirect.platform.base); + auto const isScreenLocked = win::wayland::screen_lock_is_locked(redirect.space); auto const& stacking = redirect.space.stacking.order.stack; if (stacking.empty()) { return {}; @@ -71,7 +72,7 @@ template auto find_window(Redirect const& redirect, QPoint const& pos) -> std::optional { - if (base::wayland::is_screen_locked(redirect.platform.base)) { + if (win::wayland::screen_lock_is_locked(redirect.space)) { return find_controlled_window(redirect, pos); } diff --git a/como/input/x11/xinput_integration.h b/como/input/x11/xinput_integration.h index 57aafcc0c2..8a6816f514 100644 --- a/como/input/x11/xinput_integration.h +++ b/como/input/x11/xinput_integration.h @@ -27,7 +27,7 @@ namespace como::input::x11 static inline qreal fixed1616ToReal(FP1616 val) { - return (val)*1.0 / (1 << 16); + return (val) * 1.0 / (1 << 16); } template diff --git a/como/input/xkb/manager.h b/como/input/xkb/manager.h index 1cf0785d4e..5b6535c00d 100644 --- a/como/input/xkb/manager.h +++ b/como/input/xkb/manager.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/como/render/effect/interface/anidata.cpp b/como/render/effect/interface/anidata.cpp index edd23eb787..c2ad6784b4 100644 --- a/como/render/effect/interface/anidata.cpp +++ b/como/render/effect/interface/anidata.cpp @@ -59,7 +59,7 @@ AniData::AniData(AnimationEffect::Attribute a, int delay, const FPx2& from_, bool waitAtSource_, - FullScreenEffectLockPtr fullScreenEffectLock_, + std::shared_ptr const& fullScreenEffectLock, bool keepAlive, PreviousWindowPixmapLockPtr previousWindowPixmapLock_, GLShader* shader) @@ -69,7 +69,7 @@ AniData::AniData(AnimationEffect::Attribute a, , meta(meta_) , startTime(AnimationEffect::clock() + delay) , frozenTime(-1) - , fullScreenEffectLock(std::move(fullScreenEffectLock_)) + , fullScreenEffectLock{fullScreenEffectLock} , waitAtSource(waitAtSource_) , keepAlive(keepAlive) , previousWindowPixmapLock(std::move(previousWindowPixmapLock_)) diff --git a/como/render/effect/interface/anidata_p.h b/como/render/effect/interface/anidata_p.h index ebe7b07420..428f39d4be 100644 --- a/como/render/effect/interface/anidata_p.h +++ b/como/render/effect/interface/anidata_p.h @@ -34,7 +34,6 @@ class FullScreenEffectLock private: Q_DISABLE_COPY(FullScreenEffectLock) }; -typedef QSharedPointer FullScreenEffectLockPtr; /** * References the previous window pixmap to prevent discarding. @@ -61,7 +60,7 @@ class COMO_EXPORT AniData int delay, const FPx2& from, bool waitAtSource, - FullScreenEffectLockPtr = FullScreenEffectLockPtr(), + std::shared_ptr const& fullScreenEffectLock = nullptr, bool keepAlive = true, PreviousWindowPixmapLockPtr previousWindowPixmapLock = {}, GLShader* shader = nullptr); @@ -82,7 +81,7 @@ class COMO_EXPORT AniData uint meta; qint64 startTime; qint64 frozenTime; - QSharedPointer fullScreenEffectLock; + std::shared_ptr fullScreenEffectLock; bool waitAtSource; bool keepAlive; EffectWindowDeletedRef deletedRef; diff --git a/como/render/effect/interface/animation_effect.cpp b/como/render/effect/interface/animation_effect.cpp index 1f8eed0e40..8d513f4469 100644 --- a/como/render/effect/interface/animation_effect.cpp +++ b/como/render/effect/interface/animation_effect.cpp @@ -41,7 +41,7 @@ class AnimationEffectPrivate AnimationEffect::AniMap m_animations; static quint64 m_animCounter; quint64 m_justEndedAnimation; // protect against cancel - QWeakPointer m_fullScreenEffectLock; + std::weak_ptr m_fullScreenEffectLock; bool m_needSceneRepaint, m_animationsTouched, m_isInitialized; }; } @@ -51,7 +51,7 @@ using namespace como; quint64 AnimationEffectPrivate::m_animCounter = 0; AnimationEffect::AnimationEffect() - : d_ptr(new AnimationEffectPrivate()) + : d_ptr{std::make_unique()} { if (!s_clock.isValid()) s_clock.start(); @@ -60,17 +60,13 @@ AnimationEffect::AnimationEffect() QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection); } -AnimationEffect::~AnimationEffect() -{ - delete d_ptr; -} +AnimationEffect::~AnimationEffect() = default; void AnimationEffect::init() { - Q_D(AnimationEffect); - if (d->m_isInitialized) + if (d_ptr->m_isInitialized) return; // not more than once, please - d->m_isInitialized = true; + d_ptr->m_isInitialized = true; /* by connecting the signal from a slot AFTER the inheriting class constructor had the chance to * connect it we can provide auto-referencing of animated and closed windows, since at the time * our slot will be called, the slot of the subclass has been (SIGNAL/SLOT connections are FIFO) @@ -81,8 +77,7 @@ void AnimationEffect::init() bool AnimationEffect::isActive() const { - Q_D(const AnimationEffect); - return !d->m_animations.isEmpty() && !effects->isScreenLocked(); + return !d_ptr->m_animations.isEmpty() && !effects->isScreenLocked(); } #define RELATIVE_XY(_FIELD_) \ @@ -228,25 +223,23 @@ quint64 AnimationEffect::p_animate(EffectWindow* w, const bool waitAtSource = from.isValid(); validate(a, meta, &from, &to, w); - Q_D(AnimationEffect); - if (!d->m_isInitialized) + if (!d_ptr->m_isInitialized) init(); // needs to ensure the window gets removed if deleted in the same event cycle - auto it = d->m_animations.find(w); - if (it == d->m_animations.end()) { + auto it = d_ptr->m_animations.find(w); + if (it == d_ptr->m_animations.end()) { connect(w, &EffectWindow::windowExpandedGeometryChanged, this, &AnimationEffect::_windowExpandedGeometryChanged); - it = d->m_animations.insert(w, QPair, QRect>(QList(), QRect())); + it = d_ptr->m_animations.insert(w, QPair, QRect>(QList(), QRect())); } - FullScreenEffectLockPtr fullscreen; + std::shared_ptr fullscreen; if (fullScreenEffect) { - if (d->m_fullScreenEffectLock.isNull()) { - fullscreen = FullScreenEffectLockPtr::create(this); - d->m_fullScreenEffectLock = fullscreen.toWeakRef(); - } else { - fullscreen = d->m_fullScreenEffectLock.toStrongRef(); + fullscreen = d_ptr->m_fullScreenEffectLock.lock(); + if (!fullscreen) { + fullscreen = std::make_shared(this); + d_ptr->m_fullScreenEffectLock = fullscreen; } } @@ -266,7 +259,7 @@ quint64 AnimationEffect::p_animate(EffectWindow* w, previousPixmap, // Previous window pixmap lock shader)); - const quint64 ret_id = ++d->m_animCounter; + const quint64 ret_id = ++d_ptr->m_animCounter; AniData& animation = it->first.last(); animation.id = ret_id; @@ -287,7 +280,7 @@ quint64 AnimationEffect::p_animate(EffectWindow* w, it->second = QRect(); - d->m_animationsTouched = true; + d_ptr->m_animationsTouched = true; if (delay > 0) { QTimer::singleShot(delay, this, &AnimationEffect::triggerRepaint); @@ -308,13 +301,13 @@ quint64 AnimationEffect::p_animate(EffectWindow* w, bool AnimationEffect::retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime) { - Q_D(AnimationEffect); - if (animationId == d->m_justEndedAnimation) { + if (animationId == d_ptr->m_justEndedAnimation) { // this is just ending, do not try to retarget it return false; } - for (auto entry = d->m_animations.begin(), mapEnd = d->m_animations.end(); entry != mapEnd; + for (auto entry = d_ptr->m_animations.begin(), mapEnd = d_ptr->m_animations.end(); + entry != mapEnd; ++entry) { for (auto anim = entry->first.begin(), animEnd = entry->first.end(); anim != animEnd; ++anim) { @@ -336,12 +329,11 @@ bool AnimationEffect::retarget(quint64 animationId, FPx2 newTarget, int newRemai bool AnimationEffect::freezeInTime(quint64 animationId, qint64 frozenTime) { - Q_D(AnimationEffect); - - if (animationId == d->m_justEndedAnimation) { + if (animationId == d_ptr->m_justEndedAnimation) { return false; // this is just ending, do not try to retarget it } - for (auto entry = d->m_animations.begin(), mapEnd = d->m_animations.end(); entry != mapEnd; + for (auto entry = d_ptr->m_animations.begin(), mapEnd = d_ptr->m_animations.end(); + entry != mapEnd; ++entry) { for (auto anim = entry->first.begin(), animEnd = entry->first.end(); anim != animEnd; ++anim) { @@ -361,13 +353,12 @@ bool AnimationEffect::redirect(quint64 animationId, Direction direction, TerminationFlags terminationFlags) { - Q_D(AnimationEffect); - - if (animationId == d->m_justEndedAnimation) { + if (animationId == d_ptr->m_justEndedAnimation) { return false; } - for (auto entryIt = d->m_animations.begin(); entryIt != d->m_animations.end(); ++entryIt) { + for (auto entryIt = d_ptr->m_animations.begin(); entryIt != d_ptr->m_animations.end(); + ++entryIt) { auto animIt = std::find_if(entryIt->first.begin(), entryIt->first.end(), [animationId](AniData& anim) { return anim.id == animationId; }); @@ -395,13 +386,12 @@ bool AnimationEffect::redirect(quint64 animationId, bool AnimationEffect::complete(quint64 animationId) { - Q_D(AnimationEffect); - - if (animationId == d->m_justEndedAnimation) { + if (animationId == d_ptr->m_justEndedAnimation) { return false; } - for (auto entryIt = d->m_animations.begin(); entryIt != d->m_animations.end(); ++entryIt) { + for (auto entryIt = d_ptr->m_animations.begin(); entryIt != d_ptr->m_animations.end(); + ++entryIt) { auto animIt = std::find_if(entryIt->first.begin(), entryIt->first.end(), [animationId](AniData& anim) { return anim.id == animationId; }); @@ -419,13 +409,13 @@ bool AnimationEffect::complete(quint64 animationId) bool AnimationEffect::cancel(quint64 animationId) { - Q_D(AnimationEffect); - if (animationId == d->m_justEndedAnimation) { + if (animationId == d_ptr->m_justEndedAnimation) { // this is just ending, do not try to cancel it but fake success return true; } - for (auto entry = d->m_animations.begin(), mapEnd = d->m_animations.end(); entry != mapEnd; + for (auto entry = d_ptr->m_animations.begin(), mapEnd = d_ptr->m_animations.end(); + entry != mapEnd; ++entry) { for (auto anim = entry->first.begin(), animEnd = entry->first.end(); anim != animEnd; ++anim) { @@ -443,9 +433,9 @@ bool AnimationEffect::cancel(quint64 animationId) &EffectWindow::windowExpandedGeometryChanged, this, &AnimationEffect::_windowExpandedGeometryChanged); - d->m_animations.erase(entry); + d_ptr->m_animations.erase(entry); } - d->m_animationsTouched = true; // could be called from animationEnded + d_ptr->m_animationsTouched = true; // could be called from animationEnded return true; } } @@ -498,10 +488,9 @@ QRect AnimationEffect::clipRect(const QRect& geo, const AniData& anim) const void AnimationEffect::prePaintWindow(effect::window_prepaint_data& data) { - Q_D(AnimationEffect); - auto entry = d->m_animations.find(&data.window); + auto entry = d_ptr->m_animations.find(&data.window); - if (entry != d->m_animations.end()) { + if (entry != d_ptr->m_animations.end()) { for (auto anim = entry->first.begin(); anim != entry->first.end(); ++anim) { if (anim->startTime > clock() && !anim->waitAtSource) { continue; @@ -533,9 +522,8 @@ static inline float geometryCompensation(int flags, float v) void AnimationEffect::paintWindow(effect::window_paint_data& data) { - Q_D(AnimationEffect); - auto entry = d->m_animations.constFind(&data.window); - if (entry != d->m_animations.constEnd()) { + auto entry = d_ptr->m_animations.constFind(&data.window); + if (entry != d_ptr->m_animations.constEnd()) { for (QList::const_iterator anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) { @@ -684,11 +672,10 @@ void AnimationEffect::paintWindow(effect::window_paint_data& data) void AnimationEffect::postPaintScreen() { - Q_D(AnimationEffect); - d->m_animationsTouched = false; + d_ptr->m_animationsTouched = false; bool damageDirty = false; - for (auto entry = d->m_animations.begin(); entry != d->m_animations.end();) { + for (auto entry = d_ptr->m_animations.begin(); entry != d_ptr->m_animations.end();) { bool invalidateLayerRect = false; int animCounter = 0; for (auto anim = entry->first.begin(); anim != entry->first.end();) { @@ -698,7 +685,7 @@ void AnimationEffect::postPaintScreen() continue; } auto window = entry.key(); - d->m_justEndedAnimation = anim->id; + d_ptr->m_justEndedAnimation = anim->id; if (anim->shader && std::none_of( entry->first.begin(), entry->first.end(), [anim](const auto& other) { @@ -707,19 +694,20 @@ void AnimationEffect::postPaintScreen() unredirect(window); } animationEnded(window, anim->attribute, anim->meta); - d->m_justEndedAnimation = 0; + d_ptr->m_justEndedAnimation = 0; // NOTICE animationEnded is an external call and might have called "::animate" // as a result our iterators could now point random junk on the heap // so we've to restore the former states, ie. find our window list and animation - if (d->m_animationsTouched) { - d->m_animationsTouched = false; - entry = d->m_animations.begin(); - while (entry.key() != window && entry != d->m_animations.end()) { + if (d_ptr->m_animationsTouched) { + d_ptr->m_animationsTouched = false; + entry = d_ptr->m_animations.begin(); + while (entry.key() != window && entry != d_ptr->m_animations.end()) { ++entry; } - Q_ASSERT(entry - != d->m_animations.end()); // usercode should not delete animations from - // animationEnded (not even possible atm.) + Q_ASSERT( + entry + != d_ptr->m_animations.end()); // usercode should not delete animations from + // animationEnded (not even possible atm.) anim = entry->first.begin(); Q_ASSERT(animCounter < entry->first.count()); for (int i = 0; i < animCounter; ++i) { @@ -735,7 +723,7 @@ void AnimationEffect::postPaintScreen() this, &AnimationEffect::_windowExpandedGeometryChanged); effects->addRepaint(entry->second); - entry = d->m_animations.erase(entry); + entry = d_ptr->m_animations.erase(entry); } else { if (invalidateLayerRect) { *const_cast(&(entry->second)) = QRect(); // invalidate @@ -747,10 +735,10 @@ void AnimationEffect::postPaintScreen() if (damageDirty) { updateLayerRepaints(); } - if (d->m_needSceneRepaint) { + if (d_ptr->m_needSceneRepaint) { effects->addRepaintFull(); } else { - for (auto entry = d->m_animations.constBegin(); entry != d->m_animations.constEnd(); + for (auto entry = d_ptr->m_animations.constBegin(); entry != d_ptr->m_animations.constEnd(); ++entry) { for (auto anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) { if (anim->startTime > clock()) @@ -838,15 +826,16 @@ void AnimationEffect::setMetaData(MetaType type, uint value, uint& meta) void AnimationEffect::triggerRepaint() { - Q_D(AnimationEffect); - for (auto entry = d->m_animations.constBegin(); entry != d->m_animations.constEnd(); ++entry) { + for (auto entry = d_ptr->m_animations.constBegin(); entry != d_ptr->m_animations.constEnd(); + ++entry) { *const_cast(&(entry->second)) = QRect(); } updateLayerRepaints(); - if (d->m_needSceneRepaint) { + if (d_ptr->m_needSceneRepaint) { effects->addRepaintFull(); } else { - for (auto it = d->m_animations.constBegin(); it != d->m_animations.constEnd(); ++it) { + for (auto it = d_ptr->m_animations.constBegin(); it != d_ptr->m_animations.constEnd(); + ++it) { it.key()->addLayerRepaint(it->second); } } @@ -872,9 +861,9 @@ static float fixOvershoot(float f, const AniData& d, short int dir, float s = 1. void AnimationEffect::updateLayerRepaints() { - Q_D(AnimationEffect); - d->m_needSceneRepaint = false; - for (auto entry = d->m_animations.constBegin(); entry != d->m_animations.constEnd(); ++entry) { + d_ptr->m_needSceneRepaint = false; + for (auto entry = d_ptr->m_animations.constBegin(); entry != d_ptr->m_animations.constEnd(); + ++entry) { if (!entry->second.isNull()) { continue; } @@ -905,7 +894,7 @@ void AnimationEffect::updateLayerRepaints() case Generic: // we don't know whether this will change visual stacking order // sic! no need to do anything else - d->m_needSceneRepaint = true; + d_ptr->m_needSceneRepaint = true; return; case Translation: case Position: { @@ -1004,9 +993,7 @@ void AnimationEffect::updateLayerRepaints() void AnimationEffect::_windowExpandedGeometryChanged(como::EffectWindow* w) { - Q_D(AnimationEffect); - - if (auto entry = d->m_animations.constFind(w); entry != d->m_animations.constEnd()) { + if (auto entry = d_ptr->m_animations.constFind(w); entry != d_ptr->m_animations.constEnd()) { *const_cast(&(entry->second)) = QRect(); updateLayerRepaints(); if (!entry->second.isNull()) { @@ -1018,10 +1005,8 @@ void AnimationEffect::_windowExpandedGeometryChanged(como::EffectWindow* w) void AnimationEffect::_windowClosed(EffectWindow* w) { - Q_D(AnimationEffect); - - auto it = d->m_animations.find(w); - if (it == d->m_animations.end()) { + auto it = d_ptr->m_animations.find(w); + if (it == d_ptr->m_animations.end()) { return; } @@ -1035,21 +1020,19 @@ void AnimationEffect::_windowClosed(EffectWindow* w) void AnimationEffect::_windowDeleted(EffectWindow* w) { - Q_D(AnimationEffect); - d->m_animations.remove(w); + d_ptr->m_animations.remove(w); } QString AnimationEffect::debug(const QString& /*parameter*/) const { - Q_D(const AnimationEffect); - - if (d->m_animations.isEmpty()) { + if (d_ptr->m_animations.isEmpty()) { return QStringLiteral("No window is animated"); } QString dbg; - for (auto entry = d->m_animations.constBegin(); entry != d->m_animations.constEnd(); ++entry) { + for (auto entry = d_ptr->m_animations.constBegin(); entry != d_ptr->m_animations.constEnd(); + ++entry) { auto caption = entry.key()->isDeleted() ? QStringLiteral("[Deleted]") : entry.key()->caption(); if (caption.isEmpty()) { @@ -1066,6 +1049,5 @@ QString AnimationEffect::debug(const QString& /*parameter*/) const AnimationEffect::AniMap AnimationEffect::state() const { - Q_D(const AnimationEffect); - return d->m_animations; + return d_ptr->m_animations; } diff --git a/como/render/effect/interface/animation_effect.h b/como/render/effect/interface/animation_effect.h index 3c5d82bdeb..304d624b8c 100644 --- a/como/render/effect/interface/animation_effect.h +++ b/como/render/effect/interface/animation_effect.h @@ -564,7 +564,7 @@ private Q_SLOTS: private: static QElapsedTimer s_clock; - AnimationEffectPrivate* const d_ptr; + std::unique_ptr const d_ptr; Q_DECLARE_PRIVATE(AnimationEffect) Q_DISABLE_COPY(AnimationEffect) }; diff --git a/como/render/effect/interface/quick_scene.cpp b/como/render/effect/interface/quick_scene.cpp index edc0066429..45939a3aad 100644 --- a/como/render/effect/interface/quick_scene.cpp +++ b/como/render/effect/interface/quick_scene.cpp @@ -58,25 +58,42 @@ class QuickSceneViewIncubator : public QQmlIncubator std::unique_ptr m_view; }; -class QuickSceneEffectPrivate +class QuickSceneEffectPrivate : QObject { public: + void set_mouse_implicit_grab(QuickSceneView* view); + bool isItemOnScreen(QQuickItem* item, EffectScreen const* screen) const; + static QuickSceneEffectPrivate* get(QuickSceneEffect* effect) { return effect->d.get(); } - bool isItemOnScreen(QQuickItem* item, EffectScreen const* screen) const; - std::unique_ptr delegate; + QPointer delegate; QUrl source; std::map> contexts; std::map> incubators; std::map> views; - QPointer mouseImplicitGrab; + QuickSceneView* mouseImplicitGrab{nullptr}; bool running = false; EffectScreen const* paintedScreen{nullptr}; }; +void QuickSceneEffectPrivate::set_mouse_implicit_grab(QuickSceneView* view) +{ + if (mouseImplicitGrab == view) { + return; + } + if (mouseImplicitGrab) { + QObject::disconnect(mouseImplicitGrab, &QObject::destroyed, this, nullptr); + } + if (view) { + QObject::connect( + view, &QObject::destroyed, this, [this] { set_mouse_implicit_grab(nullptr); }); + } + mouseImplicitGrab = view; +} + bool QuickSceneEffectPrivate::isItemOnScreen(QQuickItem* item, EffectScreen const* screen) const { if (!item || !screen || !views.contains(screen)) { @@ -172,7 +189,7 @@ QuickSceneView* QuickSceneView::qmlAttachedProperties(QObject* object) QuickSceneEffect::QuickSceneEffect(QObject* parent) : Effect(parent) - , d(new QuickSceneEffectPrivate) + , d{std::make_unique()} { } @@ -253,7 +270,7 @@ void QuickSceneEffect::setSource(const QUrl& url) } if (d->source != url) { d->source = url; - d->delegate.reset(); + d->delegate.clear(); } } @@ -270,7 +287,7 @@ void QuickSceneEffect::setDelegate(QQmlComponent* delegate) } if (d->delegate.get() != delegate) { d->source = QUrl(); - d->delegate.reset(delegate); + d->delegate = delegate; Q_EMIT delegateChanged(); } } @@ -499,11 +516,12 @@ void QuickSceneEffect::startInternal() return; } - d->delegate = std::make_unique(effects->qmlEngine()); + d->delegate = new QQmlComponent(effects->qmlEngine(), this); d->delegate->loadUrl(d->source); + if (d->delegate->isError()) { qWarning().nospace() << "Failed to load " << d->source << ": " << d->delegate->errors(); - d->delegate.reset(); + d->delegate.clear(); return; } Q_EMIT delegateChanged(); @@ -567,7 +585,7 @@ void QuickSceneEffect::windowInputMouseEvent(QEvent* event) if (buttons) { if (!d->mouseImplicitGrab) { - d->mouseImplicitGrab = viewAt(globalPosition); + d->set_mouse_implicit_grab(viewAt(globalPosition)); } } @@ -577,7 +595,7 @@ void QuickSceneEffect::windowInputMouseEvent(QEvent* event) } if (!buttons) { - d->mouseImplicitGrab = nullptr; + d->set_mouse_implicit_grab(nullptr); } if (target) { diff --git a/como/render/gl/scene.h b/como/render/gl/scene.h index 5ef4bf7f29..a711cd689a 100644 --- a/como/render/gl/scene.h +++ b/como/render/gl/scene.h @@ -283,7 +283,8 @@ class scene : public render::scene { auto& eff_win = static_cast(data.window); - if (base::wayland::is_screen_locked(this->platform.base)) { + if (this->windowing_integration.is_screen_locked + && this->windowing_integration.is_screen_locked()) { if (std::visit(overload{[&](auto&& win) { if constexpr (requires(decltype(win) win) { win.isLockScreen(); }) { if (win->isLockScreen()) { diff --git a/como/render/post/night_color_manager.h b/como/render/post/night_color_manager.h index 62df2ad677..a0b14c7085 100644 --- a/como/render/post/night_color_manager.h +++ b/como/render/post/night_color_manager.h @@ -44,8 +44,9 @@ inline void night_color_display_inhibit_message(bool inhibit, bool show_day_stat : show_day_status ? QStringLiteral("redshift-status-day") : QStringLiteral("redshift-status-on"); - auto const text = inhibit ? i18nc("Night Light was disabled", "Night Light Off") - : i18nc("Night Light was enabled", "Night Light On"); + auto const text = inhibit + ? i18nc("Night Light was temporarily disabled", "Night Light Suspended") + : i18nc("Night Light was reenabled from temporary suspension", "Night Light Resumed"); auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"), diff --git a/como/render/post/night_color_setup.h b/como/render/post/night_color_setup.h index 3ba4ef66f4..776c2cf6d2 100644 --- a/como/render/post/night_color_setup.h +++ b/como/render/post/night_color_setup.h @@ -19,7 +19,8 @@ void init_night_color_shortcuts(Input& input, NightColor& manager) auto toggleAction = new QAction(manager.qobject.get()); toggleAction->setProperty("componentName", "kwin"); toggleAction->setObjectName(QStringLiteral("Toggle Night Color")); - toggleAction->setText(i18n("Toggle Night Light")); + toggleAction->setText( + i18nc("Temporarily disable/reenable Night Light", "Suspend/Resume Night Light")); input.shortcuts->register_keyboard_default_shortcut(toggleAction, {}); input.shortcuts->register_keyboard_shortcut(toggleAction, {}); diff --git a/como/render/qml/frames/plasma/frame_unstyled.qml b/como/render/qml/frames/plasma/frame_unstyled.qml index c817f09054..132675084d 100644 --- a/como/render/qml/frames/plasma/frame_unstyled.qml +++ b/como/render/qml/frames/plasma/frame_unstyled.qml @@ -9,7 +9,7 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls as QQC2 -import org.kde.kirigami 2.12 as Kirigami +import org.kde.kirigami as Kirigami Rectangle { id: root @@ -20,7 +20,7 @@ Rectangle { implicitHeight: layout.implicitHeight + 2 * layout.anchors.margins color: Qt.rgba(0, 0, 0, effectFrame.frameOpacity) - radius: layout.anchors.margins + radius: Kirigami.Units.cornerRadius RowLayout { id: layout diff --git a/como/render/scene.h b/como/render/scene.h index fd4c7cb034..f0833715a3 100644 --- a/como/render/scene.h +++ b/como/render/scene.h @@ -11,7 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include "singleton_interface.h" #include "types.h" -#include #include #include #include @@ -32,6 +31,7 @@ namespace como::render struct scene_windowing_integration { std::function handle_viewport_limits_alarm; + std::function is_screen_locked; }; /** @@ -625,7 +625,7 @@ class scene : public QObject auto& eff_win = static_cast(data.window); auto mask = static_cast(data.paint.mask); - if (base::wayland::is_screen_locked(platform.base)) { + if (windowing_integration.is_screen_locked && windowing_integration.is_screen_locked()) { if (!std::visit( overload{[](auto&& win) { auto do_draw{false}; diff --git a/como/render/wayland/output.h b/como/render/wayland/output.h index 672e336932..1a15b87ce2 100644 --- a/como/render/wayland/output.h +++ b/como/render/wayland/output.h @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -405,7 +406,8 @@ class output : public QObject } idle = false; - auto const screen_lock_filtered = base::wayland::is_screen_locked(platform.base); + auto const screen_lock_filtered + = win::wayland::screen_lock_is_locked(*platform.base.mod.space); // Skip windows that are not yet ready for being painted and if screen is locked skip // windows that are neither lockscreen nor inputmethod windows. diff --git a/como/render/wayland/platform.h b/como/render/wayland/platform.h index 8957605942..f5a80acf2d 100644 --- a/como/render/wayland/platform.h +++ b/como/render/wayland/platform.h @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -257,10 +258,16 @@ class platform std::unique_ptr create_scene() { + auto setup_hooks = [&, this](auto scene) -> decltype(scene) { + scene->windowing_integration.is_screen_locked + = [&, this] { return win::wayland::screen_lock_is_locked(*space); }; + return scene; + }; + if (is_sw_compositing()) { - return qpainter::create_scene(*this); + return setup_hooks(qpainter::create_scene(*this)); } - return gl::create_scene(*this); + return setup_hooks(gl::create_scene(*this)); } template diff --git a/como/script/window_thumbnail_item.cpp b/como/script/window_thumbnail_item.cpp index 460885c4ad..61a1bd420e 100644 --- a/como/script/window_thumbnail_item.cpp +++ b/como/script/window_thumbnail_item.cpp @@ -45,6 +45,7 @@ window_thumbnail_source::window_thumbnail_source(QQuickWindow* view, , m_handle(handle) , wId{wId} { + connect(handle, &QObject::destroyed, this, [this]() { m_handle = nullptr; }); connect(handle, &scripting::window::frameGeometryChanged, this, [this]() { m_dirty = true; Q_EMIT changed(); @@ -109,7 +110,6 @@ void window_thumbnail_source::update(effect::screen_paint_data& data) if (m_acquireFence || !m_dirty || !m_handle) { return; } - Q_ASSERT(m_view); auto const geometry = m_handle->visibleRect(); auto const dpi = m_view->devicePixelRatio(); @@ -397,6 +397,7 @@ void window_thumbnail_item::setClient(scripting::window* client) &scripting::window::frameGeometryChanged, this, &window_thumbnail_item::updateImplicitSize); + disconnect(m_client, &QObject::destroyed, this, nullptr); } m_client = client; if (m_client) { @@ -404,6 +405,7 @@ void window_thumbnail_item::setClient(scripting::window* client) &scripting::window::frameGeometryChanged, this, &window_thumbnail_item::updateImplicitSize); + connect(m_client, &QObject::destroyed, this, [this] { m_client = nullptr; }); setWId(m_client->internalId()); } else { setWId(QUuid()); diff --git a/como/script/window_thumbnail_item.h b/como/script/window_thumbnail_item.h index e8309789a5..763a325ff5 100644 --- a/como/script/window_thumbnail_item.h +++ b/como/script/window_thumbnail_item.h @@ -12,8 +12,8 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include - #include +#include namespace como { @@ -50,8 +50,8 @@ class window_thumbnail_source : public QObject private: void update(como::effect::screen_paint_data& data); - QPointer m_view; - QPointer m_handle; + gsl::not_null m_view; + scripting::window* m_handle; std::shared_ptr m_offscreenTexture; std::unique_ptr m_offscreenTarget; @@ -95,7 +95,7 @@ class COMO_EXPORT window_thumbnail_item : public QQuickItem void reset_source(); QUuid m_wId; - QPointer m_client; + scripting::window* m_client{nullptr}; mutable ThumbnailTextureProvider* m_provider = nullptr; std::shared_ptr m_source; diff --git a/como/win/CMakeLists.txt b/como/win/CMakeLists.txt index b303f07862..8808cf091e 100644 --- a/como/win/CMakeLists.txt +++ b/como/win/CMakeLists.txt @@ -9,7 +9,9 @@ target_link_libraries(win PUBLIC KDecoration2::KDecoration KDecoration2::KDecoration2Private - KF6::ConfigWidgets + KF6::ColorScheme + KF6::ConfigCore + KF6::ConfigGui KF6::CoreAddons KF6::I18n KF6::Package @@ -341,6 +343,7 @@ target_sources(win-wl wayland/plasma_window.h wayland/popup_placement.h wayland/scene.h + wayland/screen_lock.h wayland/session_manager.h wayland/setup.h wayland/space.h diff --git a/como/win/deco/bridge.h b/como/win/deco/bridge.h index b693a6dd20..2d8857c043 100644 --- a/como/win/deco/bridge.h +++ b/como/win/deco/bridge.h @@ -99,7 +99,7 @@ class bridge : public KDecoration2::DecorationBridge if (!m_theme.isEmpty()) { args.insert(QStringLiteral("theme"), m_theme); } - auto deco = m_factory->create(window, QVariantList({args})); + auto deco = m_factory->create(window, QVariantList{args}); deco->setSettings(m_settings); deco->init(); return deco; diff --git a/como/win/deco/settings.h b/como/win/deco/settings.h index 0f62d618a2..0eb581d859 100644 --- a/como/win/deco/settings.h +++ b/como/win/deco/settings.h @@ -110,6 +110,7 @@ class settings : public QObject, public KDecoration2::DecorationSettingsPrivate s_buttonNames[KDecoration2::DecorationButtonType::KeepAbove] = QChar('F'); s_buttonNames[KDecoration2::DecorationButtonType::KeepBelow] = QChar('B'); s_buttonNames[KDecoration2::DecorationButtonType::Shade] = QChar('L'); + s_buttonNames[KDecoration2::DecorationButtonType::Spacer] = QChar('_'); } QString buttonsToString(QVector const& buttons) const diff --git a/como/win/meta.h b/como/win/meta.h index b31b92a1fe..17f4a82873 100644 --- a/como/win/meta.h +++ b/como/win/meta.h @@ -91,39 +91,6 @@ bool is_special_window(Win const* win) || is_notification(win) || is_critical_notification(win) || is_on_screen_display(win); } -/** - * Looks for another window with same captionNormal and captionSuffix. - * If no such window exists @c nullptr is returned. - */ -template -std::optional find_client_with_same_caption(Win const* win) -{ - for (auto candidate : win->space.windows) { - if (std::visit(overload{[&](auto&& candidate) { - if constexpr (std::is_same_v, Win*>) { - if (candidate == win) { - return false; - } - } - if (!candidate->control) { - return false; - } - if (is_special_window(candidate) && !is_toolbar(candidate)) { - return false; - } - if (candidate->meta.caption.normal != win->meta.caption.normal - || candidate->meta.caption.suffix != win->meta.caption.suffix) { - return false; - } - return true; - }}, - candidate)) { - return candidate; - } - } - return {}; -} - template void set_wm_class(Win& win, QByteArray const& res_name, QByteArray const& res_class) { diff --git a/como/win/move.h b/como/win/move.h index a42196b223..f7119a1436 100644 --- a/como/win/move.h +++ b/como/win/move.h @@ -987,6 +987,8 @@ void send_to_screen(Space const& space, Win* win, Output const& output) // (i.e. one near the middle of the right edge will also end up near the middle of the right // edge). auto center = frame_geo.center() - oldScreenArea.center(); + + assert(oldScreenArea.width() > 0); center.setX(center.x() * screenArea.width() / oldScreenArea.width()); center.setY(center.y() * screenArea.height() / oldScreenArea.height()); center += screenArea.center(); diff --git a/como/win/rules/book.cpp b/como/win/rules/book.cpp index a9ddd90fb9..71de51344f 100644 --- a/como/win/rules/book.cpp +++ b/como/win/rules/book.cpp @@ -9,7 +9,6 @@ #include #include -#include "book_settings.h" #include "rules_settings.h" #include @@ -46,34 +45,25 @@ void book::load() { deleteAll(); - if (!config) { - config = KSharedConfig::openConfig(QStringLiteral("kwinrulesrc"), KConfig::NoGlobals); + if (!settings) { + settings = std::make_unique(); } else { - config->reparseConfiguration(); + settings->sharedConfig()->reparseConfiguration(); } - book_settings book(config); - book.load(); - m_rules = book.rules(); + settings->load(); + m_rules = settings->rules(); } void book::save() { m_updateTimer->stop(); - if (!config) { + if (!settings) { qCWarning(KWIN_CORE) << "book::save invoked without prior invocation of book::load"; return; } - - std::vector filteredRules; - for (const auto& rule : std::as_const(m_rules)) { - filteredRules.push_back(rule); - } - - book_settings settings(config); - settings.setRules(filteredRules); - settings.save(); + settings->save(); } void book::requestDiskStorage() diff --git a/como/win/rules/book.h b/como/win/rules/book.h index 5d3b7018ed..20bd460217 100644 --- a/como/win/rules/book.h +++ b/como/win/rules/book.h @@ -6,7 +6,8 @@ */ #pragma once -#include "window.h" +#include +#include #include #include @@ -14,6 +15,7 @@ namespace como::win::rules { +class book_settings; class ruling; class COMO_EXPORT book_qobject : public QObject @@ -38,7 +40,7 @@ class COMO_EXPORT book void requestDiskStorage(); std::unique_ptr qobject; - KSharedConfig::Ptr config; + std::unique_ptr settings; std::deque m_rules; private: diff --git a/como/win/rules/book_edit.h b/como/win/rules/book_edit.h index d4fbae4f34..603e9b3f13 100644 --- a/como/win/rules/book_edit.h +++ b/como/win/rules/book_edit.h @@ -17,25 +17,31 @@ namespace como::win::rules template void discard_used_rules(Book& book, RefWin& ref_win, bool withdrawn) { - auto updated = false; - for (auto it = book.m_rules.begin(); it != book.m_rules.end();) { if (ref_win.control->rules.contains(*it)) { + auto const index = book.settings->indexForId((*it)->id); + if ((*it)->discardUsed(withdrawn)) { - updated = true; + if (index) { + auto settings = book.settings->ruleSettingsAt(index.value()); + (*it)->write(settings); + } } if ((*it)->isEmpty()) { ref_win.control->remove_rule(*it); auto r = *it; it = book.m_rules.erase(it); delete r; + if (index) { + book.settings->removeRuleSettingsAt(index.value()); + } continue; } } ++it; } - if (updated) { + if (book.settings->usrIsSaveNeeded()) { book.requestDiskStorage(); } } diff --git a/como/win/rules/book_settings.cpp b/como/win/rules/book_settings.cpp index 48c54c370d..7baa6de1c3 100644 --- a/como/win/rules/book_settings.cpp +++ b/como/win/rules/book_settings.cpp @@ -18,18 +18,9 @@ book_settings::book_settings(KSharedConfig::Ptr config, QObject* parent) { } -book_settings::book_settings(const QString& configname, KConfig::OpenFlags flags, QObject* parent) - : book_settings(KSharedConfig::openConfig(configname, flags), parent) -{ -} - -book_settings::book_settings(KConfig::OpenFlags flags, QObject* parent) - : book_settings(QStringLiteral("kwinrulesrc"), flags, parent) -{ -} - book_settings::book_settings(QObject* parent) - : book_settings(KConfig::FullConfig, parent) + : book_settings(KSharedConfig::openConfig(QStringLiteral("kwinrulesrc"), KConfig::NoGlobals), + parent) { } @@ -38,43 +29,7 @@ book_settings::~book_settings() qDeleteAll(m_list); } -void book_settings::setRules(std::vector const& rules) -{ - mCount = rules.size(); - mRuleGroupList.clear(); - mRuleGroupList.reserve(rules.size()); - - size_t i{0}; - auto const list_length = m_list.size(); - for (const auto& rule : rules) { - rules::settings* settings; - if (i < list_length) { - // Optimization. Reuse settings already created - settings = m_list.at(i); - settings->setDefaults(); - } else { - // If there are more rules than in cache - settings = new rules::settings(this->sharedConfig(), QString::number(i + 1), this); - m_list.push_back(settings); - } - - rule->write(settings); - mRuleGroupList.append(settings->currentGroup()); - - i++; - } - - if (m_list.empty()) { - return; - } - - for (size_t j = m_list.size() - 1; j >= rules.size(); j--) { - delete m_list[j]; - m_list.erase(m_list.begin() + j); - } -} - -std::deque book_settings::rules() +std::deque book_settings::rules() const { std::deque result; for (auto const& settings : m_list) { @@ -83,6 +38,16 @@ std::deque book_settings::rules() return result; } +std::optional book_settings::indexForId(QString const& id) const +{ + for (size_t i = 0; i < m_list.size(); i++) { + if (m_list.at(i)->currentGroup() == id) { + return i; + } + } + return std::nullopt; +} + bool book_settings::usrSave() { bool result = true; diff --git a/como/win/rules/book_settings.h b/como/win/rules/book_settings.h index 4c0c3fb4b4..501e561de6 100644 --- a/como/win/rules/book_settings.h +++ b/como/win/rules/book_settings.h @@ -25,19 +25,18 @@ class COMO_EXPORT book_settings : public book_settings_base { public: book_settings(KSharedConfig::Ptr config, QObject* parent = nullptr); - book_settings(const QString& configname, KConfig::OpenFlags, QObject* parent = nullptr); - book_settings(KConfig::OpenFlags, QObject* parent = nullptr); book_settings(QObject* parent = nullptr); ~book_settings(); void setRules(std::vector const&); - std::deque rules(); + std::deque rules() const; bool usrSave() override; void usrRead() override; bool usrIsSaveNeeded() const; size_t ruleCount() const; + std::optional indexForId(QString const& id) const; settings* ruleSettingsAt(size_t row) const; settings* insertRuleSettingsAt(size_t row); void removeRuleSettingsAt(size_t row); diff --git a/como/win/rules/ruling.cpp b/como/win/rules/ruling.cpp index e0256ae4e2..bddc7d9453 100644 --- a/como/win/rules/ruling.cpp +++ b/como/win/rules/ruling.cpp @@ -148,6 +148,7 @@ void ruling::write(rules::settings* settings) const } }; + settings->setDefaults(); settings->setDescription(description); // Always write wmclass. diff --git a/como/win/rules/ruling.h b/como/win/rules/ruling.h index ee4aa3582b..97afae386e 100644 --- a/como/win/rules/ruling.h +++ b/como/win/rules/ruling.h @@ -144,6 +144,7 @@ class COMO_EXPORT ruling bytes_match clientmachine; string_match title; + QString id; QString description; bool wmclasscomplete; window_type_mask types; diff --git a/como/win/tabbox/switchers/thumbnail_grid/contents/ui/main.qml b/como/win/tabbox/switchers/thumbnail_grid/contents/ui/main.qml index 33b3061836..b152221840 100644 --- a/como/win/tabbox/switchers/thumbnail_grid/contents/ui/main.qml +++ b/como/win/tabbox/switchers/thumbnail_grid/contents/ui/main.qml @@ -198,6 +198,14 @@ KWin.TabBoxSwitcher { onCurrentIndexChanged: tabBox.currentIndex = thumbnailGridView.currentIndex; } // GridView + Kirigami.PlaceholderMessage { + anchors.centerIn: parent + width: parent.width - Kirigami.Units.largeSpacing * 2 + icon.source: "edit-none" + text: i18ndc("kwin", "@info:placeholder no entries in the task switcher", "No open windows") + visible: thumbnailGridView.count === 0 + } + Keys.onPressed: { if (event.key == Qt.Key_Left) { thumbnailGridView.moveCurrentIndexLeft(); diff --git a/como/win/tabbox/tabbox.h b/como/win/tabbox/tabbox.h index 85221af547..ad7d089cb5 100644 --- a/como/win/tabbox/tabbox.h +++ b/como/win/tabbox/tabbox.h @@ -441,11 +441,11 @@ class tabbox mods &= keyQt; if (((keyQt & ~mods) == Qt::Key_Tab) || ((keyQt & ~mods) == Qt::Key_Backtab)) { if (contains(forward, QKeyCombination(mods, Qt::Key_Backtab).toCombined()) - || contains(forward, QKeyCombination(mods, Qt::Key_Tab))) { + || contains(forward, QKeyCombination(mods, Qt::Key_Tab).toCombined())) { return Forward; } if (contains(backward, QKeyCombination(mods, Qt::Key_Backtab).toCombined()) - || contains(backward, QKeyCombination(mods, Qt::Key_Tab))) { + || contains(backward, QKeyCombination(mods, Qt::Key_Tab).toCombined())) { return Backward; } } diff --git a/como/win/tabbox/tabbox_client_model.cpp b/como/win/tabbox/tabbox_client_model.cpp index d143458054..450565df79 100644 --- a/como/win/tabbox/tabbox_client_model.cpp +++ b/como/win/tabbox/tabbox_client_model.cpp @@ -211,7 +211,8 @@ void tabbox_client_model::create_client_list(int desktop, bool partial_reset) break; } } - if (tabbox_handle->config().client_applications_mode() + if (!m_client_list.empty() + && tabbox_handle->config().client_applications_mode() != tabbox_config::AllWindowsCurrentApplication && tabbox_handle->config().show_desktop_mode() == tabbox_config::ShowDesktopClient) { if (auto desktop_client = tabbox_handle->desktop_client()) { diff --git a/como/win/wayland/internal_window.h b/como/win/wayland/internal_window.h index 670df2ca85..99889f344a 100644 --- a/como/win/wayland/internal_window.h +++ b/como/win/wayland/internal_window.h @@ -668,19 +668,9 @@ class internal_window void updateCaption() { - auto const oldSuffix = this->meta.caption.suffix; - const auto shortcut = win::shortcut_caption_suffix(this); - this->meta.caption.suffix = shortcut; - if ((!win::is_special_window(this) || win::is_toolbar(this)) - && win::find_client_with_same_caption(this)) { - int i = 2; - do { - this->meta.caption.suffix - = shortcut + QLatin1String(" <") + QString::number(i) + QLatin1Char('>'); - i++; - } while (win::find_client_with_same_caption(this)); - } - if (this->meta.caption.suffix != oldSuffix) { + auto const old_suffix = this->meta.caption.suffix; + this->meta.caption.suffix = win::shortcut_caption_suffix(this); + if (this->meta.caption.suffix != old_suffix) { Q_EMIT this->qobject->captionChanged(); } } @@ -728,13 +718,7 @@ class internal_window } this->meta.caption.normal = cap; - - auto const oldCaptionSuffix = this->meta.caption.suffix; - updateCaption(); - - if (this->meta.caption.suffix == oldCaptionSuffix) { - Q_EMIT this->qobject->captionChanged(); - } + Q_EMIT this->qobject->captionChanged(); } void markAsMapped() diff --git a/como/win/wayland/layer_shell.h b/como/win/wayland/layer_shell.h index d32934db25..e208fc4d14 100644 --- a/como/win/wayland/layer_shell.h +++ b/como/win/wayland/layer_shell.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -228,7 +229,7 @@ void handle_new_layer_surface(Space* space, Wrapland::Server::LayerSurfaceV1* la using var_win = typename Space::window_t; auto window = new Window(layer_surface->surface(), *space); - if (layer_surface->surface()->client() == space->base.server->screen_locker_client_connection) { + if (layer_surface->surface()->client() == win::wayland::screen_lock_get_client(*space)) { ScreenLocker::KSldApp::self()->lockScreenShown(); } diff --git a/como/win/wayland/screen_lock.h b/como/win/wayland/screen_lock.h new file mode 100644 index 0000000000..6b4fe08902 --- /dev/null +++ b/como/win/wayland/screen_lock.h @@ -0,0 +1,47 @@ +/* + SPDX-FileCopyrightText: 2024 Roman Gilg + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#pragma once + +#include + +namespace como::win::wayland +{ + +template +bool screen_lock_is_supported(Space const& space) +{ + if constexpr (requires(decltype(space.mod.desktop) desktop) { desktop->screen_locker; }) { + return space.mod.desktop && space.mod.desktop->screen_locker; + } + return false; +} + +template +Wrapland::Server::Client* screen_lock_get_client(Space const& space) +{ + if constexpr (requires(decltype(space.mod.desktop) desktop) { desktop->screen_locker; }) { + if (space.mod.desktop && space.mod.desktop->screen_locker) { + space.mod.desktop->screen_locker->get_client(); + } + } + + return nullptr; +} + +template +bool screen_lock_is_locked(Space const& space) +{ + if (!screen_lock_is_supported(space)) { + return false; + } + + if constexpr (requires(decltype(space.mod.desktop) desktop) { desktop->screen_locker; }) { + return space.mod.desktop->screen_locker->is_locked(); + } + + return false; +} + +} diff --git a/como/win/wayland/window.h b/como/win/wayland/window.h index 31a8ec8f09..63140cab07 100644 --- a/como/win/wayland/window.h +++ b/como/win/wayland/window.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -848,8 +849,10 @@ class window bool isLockScreen() const { - return !this->remnant - && surface->client() == space.base.server->screen_locker_client_connection; + if (remnant) { + return false; + } + return surface->client() == screen_lock_get_client(space); } bool isInitialPositionSet() const @@ -1218,13 +1221,9 @@ class window void handle_title_changed() { - auto const old_suffix = this->meta.caption.suffix; - - this->meta.caption.normal = QString::fromStdString(toplevel->title()).simplified(); - updateCaption(); - - if (this->meta.caption.suffix == old_suffix) { - // Don't emit caption change twice it already got emitted by the changing suffix. + auto const title = QString::fromStdString(toplevel->title()).simplified(); + if (this->meta.caption.normal != title) { + meta.caption.normal = title; Q_EMIT this->qobject->captionChanged(); } } @@ -1396,16 +1395,7 @@ class window void updateCaption() { auto const old_suffix = this->meta.caption.suffix; - auto const shortcut = shortcut_caption_suffix(this); - this->meta.caption.suffix = shortcut; - if ((!is_special_window(this) || is_toolbar(this)) && find_client_with_same_caption(this)) { - int i = 2; - do { - this->meta.caption.suffix - = shortcut + QLatin1String(" <") + QString::number(i) + QLatin1Char('>'); - i++; - } while (find_client_with_same_caption(this)); - } + this->meta.caption.suffix = shortcut_caption_suffix(this); if (this->meta.caption.suffix != old_suffix) { Q_EMIT this->qobject->captionChanged(); } diff --git a/como/win/wayland/xdg_activation.h b/como/win/wayland/xdg_activation.h index 7e1d59ccd0..242d65319f 100644 --- a/como/win/wayland/xdg_activation.h +++ b/como/win/wayland/xdg_activation.h @@ -63,9 +63,9 @@ inline bool generate_token(char out[token_strlen]) template struct xdg_activation { xdg_activation(Space& space) - : interface { - std::make_unique(space.base.server->display.get()) - }, space{space} + : interface{std::make_unique( + space.base.server->display.get())} + , space{space} { QObject::connect( interface.get(), diff --git a/como/win/wayland/xdg_shell.h b/como/win/wayland/xdg_shell.h index c35c32db89..34d2d781d0 100644 --- a/como/win/wayland/xdg_shell.h +++ b/como/win/wayland/xdg_shell.h @@ -7,9 +7,9 @@ #include "popup_placement.h" #include "window_release.h" +#include #include -#include #include #include #include @@ -615,7 +615,7 @@ void install_deco(Win& win, Wrapland::Server::XdgDecoration* deco) template void handle_new_toplevel(Space* space, Wrapland::Server::XdgShellToplevel* toplevel) { - if (toplevel->client() == space->base.server->screen_locker_client_connection) { + if (toplevel->client() == screen_lock_get_client(*space)) { ScreenLocker::KSldApp::self()->lockScreenShown(); } auto& win = win::wayland::create_toplevel_window(space, toplevel); diff --git a/como/win/x11/meta.h b/como/win/x11/meta.h index 000cd7d58a..ac889ef072 100644 --- a/como/win/x11/meta.h +++ b/como/win/x11/meta.h @@ -87,7 +87,6 @@ void set_caption(Win* win, QString const& _s, bool force = false) return; } - auto reset_name = force; auto was_suffix = !win->meta.caption.suffix.isEmpty(); win->meta.caption.suffix.clear(); @@ -103,21 +102,7 @@ void set_caption(Win* win, QString const& _s, bool force = false) auto shortcut_suffix = win::shortcut_caption_suffix(win); win->meta.caption.suffix = machine_suffix + shortcut_suffix; - if ((!win::is_special_window(win) || win::is_toolbar(win)) - && find_client_with_same_caption(win)) { - int i = 2; - - do { - win->meta.caption.suffix = machine_suffix + QLatin1String(" <") + QString::number(i) - + QLatin1Char('>') + LRM; - i++; - } while (find_client_with_same_caption(win)); - - win->net_info->setVisibleName(win::caption(win).toUtf8().constData()); - reset_name = false; - } - - if ((was_suffix && win->meta.caption.suffix.isEmpty()) || reset_name) { + if ((was_suffix && win->meta.caption.suffix.isEmpty()) || force) { // If it was new window, it may have old value still set, if the window is reused win->net_info->setVisibleName(""); win->net_info->setVisibleIconName(""); diff --git a/como/win/x11/space_setup.h b/como/win/x11/space_setup.h index 01facafb6a..7a177be2b6 100644 --- a/como/win/x11/space_setup.h +++ b/como/win/x11/space_setup.h @@ -137,14 +137,14 @@ void init_space(Space& space) space.m_nullFocus->map(); space.root_info = x11::root_info::create(space); + space.root_info->activate(); + auto& subspaces = space.subspace_manager; if constexpr (requires { subspaces->backend; }) { subspace_manager_set_root_info(*subspaces, space.root_info.get()); } - space.root_info->activate(); - // TODO(romangg): Do we need this still? /* // TODO: only in X11 mode diff --git a/como/win/x11/subspace_manager.h b/como/win/x11/subspace_manager.h index db56c46111..9fa23939c9 100644 --- a/como/win/x11/subspace_manager.h +++ b/como/win/x11/subspace_manager.h @@ -57,7 +57,6 @@ struct subspace_manager_backend { columns, rows, x11::net::DesktopLayoutCornerTopLeft); - data->activate(); } } diff --git a/examples/quick-effect/CMakeLists.txt b/examples/quick-effect/CMakeLists.txt index 27b5ea3f14..e4d2d9e67c 100644 --- a/examples/quick-effect/CMakeLists.txt +++ b/examples/quick-effect/CMakeLists.txt @@ -1,13 +1,15 @@ # SPDX-FileCopyrightText: None # SPDX-License-Identifier: CC0-1.0 -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) project(quick-effect) -find_package(ECM 5.240 REQUIRED NO_MODULE) +set(KF6_MIN_VERSION "6.0.0") + +find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -find_package(KF6 5.240 REQUIRED COMPONENTS +find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS Package ) diff --git a/examples/quick-effect/package/metadata.json b/examples/quick-effect/package/metadata.json index db9b0d3472..db4715e592 100644 --- a/examples/quick-effect/package/metadata.json +++ b/examples/quick-effect/package/metadata.json @@ -11,7 +11,7 @@ "Description": "Quick Effect", "EnabledByDefault": true, "Id": "quick-effect", - "License": "GPL", + "License": "MIT", "Name": "Quick Effect" }, "X-KDE-ConfigModule": "kcm_kwin4_genericscripted", diff --git a/plugins/effects/blur/blur.h b/plugins/effects/blur/blur.h index 31ba5843c3..689ccd3b41 100644 --- a/plugins/effects/blur/blur.h +++ b/plugins/effects/blur/blur.h @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/plugins/effects/fadingpopups/package/contents/code/main.js b/plugins/effects/fadingpopups/package/contents/code/main.js index d41c5f6825..b25d7c2ba7 100644 --- a/plugins/effects/fadingpopups/package/contents/code/main.js +++ b/plugins/effects/fadingpopups/package/contents/code/main.js @@ -53,7 +53,7 @@ function isPopupWindow(window) { // this one. In addition to popups, this effect also animates some // special windows(e.g. notifications) because the monolithic version // was doing that. - if (window.dock || window.splash || window.toolbar + if (window.splash || window.toolbar || window.notification || window.onScreenDisplay || window.criticalNotification || window.appletPopup) { diff --git a/plugins/effects/overview/kcm/overvieweffectkcm.ui b/plugins/effects/overview/kcm/overvieweffectkcm.ui index f667256364..1e1bd9a073 100644 --- a/plugins/effects/overview/kcm/overvieweffectkcm.ui +++ b/plugins/effects/overview/kcm/overvieweffectkcm.ui @@ -17,69 +17,48 @@ - - - Layout mode: - - - - - - - - Closest - - - - - Natural - - - - - Ignore minimized windows: - + - + Organize windows in the Grid View: - + - + Search results include filtered windows: - + - + diff --git a/plugins/effects/overview/overviewconfig.kcfg b/plugins/effects/overview/overviewconfig.kcfg index db6bebbdb6..41830e6c6b 100644 --- a/plugins/effects/overview/overviewconfig.kcfg +++ b/plugins/effects/overview/overviewconfig.kcfg @@ -10,9 +10,6 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - 1 - false @@ -26,6 +23,8 @@ ElectricTopLeft + + diff --git a/plugins/effects/overview/overvieweffect.cpp b/plugins/effects/overview/overvieweffect.cpp index 9e6197a273..48b3ecfb72 100644 --- a/plugins/effects/overview/overvieweffect.cpp +++ b/plugins/effects/overview/overvieweffect.cpp @@ -26,6 +26,7 @@ OverviewEffect::OverviewEffect() // manages the transition betwee inactive -> overview , m_gridState(new EffectTogglableState(this)) , m_border(new EffectTogglableTouchBorder(m_overviewState)) + , m_gridBorder(new EffectTogglableTouchBorder(m_gridState)) , m_shutdownTimer(new QTimer(this)) { auto gesture = new EffectTogglableGesture(m_overviewState); @@ -190,14 +191,14 @@ OverviewEffect::OverviewEffect() i18nc("@action Grid view is the name of a Kwin effect", "Toggle Grid View")); KGlobalAccel::self()->setDefaultShortcut(gridAction, {defaultGridShortcut}); KGlobalAccel::self()->setShortcut(gridAction, {defaultGridShortcut}); - m_overviewShortcut = KGlobalAccel::self()->shortcut(gridAction); + m_gridShortcut = KGlobalAccel::self()->shortcut(gridAction); connect(effects, &EffectsHandler::screenAboutToLock, this, &OverviewEffect::realDeactivate); OverviewConfig::instance(effects->config()); reconfigure(ReconfigureAll); - auto delegate = new QQmlComponent(effects->qmlEngine()); + auto delegate = new QQmlComponent(effects->qmlEngine(), this); connect(delegate, &QQmlComponent::statusChanged, this, [delegate]() { if (delegate->isError()) { qWarning() << "Failed to load overview:" << delegate->errorString(); @@ -215,15 +216,18 @@ OverviewEffect::~OverviewEffect() void OverviewEffect::reconfigure(ReconfigureFlags) { OverviewConfig::self()->read(); - setLayout(OverviewConfig::layoutMode()); setAnimationDuration(animationTime(300)); setFilterWindows(OverviewConfig::filterWindows()); for (const ElectricBorder& border : std::as_const(m_borderActivate)) { effects->unreserveElectricBorder(border, this); } + for (const ElectricBorder& border : std::as_const(m_gridBorderActivate)) { + effects->unreserveElectricBorder(border, this); + } m_borderActivate.clear(); + m_gridBorderActivate.clear(); const QList activateBorders = OverviewConfig::borderActivate(); for (const int& border : activateBorders) { @@ -231,7 +235,14 @@ void OverviewEffect::reconfigure(ReconfigureFlags) effects->reserveElectricBorder(ElectricBorder(border), this); } + const QList gridActivateBorders = OverviewConfig::gridBorderActivate(); + for (const int& border : gridActivateBorders) { + m_gridBorderActivate.append(ElectricBorder(border)); + effects->reserveElectricBorder(ElectricBorder(border), this); + } + m_border->setBorders(OverviewConfig::touchBorderActivate()); + m_gridBorder->setBorders(OverviewConfig::gridTouchBorderActivate()); } int OverviewEffect::animationDuration() const @@ -295,11 +306,6 @@ QPointF OverviewEffect::desktopOffset() const return m_desktopOffset; } -int OverviewEffect::layout() const -{ - return m_layout; -} - bool OverviewEffect::ignoreMinimized() const { return OverviewConfig::ignoreMinimized(); @@ -310,14 +316,6 @@ bool OverviewEffect::organizedGrid() const return OverviewConfig::organizedGrid(); } -void OverviewEffect::setLayout(int layout) -{ - if (m_layout != layout) { - m_layout = layout; - Q_EMIT layoutChanged(); - } -} - int OverviewEffect::requestedEffectChainPosition() const { return 70; @@ -328,6 +326,9 @@ bool OverviewEffect::borderActivated(ElectricBorder border) if (m_borderActivate.contains(border)) { m_overviewState->toggle(); return true; + } else if (m_gridBorderActivate.contains(border)) { + m_gridState->toggle(); + return true; } return false; } @@ -392,13 +393,13 @@ void OverviewEffect::grabbedKeyboardEvent(QKeyEvent* keyEvent) } if (m_overviewShortcut.contains(keyEvent->key() | keyEvent->modifiers())) { if (keyEvent->type() == QEvent::KeyPress) { - m_overviewState->toggleAction(); + m_overviewState->toggle(); } return; } if (m_gridShortcut.contains(keyEvent->key() | keyEvent->modifiers())) { if (keyEvent->type() == QEvent::KeyPress) { - m_gridState->toggleAction(); + m_gridState->toggle(); } return; } diff --git a/plugins/effects/overview/overvieweffect.h b/plugins/effects/overview/overvieweffect.h index 135dfd103d..144d13f661 100644 --- a/plugins/effects/overview/overvieweffect.h +++ b/plugins/effects/overview/overvieweffect.h @@ -16,7 +16,6 @@ class OverviewEffect : public QuickSceneEffect { Q_OBJECT Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged) - Q_PROPERTY(int layout READ layout NOTIFY layoutChanged) Q_PROPERTY(bool ignoreMinimized READ ignoreMinimized NOTIFY ignoreMinimizedChanged) Q_PROPERTY(bool filterWindows READ filterWindows NOTIFY filterWindowsChanged) Q_PROPERTY(bool organizedGrid READ organizedGrid NOTIFY organizedGridChanged) @@ -41,9 +40,6 @@ class OverviewEffect : public QuickSceneEffect OverviewEffect(); ~OverviewEffect() override; - int layout() const; - void setLayout(int layout); - bool ignoreMinimized() const; bool organizedGrid() const; @@ -70,7 +66,6 @@ class OverviewEffect : public QuickSceneEffect Q_SIGNALS: void animationDurationChanged(); - void layoutChanged(); void overviewPartialActivationFactorChanged(); void overviewGestureInProgressChanged(); void transitionPartialActivationFactorChanged(); @@ -96,6 +91,7 @@ public Q_SLOTS: EffectTogglableState* const m_transitionState; EffectTogglableState* const m_gridState; EffectTogglableTouchBorder* const m_border; + EffectTogglableTouchBorder* const m_gridBorder; QTimer* m_shutdownTimer; QList m_cycleShortcut; @@ -103,11 +99,11 @@ public Q_SLOTS: QList m_overviewShortcut; QList m_gridShortcut; QList m_borderActivate; + QList m_gridBorderActivate; QString m_searchText; QPointF m_desktopOffset; bool m_filterWindows = true; int m_animationDuration = 400; - int m_layout = 1; }; } diff --git a/plugins/effects/overview/qml/DesktopBar.qml b/plugins/effects/overview/qml/DesktopBar.qml index 0cb730ce71..9c6a1442c4 100644 --- a/plugins/effects/overview/qml/DesktopBar.qml +++ b/plugins/effects/overview/qml/DesktopBar.qml @@ -139,7 +139,7 @@ Item { Rectangle { readonly property bool active: (delegate.activeFocus || dropArea.containsDrag || mouseArea.containsPress || bar.selectedDesktop === delegate.desktop) anchors.fill: parent - radius: width / 20 + radius: Kirigami.Units.cornerRadius color: "transparent" border.width: active ? 2 : 1 border.color: active ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor @@ -149,17 +149,10 @@ Item { MouseArea { id: mouseArea anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.MiddleButton + acceptedButtons: Qt.LeftButton onClicked: mouse => { mouse.accepted = true; - switch (mouse.button) { - case Qt.LeftButton: - delegate.activate(); - break; - case Qt.MiddleButton: - delegate.remove(); - break; - } + delegate.activate(); } } diff --git a/plugins/effects/overview/qml/main.qml b/plugins/effects/overview/qml/main.qml index fcc02606cf..604d4ccf96 100644 --- a/plugins/effects/overview/qml/main.qml +++ b/plugins/effects/overview/qml/main.qml @@ -9,7 +9,7 @@ import QtQuick import Qt5Compat.GraphicalEffects import QtQuick.Layouts -import org.kde.kirigami 2.20 as Kirigami +import org.kde.kirigami as Kirigami import org.kde.kwin as KWinComponents import org.kde.kwin.private.effects import org.kde.milou as Milou @@ -524,16 +524,21 @@ FocusScope { Kirigami.ShadowedTexture { anchors.fill: parent - color: Kirigami.Theme.highlightColor + color: "transparent" source: desktopElement - radius: Kirigami.Units.largeSpacing * 2 * (overviewVal + gridVal * 2) + radius: Kirigami.Units.cornerRadius * (overviewVal + gridVal * 2) shadow { size: Kirigami.Units.gridUnit * 2 color: Qt.rgba(0, 0, 0, 0.3) yOffset: 3 } + + property var borderWidth: desktopHover.hovered ? Kirigami.Units.largeSpacing : (mainBackground.current ? Kirigami.Units.smallSpacing : 0); + property var borderColor: desktopHover.hovered ? Kirigami.Theme.focusColor : (mainBackground.current ? Kirigami.Theme.highlightColor : "transparent") + border.width: gridVal == 1 ? borderWidth : 0 + border.color: gridVal == 1 ? borderColor : "transparent" } DropArea { @@ -574,6 +579,13 @@ FocusScope { item.client.desktops = [mainBackground.desktop]; } } + TapHandler { + acceptedButtons: Qt.LeftButton + onTapped: { + KWinComponents.Workspace.currentDesktop = mainBackground.desktop; + container.effect.deactivate(); + } + } DragHandler { id: dragHandler target: heap @@ -586,6 +598,10 @@ FocusScope { } } } + + HoverHandler { + id: desktopHover + } } WindowHeap { @@ -607,7 +623,6 @@ FocusScope { Drag.hotSpot: Qt.point(width * 0.5, height * 0.5) Drag.keys: ["kwin-desktop"] - layout.mode: effect.layout focus: current padding: Kirigami.Units.largeSpacing animationDuration: effect.animationDuration @@ -683,13 +698,6 @@ FocusScope { onActivated: effect.deactivate() } - TapHandler { - acceptedButtons: Qt.LeftButton - onTapped: { - KWinComponents.Workspace.currentDesktop = mainBackground.desktop; - container.effect.deactivate(); - } - } onCurrentChanged: { if (current) { diff --git a/plugins/effects/private/expolayout.cpp b/plugins/effects/private/expolayout.cpp index 46ed230ed6..1bacfea954 100644 --- a/plugins/effects/private/expolayout.cpp +++ b/plugins/effects/private/expolayout.cpp @@ -1,9 +1,6 @@ /* SPDX-FileCopyrightText: 2021 Vlad Zahorodnii - - // The layouting code is taken from the present windows effect. - SPDX-FileCopyrightText: 2007 Rivo Laks - SPDX-FileCopyrightText: 2008 Lucas Murray + SPDX-FileCopyrightText: 2024 Yifan Zhu SPDX-License-Identifier: GPL-2.0-or-later */ @@ -11,6 +8,8 @@ #include "expolayout.h" #include +#include +#include ExpoCell::ExpoCell(QObject* parent) : QObject(parent) @@ -32,13 +31,21 @@ void ExpoCell::setLayout(ExpoLayout* layout) if (m_layout == layout) { return; } + if (m_layout) { m_layout->removeCell(this); + QObject::disconnect(m_layout, &QObject::destroyed, this, nullptr); } + m_layout = layout; - if (m_layout && m_enabled) { - m_layout->addCell(this); + + if (m_layout) { + QObject::connect(m_layout, &QObject::destroyed, this, [this] { m_layout = nullptr; }); + if (m_enabled) { + m_layout->addCell(this); + } } + Q_EMIT layoutChanged(); } @@ -222,45 +229,17 @@ ExpoLayout::ExpoLayout(QQuickItem* parent) { } -ExpoLayout::LayoutMode ExpoLayout::mode() const -{ - return m_mode; -} - -void ExpoLayout::setMode(LayoutMode mode) -{ - if (m_mode != mode) { - m_mode = mode; - polish(); - Q_EMIT modeChanged(); - } -} - -bool ExpoLayout::fillGaps() const -{ - return m_fillGaps; -} - -void ExpoLayout::setFillGaps(bool fill) -{ - if (m_fillGaps != fill) { - m_fillGaps = fill; - polish(); - Q_EMIT fillGapsChanged(); - } -} - -int ExpoLayout::spacing() const +ExpoLayout::PlacementMode ExpoLayout::placementMode() const { - return m_spacing; + return m_placementMode; } -void ExpoLayout::setSpacing(int spacing) +void ExpoLayout::setPlacementMode(PlacementMode mode) { - if (m_spacing != spacing) { - m_spacing = spacing; + if (m_placementMode != mode) { + m_placementMode = mode; polish(); - Q_EMIT spacingChanged(); + Q_EMIT placementModeChanged(); } } @@ -282,25 +261,6 @@ void ExpoLayout::forceLayout() updatePolish(); } -void ExpoLayout::updatePolish() -{ - if (!m_cells.isEmpty()) { - switch (m_mode) { - case LayoutClosest: - calculateWindowTransformationsClosest(); - break; - case LayoutNatural: - calculateWindowTransformationsNatural(); - break; - case LayoutNone: - resetTransformations(); - break; - } - } - - setReady(); -} - void ExpoLayout::addCell(ExpoCell* cell) { Q_ASSERT(!m_cells.contains(cell)); @@ -322,416 +282,553 @@ void ExpoLayout::geometryChange(const QRectF& newGeometry, const QRectF& oldGeom QQuickItem::geometryChange(newGeometry, oldGeometry); } -static int distance(const QPoint& a, const QPoint& b) +// Move and scale rect to fit inside area +static void moveToFit(QRectF& rect, const QRectF& area) { - const int xdiff = a.x() - b.x(); - const int ydiff = a.y() - b.y(); - return int(std::sqrt(qreal(xdiff * xdiff + ydiff * ydiff))); + qreal scale = std::min(area.width() / rect.width(), area.height() / rect.height()); + rect.setWidth(rect.width() * scale); + rect.setHeight(rect.height() * scale); + rect.moveCenter(area.center()); } -static QRect centered(ExpoCell* cell, const QRect& bounds) +void ExpoLayout::updatePolish() { - const QSize scaled = QSize(cell->naturalWidth(), cell->naturalHeight()) - .scaled(bounds.size(), Qt::KeepAspectRatio); + if (m_cells.isEmpty()) { + setReady(); + return; + } - return QRect(bounds.center().x() - scaled.width() / 2, - bounds.center().y() - scaled.height() / 2, - scaled.width(), - scaled.height()); -} + QRectF area = QRectF(0, 0, width(), height()); -void ExpoLayout::calculateWindowTransformationsClosest() -{ - QRect area = QRect(0, 0, width(), height()); - const int columns = int(std::ceil(std::sqrt(qreal(m_cells.count())))); - const int rows = int(std::ceil(m_cells.count() / qreal(columns))); + std::sort(m_cells.begin(), m_cells.end(), [](const ExpoCell* a, const ExpoCell* b) { + return a->persistentKey() < b->persistentKey(); + }); - // Assign slots - const int slotWidth = area.width() / columns; - const int slotHeight = area.height() / rows; - QVector takenSlots; - takenSlots.resize(rows * columns); - takenSlots.fill(nullptr); + // Estimate the scale factor we need to apply by simple heuristics + qreal totalArea = 0; + qreal availableArea = area.width() * area.height(); + for (ExpoCell* cell : std::as_const(m_cells)) { + totalArea += cell->naturalWidth() * cell->naturalHeight(); + } + qreal scale = std::sqrt(availableArea / totalArea) * 0.7; // conservative estimate + scale = std::clamp(scale, 0.1, 10.0); // don't go crazy - // precalculate all slot centers - QVector slotCenters; - slotCenters.resize(rows * columns); - for (int x = 0; x < columns; ++x) { - for (int y = 0; y < rows; ++y) { - slotCenters[x + y * columns] = QPoint(area.x() + slotWidth * x + slotWidth / 2, - area.y() + slotHeight * y + slotHeight / 2); + QList windowSizes; + for (ExpoCell* cell : std::as_const(m_cells)) { + const QMargins& margins = cell->margins(); + const QMarginsF scaledMargins(margins.left() / scale, + margins.top() / scale, + margins.right() / scale, + margins.bottom() / scale); + windowSizes.emplace_back(cell->naturalRect().toRectF().marginsAdded(scaledMargins)); + } + auto windowLayouts = ExpoLayout::layout(area, windowSizes); + for (int i = 0; i < windowLayouts.size(); ++i) { + ExpoCell* cell = m_cells[i]; + QRectF target = windowLayouts[i]; + + QRectF adjustedTarget = target.marginsRemoved(cell->margins()); + if (adjustedTarget.isValid()) { + target = adjustedTarget; // Borders } + + QRectF rect = cell->naturalRect(); + moveToFit(rect, target); + cell->setX(rect.x()); + cell->setY(rect.y()); + cell->setWidth(rect.width()); + cell->setHeight(rect.height()); } + setReady(); +} - // Assign each window to the closest available slot - QList tmpList = m_cells; // use a QLinkedList copy instead? - while (!tmpList.isEmpty()) { - ExpoCell* cell = tmpList.first(); - int slotCandidate = -1, slotCandidateDistance = INT_MAX; - const QPoint pos = cell->naturalRect().center(); - - for (int i = 0; i < columns * rows; ++i) { // all slots - const int dist = distance(pos, slotCenters[i]); - if (dist < slotCandidateDistance) { // window is interested in this slot - ExpoCell* occupier = takenSlots[i]; - Q_ASSERT(occupier != cell); - if (!occupier - || dist < distance(occupier->naturalRect().center(), slotCenters[i])) { - // either nobody lives here, or we're better - takeover the slot if it's our - // best - slotCandidate = i; - slotCandidateDistance = dist; - } - } - } - Q_ASSERT(slotCandidate != -1); - if (takenSlots[slotCandidate]) { - tmpList << takenSlots[slotCandidate]; // occupier needs a new home now :p +Layer::Layer(qreal maxWidth, + const QList& windowSizes, + const QList& windowIds, + size_t startPos, + size_t endPos) + : maxWidth(maxWidth) + , maxHeight(windowSizes[windowIds[endPos - 1]].height()) + , ids(windowIds.begin() + startPos, windowIds.begin() + endPos) +{ + remainingWidth = maxWidth; + for (auto id = ids.begin(); id != ids.end(); ++id) { + remainingWidth -= windowSizes[*id].width(); + } +} + +qreal Layer::width() const +{ + return maxWidth - remainingWidth; +} + +LayeredPacking::LayeredPacking(qreal maxWidth, + const QList& windowSizes, + const QList& ids, + const QList& layerStartPos) + : maxWidth(maxWidth) + , width(0) + , height(0) +{ + for (int i = 1; i < layerStartPos.size(); ++i) { + layers.emplace_back(maxWidth, windowSizes, ids, layerStartPos[i - 1], layerStartPos[i]); + width = std::max(width, layers.back().width()); + height += layers.back().maxHeight; + } +} + +/** + * @brief Check if @param candidate can be ignored in the future because either @param + * alternativeSmall or @param alternativeBig is at least as good as @param candidate for layerStart. + * + * More formally, returns false if and only if there exists a k with @param alternativeBig < k <= + * @param length such that leastWeightCandidate( @param candidate, k ) < leastWeightCandidate( + * @param alternativeSmall, k ) and leastWeightCandidate( @param candidate, k ) < + * leastWeightCandidate( + * @param alternativeBig, k ). + * + * The input must satisfy @param alternativeSmall < @param candidate < @param alternativeBig + * + * The run time of the algorithm is O(log length). + * + * The Bridge algorithm from Hirschberg, Daniel S., and Lawrence L. + * Larmore. "The least weight subsequence problem." SIAM Journal on + * Computing 16.4 (1987): 628-638 + * + * @param length The length of the sequence. + * @param leastWeightCandidate leastWeightCandidate(i, j) is the weight of arranging the first j + * windows, if we use the optimal arrangement of the first i windows, and the last layest consists + * of windows [i, j) + */ +static bool isDominated(size_t candidate, + size_t alternativeSmall, + size_t alternativeBig, + size_t length, + std::function leastWeightCandidate) +{ + Q_ASSERT(alternativeSmall < candidate && candidate < alternativeBig); + if (alternativeBig == length) { + return true; + } + + // We assumed that the weigth function is concave, i.e., for all i <= j < k <= l, + // weight(i,k) + weight(j,l) <= weight(i,l) + weight(j,k) + // This implies the following about leastWeightCandidate: + // For all i <= j < k <= l + // - If leastWeightCandidate(i, l) <= leastWeightCandidate(j, l), then leastWeightCandidate(i, + // k) <= leastWeightCandidate(j, k) + // - If leastWeightCandidate(j, k) <= leastWeightCandidate(i, k), then leastWeightCandidate(j, + // l) <= leastWeightCandidate(i, l) + // + // In particular, this implies that the set of ks such that + // leastWeightCandidate(candidate, k) < leastWeightCandidate(alternativeSmall, k) + // is a (possibly empty) interval [k1, length] for some k1. + // This is because if for some k, + // leastWeightCandidate(alternativeSmall, k) <= leastWeightCandidate(candidate, k), + // then for all candidate < k' <= k, + // leastWeightCandidate(alternativeSmall, k') <= leastWeightCandidate(candidate, k') + // + // Similarly, the set of ks such that + // leastWeightCandidate(candidate, k) < leastWeightCandidate(alternativeBig, k) + // is a (possibly empty) interval [alternativeBig + 1, k2] for some k2. + // This is because if for some k, + // leastWeightCandidate(alternativeBig, k) <= leastWeightCandidate(candidate, k), + // then for all k' >= k + // leastWeightCandidate(alternativeBig, k') <= leastWeightCandidate(candidate, k') + // + // Hence, to check if a k exists in both intervals, we can use binary search to find the + // smallest k1 such that + // leastWeightCandidate(candidate, k1) < leastWeightCandidate(alternativeSmall, k1). + // If such a k1 exists, it suffices to check if + // leastWeightCandidate(alternativeBig, k1) <= leastWeightCandidate(candidate, k1). + if (leastWeightCandidate(alternativeSmall, length) <= leastWeightCandidate(candidate, length)) { + return true; + } + // Now we know that leastWeightCandidate(candidate, length) < + // leastWeightCandidate(alternativeSmall, length) i.e, the first interval is non-empty Our + // candidate k1 is in the interval (low, high] (inclusive on high) + size_t low = alternativeBig; + size_t high = length; + while (high - low >= 2) { + size_t mid = (low + high) / 2; + if (leastWeightCandidate(alternativeSmall, mid) <= leastWeightCandidate(candidate, mid)) { + low = mid; + } else { + high = mid; } - tmpList.removeAll(cell); - takenSlots[slotCandidate] = cell; // ...and we rumble in =) } + return (leastWeightCandidate(alternativeBig, high) <= leastWeightCandidate(candidate, high)); +} + +/** + * @brief Returns the layerStartPos for a good packing of the windows using the Basic algorithm + * from Hirschberg, Daniel S., and Lawrence L. Larmore. "The least weight subsequence problem." + * SIAM Journal on Computing 16.4 (1987): 628-638. + * + * The Basic algorithm solves the Least Weight Subsequence Problem (LWS) for + * concave weight functions. + * + * The LWS problem on the interval [a,b] is defined as follows: + * Given a weight function weight(i,j) for all i,j in [a,b], find a subsequence + * of [a,b], i.e. a sequence of strictly monotonically increasing indices + * i_0 < i_2 < ... < i_t, such that the total weight, + * sum_{k=1}^t weight(i_{k-1}, i_k), is minimized. + * + * A weight function is concave if for all i <= j < k <= l, the following holds: + * weight(i,k) + weight(j,l) <= weight(i,l) + weight(j,k) + * + * The run time of the algorithm is O(n log n). + * + * Modified from the version in the paper to fix some bugs. + * + * @param idealWidth The target width of each layer. All widths of windows *MUST* be smaller than + * idealWidth. + * @param length The length of the sequence. Solves the LWS problem on the interval [0, length]. (n + * in paper) + * @param cumWidths cumWidths[i] is the sum of widths of windows 0, 1, ..., i - 1 + * + * @return QList The subsequence (starting at 0 and ending at length) + * that minimizes the total weight. The ith element is the index of the first window in layer i. + * Always starts with 0 and ends with ids.size(). + */ +static QList getLayerStartPos(qreal maxWidth, + qreal idealWidth, + const size_t length, + const QList& cumWidths) +{ + // weight(start, end) is the penalty of placing all windows in the range [start, end) in the + // same layer. The following form only works when the maximum width of a window is less than or + // equal to idealWidth. + // + // The weight function is designed such that + // 1. The weight function is concave (see definition in Basic algorithm) + // 2. It scales like (width - idealWidth) ^ 2 for width < idealWidth + // 3. Exceeding maxWidth is guaranteed to be worse than any other solution + // + // 1. holds as long as weight(i, j) = f(cumWidths[j] - cumWidths[i]) for some convex function f + // 3. is guaranteed by making the penalty of exceeding maxWidth at least + // cumWidths.size(), which strictly upper bounds the total weight of placing + // each window in its own layer + // + auto weight = [maxWidth, idealWidth, &cumWidths](size_t start, size_t end) { + qreal width = cumWidths[end] - cumWidths[start]; + if (width < idealWidth) { + return (width - idealWidth) * (width - idealWidth) / idealWidth / idealWidth; + } else { + qreal penaltyFactor = cumWidths.size(); + return penaltyFactor * (width - idealWidth) * (width - idealWidth) + / (maxWidth - idealWidth) / (maxWidth - idealWidth); + } + }; + + // layerStart[j] is where the last layer should start, if there were only the first j windows. + // I.e., layerStart[5]=3 means that the last layer should start at window 3 if there were only + // the first 10 windows (bestLeft in paper) + QList layerStart(length + 1); + // leastWeight[i] is the least weight of any subsequence starting at 0 and ending at i (f in + // paper) + QList leastWeight(length + 1); + // layerStartcandidates contains all current candidates for layerStart[currentIndex] (d in + // paper) + std::deque layerStartCandidates; + + leastWeight[0] = 0; + + // leastWeightCandidate(lastRowStartPos, num) is a candidate value for leastWeight[num]. + // It is the weight for arranging the first num windows, assuming optimal arrangement of + // the first lastRowStartPos windows, and a last layer consisting of windows [lastRowStartPos, + // num) (g in paper) + auto leastWeightCandidate = [&leastWeight, &weight](size_t lastRowStartPos, size_t num) { + return leastWeight[lastRowStartPos] + weight(lastRowStartPos, num); + }; + layerStartCandidates.push_back(0); + for (size_t currentIndex = 1; currentIndex < length; + ++currentIndex) { // currentIndex is m in paper + leastWeight[currentIndex] + = leastWeightCandidate(layerStartCandidates.front(), currentIndex); + layerStart[currentIndex] = layerStartCandidates.front(); + + // Modification of algorithm in paper; + // needed so that layerStartCandidates.front can be correctly removed when + // layerStartCandidates.size() == 1 + layerStartCandidates.push_back(currentIndex); + + // Remove candidates from the front if they are dominated by the second candidate + // Dominate means that the second candidate is at least as good as the first candidate for + // layerStart + while (layerStartCandidates.size() >= 2 + && leastWeightCandidate(layerStartCandidates[1], currentIndex + 1) + <= leastWeightCandidate(layerStartCandidates[0], currentIndex + 1)) { + layerStartCandidates.pop_front(); + } + layerStartCandidates.pop_back(); // Modification of algorithm in paper + + // Remove candidates from the back if they are dominated by either the second to last + // candidate, or currentIndex + while (layerStartCandidates.size() >= 2 + && isDominated(layerStartCandidates.back(), + layerStartCandidates[layerStartCandidates.size() - 2], + currentIndex, + length, + leastWeightCandidate)) { + layerStartCandidates.pop_back(); + } - for (int slot = 0; slot < columns * rows; ++slot) { - ExpoCell* cell = takenSlots[slot]; - if (!cell) { // some slots might be empty + // Modification of algorithm in paper; we need at least one candidate in + // layerStartCandidates + if (layerStartCandidates.empty()) { + layerStartCandidates.push_back(currentIndex); continue; } - // Work out where the slot is - QRect target(area.x() + (slot % columns) * slotWidth, - area.y() + (slot / columns) * slotHeight, - slotWidth, - slotHeight); - QRect adjustedTarget = target.adjusted(m_spacing, m_spacing, -m_spacing, -m_spacing); - if (adjustedTarget.isValid()) { - target = adjustedTarget; // Borders - } - target = target.marginsRemoved(cell->margins()); - - qreal scale; - if (target.width() / qreal(cell->naturalWidth()) - < target.height() / qreal(cell->naturalHeight())) { - // Center vertically - scale = target.width() / qreal(cell->naturalWidth()); - target.moveTop(target.top() - + (target.height() - int(cell->naturalHeight() * scale)) / 2); - target.setHeight(int(cell->naturalHeight() * scale)); - } else { - // Center horizontally - scale = target.height() / qreal(cell->naturalHeight()); - target.moveLeft(target.left() - + (target.width() - int(cell->naturalWidth() * scale)) / 2); - target.setWidth(int(cell->naturalWidth() * scale)); - } - // Don't scale the windows too much - if (scale > 2.0 - || (scale > 1.0 && (cell->naturalWidth() > 300 || cell->naturalHeight() > 300))) { - scale = (cell->naturalWidth() > 300 || cell->naturalHeight() > 300) ? 1.0 : 2.0; - target = QRect(target.center().x() - int(cell->naturalWidth() * scale) / 2, - target.center().y() - int(cell->naturalHeight() * scale) / 2, - scale * cell->naturalWidth(), - scale * cell->naturalHeight()); + // Add currentIndex to layerStartCandidates if it is not dominated by the last candidate + if (leastWeightCandidate(currentIndex, length) + < leastWeightCandidate(layerStartCandidates.back(), length)) { + layerStartCandidates.push_back(currentIndex); } + } + + // recover the solution using layerStart + leastWeight[length] = leastWeightCandidate(layerStartCandidates.front(), length); + layerStart[length] = layerStartCandidates.front(); - cell->setX(target.x()); - cell->setY(target.y()); - cell->setWidth(target.width()); - cell->setHeight(target.height()); + QList layerStartPosReversed; + layerStartPosReversed.push_back(length); + size_t currentIndex = length; + + while (currentIndex > 0) { + currentIndex = layerStart[currentIndex]; + layerStartPosReversed.push_back(currentIndex); } + + return QList(layerStartPosReversed.rbegin(), layerStartPosReversed.rend()); } -static inline int heightForWidth(ExpoCell* cell, int width) +// Reflection about the line y = x +static QMarginsF reflect(const QMarginsF& margins) { - return int((width / qreal(cell->naturalWidth())) * cell->naturalHeight()); + return QMarginsF(margins.top(), margins.right(), margins.bottom(), margins.left()); +} +static QRectF reflect(const QRectF& rect) +{ + return QRectF(rect.y(), rect.x(), rect.height(), rect.width()); +} +static QPointF reflect(const QPointF& point) +{ + return point.transposed(); +} +template +static QList reflect(const QList& v) +{ + QList result; + result.reserve(v.size()); + for (const auto& x : v) { + result.emplace_back(reflect(x)); + } + return result; } -static bool isOverlappingAny(ExpoCell* w, - const QHash& targets, - const QRegion& border, - int spacing) +QList ExpoLayout::layout(const QRectF& area, const QList& windowSizes) { - QHash::const_iterator winTarget = targets.find(w); - if (winTarget == targets.constEnd()) { - return false; + const qreal shortSide = std::min(area.width(), area.height()); + const QMarginsF margins(shortSide * m_relativeMarginLeft, + shortSide * m_relativeMarginTop, + shortSide * m_relativeMarginRight, + shortSide * m_relativeMarginBottom); + const qreal minLength = m_relativeMinLength * shortSide; + const QRectF minSize = QRectF(0, 0, minLength, minLength); + + QList centers; + for (const QRectF& windowSize : windowSizes) { + centers.push_back(windowSize.center()); } - if (border.intersects(*winTarget)) { - return true; + + // windows bigger than 4x the area are considered ill-behaved and their sizes are clipped + const auto adjustedSizes = adjustSizes( + minSize, QRectF(0, 0, 4 * area.width(), 4 * area.height()), margins, windowSizes); + + if (placementMode() == PlacementMode::Rows) { + LayeredPacking bestPacking + = findGoodPacking(area, adjustedSizes, centers, m_idealWidthRatio, m_searchTolerance); + return refineAndApplyPacking(area, margins, bestPacking, adjustedSizes, centers); + } else { + QList adjustedSizesReflected(reflect(adjustedSizes)); + QList centersReflected(reflect(centers)); + + LayeredPacking bestPacking = findGoodPacking(area.transposed(), + adjustedSizesReflected, + centersReflected, + m_idealWidthRatio, + m_searchTolerance); + return reflect(refineAndApplyPacking(area.transposed(), + reflect(margins), + bestPacking, + adjustedSizesReflected, + centersReflected)); } - const QMargins halfSpacing(spacing / 2, spacing / 2, spacing / 2, spacing / 2); +} - // Is there a better way to do this? - QHash::const_iterator target; - for (target = targets.constBegin(); target != targets.constEnd(); ++target) { - if (target == winTarget) { - continue; - } - if (winTarget->marginsAdded(halfSpacing).intersects(target->marginsAdded(halfSpacing))) { - return true; - } +QList ExpoLayout::adjustSizes(const QRectF& minSize, + const QRectF& maxSize, + const QMarginsF& margins, + const QList& windowSizes) +{ + QList adjustedSizes; + for (QRectF windowSize : windowSizes) { + windowSize.setWidth(std::clamp(windowSize.width(), minSize.width(), maxSize.width())); + windowSize.setHeight(std::clamp(windowSize.height(), minSize.height(), maxSize.height())); + windowSize += margins; + adjustedSizes.emplace_back(windowSize); } - return false; + return adjustedSizes; } -void ExpoLayout::calculateWindowTransformationsNatural() +LayeredPacking ExpoLayout::findGoodPacking(const QRectF& area, + const QList& windowSizes, + const QList& centers, + qreal idealWidthRatio, + qreal tol) { - const QRect area = QRect(0, 0, width(), height()); + QList> windowSizesWithIds; - // As we are using pseudo-random movement (See "slot") we need to make sure the list - // is always sorted the same way no matter which window is currently active. - std::sort(m_cells.begin(), m_cells.end(), [](const ExpoCell* a, const ExpoCell* b) { - return a->persistentKey() < b->persistentKey(); - }); + for (int i = 0; i < windowSizes.size(); ++i) { + windowSizesWithIds.emplace_back(i, windowSizes[i], centers[i]); + } - QRect bounds; - int direction = 0; - QHash targets; - QHash directions; + // Sorting by height ensures that windows in same layer (row) have similar heights + std::stable_sort( + windowSizesWithIds.begin(), windowSizesWithIds.end(), [](const auto& a, const auto& b) { + // in case of same height, sort by y to minimize vertical movement + return std::tuple(std::get<1>(a).height(), std::get<2>(a).y()) + < std::tuple(std::get<1>(b).height(), std::get<2>(b).y()); + }); - for (ExpoCell* cell : std::as_const(m_cells)) { - const QRect cellRect( - cell->naturalX(), cell->naturalY(), cell->naturalWidth(), cell->naturalHeight()); - targets[cell] = cellRect; - // Reuse the unused "slot" as a preferred direction attribute. This is used when the window - // is on the edge of the screen to try to use as much screen real estate as possible. - directions[cell] = direction; - bounds = bounds.united(cellRect); - direction++; - if (direction == 4) { - direction = 0; - } + QList ids; // ids of windows in sorted order + QList cumWidths; // cumWidths[i] is the sum of widths of windows 0, 1, ..., i - 1 + + // Minimum and maximum strip widths to use in the binary search. + // Strips should be at least as wide as the widest window, and at most as + // wide as the sum of all window widths. + qreal stripWidthMin = 0; + qreal stripWidthMax = 0; + + cumWidths.push_back(0); + for (const auto& windowSizeWithId : windowSizesWithIds) { + ids.push_back(std::get<0>(windowSizeWithId)); + qreal width = std::get<1>(windowSizeWithId).width(); + cumWidths.push_back(cumWidths.back() + width); + + stripWidthMin = std::max(stripWidthMin, width); + stripWidthMax += width; } + stripWidthMin /= idealWidthRatio; + stripWidthMax /= idealWidthRatio; - // Iterate over all windows, if two overlap push them apart _slightly_ as we try to - // brute-force the most optimal positions over many iterations. - const int halfSpacing = m_spacing / 2; - bool overlap; - do { - overlap = false; - for (ExpoCell* cell : std::as_const(m_cells)) { - QRect* target_w = &targets[cell]; - for (ExpoCell* e : std::as_const(m_cells)) { - if (cell == e) { - continue; - } - - QRect* target_e = &targets[e]; - if (target_w->adjusted(-halfSpacing, -halfSpacing, halfSpacing, halfSpacing) - .intersects(target_e->adjusted( - -halfSpacing, -halfSpacing, halfSpacing, halfSpacing))) { - overlap = true; - - // Determine pushing direction - QPoint diff(target_e->center() - target_w->center()); - // Prevent dividing by zero and non-movement - if (diff.x() == 0 && diff.y() == 0) { - diff.setX(1); - } - // Try to keep screen aspect ratio - // if (bounds.height() / bounds.width() > area.height() / area.width()) - // diff.setY(diff.y() / 2); - // else - // diff.setX(diff.x() / 2); - // Approximate a vector of between 10px and 20px in magnitude in the same - // direction - diff *= m_accuracy / qreal(diff.manhattanLength()); - // Move both windows apart - target_w->translate(-diff); - target_e->translate(diff); - - // Try to keep the bounding rect the same aspect as the screen so that more - // screen real estate is utilised. We do this by splitting the screen into nine - // equal sections, if the window center is in any of the corner sections pull - // the window towards the outer corner. If it is in any of the other edge - // sections alternate between each corner on that edge. We don't want to - // determine it randomly as it will not produce consistant locations when using - // the filter. Only move one window so we don't cause large amounts of - // unnecessary zooming in some situations. We need to do this even when - // expanding later just in case all windows are the same size. (We are using an - // old bounding rect for this, hopefully it doesn't matter) - int xSection = (target_w->x() - bounds.x()) / (bounds.width() / 3); - int ySection = (target_w->y() - bounds.y()) / (bounds.height() / 3); - diff = QPoint(0, 0); - if (xSection != 1 - || ySection != 1) { // Remove this if you want the center to pull as well - if (xSection == 1) { - xSection = (directions[cell] / 2 ? 2 : 0); - } - if (ySection == 1) { - ySection = (directions[cell] % 2 ? 2 : 0); - } - } - if (xSection == 0 && ySection == 0) { - diff = QPoint(bounds.topLeft() - target_w->center()); - } - if (xSection == 2 && ySection == 0) { - diff = QPoint(bounds.topRight() - target_w->center()); - } - if (xSection == 2 && ySection == 2) { - diff = QPoint(bounds.bottomRight() - target_w->center()); - } - if (xSection == 0 && ySection == 2) { - diff = QPoint(bounds.bottomLeft() - target_w->center()); - } - if (diff.x() != 0 || diff.y() != 0) { - diff *= m_accuracy / qreal(diff.manhattanLength()); - target_w->translate(diff); - } - - // Update bounding rect - bounds = bounds.united(*target_w); - bounds = bounds.united(*target_e); - } - } - } - } while (overlap); - - // Compute the scale factor so the bounding rect fits the target area. - qreal scale; - if (bounds.width() <= area.width() && bounds.height() <= area.height()) { - scale = 1.0; - } else if (area.width() / qreal(bounds.width()) < area.height() / qreal(bounds.height())) { - scale = area.width() / qreal(bounds.width()); - } else { - scale = area.height() / qreal(bounds.height()); - } - // Make bounding rect fill the screen size for later steps - bounds = QRect(bounds.x() - (area.width() / scale - bounds.width()) / 2, - bounds.y() - (area.height() / scale - bounds.height()) / 2, - area.width() / scale, - area.height() / scale); - - // Move all windows back onto the screen and set their scale - QHash::iterator target = targets.begin(); - while (target != targets.end()) { - target->setRect((target->x() - bounds.x()) * scale + area.x(), - (target->y() - bounds.y()) * scale + area.y(), - target->width() * scale, - target->height() * scale); - ++target; - } - - // Try to fill the gaps by enlarging windows if they have the space - if (m_fillGaps) { - // Don't expand onto or over the border - QRegion borderRegion(area.adjusted(-200, -200, 200, 200)); - borderRegion ^= area; - - bool moved; - do { - moved = false; - for (ExpoCell* cell : std::as_const(m_cells)) { - QRect oldRect; - QRect* target = &targets[cell]; - // This may cause some slight distortion if the windows are enlarged a large amount - int widthDiff = m_accuracy; - int heightDiff - = heightForWidth(cell, target->width() + widthDiff) - target->height(); - int xDiff - = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the - int yDiff - = heightDiff / 2; // center windows to be enlarged if there is gaps on the side. - - // heightDiff (and yDiff) will be re-computed after each successful enlargement - // attempt so that the error introduced in the window's aspect ratio is minimized - - // Attempt enlarging to the top-right - oldRect = *target; - target->setRect(target->x() + xDiff, - target->y() - yDiff - heightDiff, - target->width() + widthDiff, - target->height() + heightDiff); - if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) { - *target = oldRect; - } else { - moved = true; - heightDiff - = heightForWidth(cell, target->width() + widthDiff) - target->height(); - yDiff = heightDiff / 2; - } - - // Attempt enlarging to the bottom-right - oldRect = *target; - target->setRect(target->x() + xDiff, - target->y() + yDiff, - target->width() + widthDiff, - target->height() + heightDiff); - if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) { - *target = oldRect; - } else { - moved = true; - heightDiff - = heightForWidth(cell, target->width() + widthDiff) - target->height(); - yDiff = heightDiff / 2; - } - - // Attempt enlarging to the bottom-left - oldRect = *target; - target->setRect(target->x() - xDiff - widthDiff, - target->y() + yDiff, - target->width() + widthDiff, - target->height() + heightDiff); - if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) { - *target = oldRect; - } else { - moved = true; - heightDiff - = heightForWidth(cell, target->width() + widthDiff) - target->height(); - yDiff = heightDiff / 2; - } - - // Attempt enlarging to the top-left - oldRect = *target; - target->setRect(target->x() - xDiff - widthDiff, - target->y() - yDiff - heightDiff, - target->width() + widthDiff, - target->height() + heightDiff); - if (isOverlappingAny(cell, targets, borderRegion, m_spacing)) { - *target = oldRect; - } else { - moved = true; - } - } - } while (moved); - - // The expanding code above can actually enlarge windows over 1.0/2.0 scale, we don't like - // this We can't add this to the loop above as it would cause a never-ending loop so we have - // to make do with the less-than-optimal space usage with using this method. - for (ExpoCell* cell : std::as_const(m_cells)) { - QRect* target = &targets[cell]; - qreal scale = target->width() / qreal(cell->naturalWidth()); - if (scale > 2.0 - || (scale > 1.0 && (cell->naturalWidth() > 300 || cell->naturalHeight() > 300))) { - scale = (cell->naturalWidth() > 300 || cell->naturalHeight() > 300) ? 1.0 : 2.0; - target->setRect(target->center().x() - int(cell->naturalWidth() * scale) / 2, - target->center().y() - int(cell->naturalHeight() * scale) / 2, - cell->naturalWidth() * scale, - cell->naturalHeight() * scale); - } - } + qreal targetRatio = area.height() / area.width(); + + auto findPacking = [&windowSizes, &ids, &cumWidths, idealWidthRatio](qreal stripWidth) { + QList layerStartPos + = getLayerStartPos(stripWidth, stripWidth * idealWidthRatio, ids.size(), cumWidths); + LayeredPacking result(stripWidth, windowSizes, ids, layerStartPos); + Q_ASSERT(result.width <= stripWidth); + return result; + }; + + // the placement with the minimum strip width corresponds with a big aspect + // ratio (ratioHigh), and the placement with the maximum strip width + // corresponds with a small aspect ratio (ratioLow) + + LayeredPacking placementWidthMin = findPacking(stripWidthMin); + qreal ratioHigh = placementWidthMin.height / placementWidthMin.width; + + if (ratioHigh <= targetRatio) { + return placementWidthMin; } - for (ExpoCell* cell : std::as_const(m_cells)) { - const QRect& cellRect = targets.value(cell); - QRect cellRectWithoutMargins = cellRect.marginsRemoved(cell->margins()); - if (!cellRectWithoutMargins.isValid()) { - cellRectWithoutMargins = cellRect; - } - const QRect rect = centered(cell, cellRectWithoutMargins); + LayeredPacking placementWidthMax = findPacking(stripWidthMax); + qreal ratioLow = placementWidthMax.height / placementWidthMax.width; - cell->setX(rect.x()); - cell->setY(rect.y()); - cell->setWidth(rect.width()); - cell->setHeight(rect.height()); + if (ratioLow >= targetRatio) { + return placementWidthMax; } -} -void ExpoLayout::resetTransformations() -{ - for (ExpoCell* cell : std::as_const(m_cells)) { - cell->setX(cell->naturalX()); - cell->setY(cell->naturalY()); - cell->setWidth(cell->naturalWidth()); - cell->setHeight(cell->naturalHeight()); + while (stripWidthMax / stripWidthMin > 1 + tol) { + qreal stripWidthMid = std::sqrt(stripWidthMin * stripWidthMax); + LayeredPacking placementMid = findPacking(stripWidthMid); + qreal ratioMid = placementMid.height / placementMid.width; + + if (ratioMid > targetRatio) { + stripWidthMin = stripWidthMid; + placementWidthMin = placementMid; + ratioHigh = ratioMid; + } else { + // small optimization: use the actual strip width + stripWidthMax = placementMid.width; + placementWidthMax = placementMid; + ratioLow = ratioMid; + } } + + // how much we need to scale the placement to fit + qreal scaleWidthMin = std::min(area.width() / placementWidthMin.width, + area.height() / placementWidthMin.height); + qreal scaleWidthMax = std::min(area.width() / placementWidthMax.width, + area.height() / placementWidthMax.height); + + if (scaleWidthMin > scaleWidthMax) { + return placementWidthMin; + } else { + return placementWidthMax; + } +} + +QList ExpoLayout::refineAndApplyPacking(const QRectF& area, + const QMarginsF& margins, + const LayeredPacking& packing, + const QList& windowSizes, + const QList& centers) +{ + // Scale packing to fit area + qreal scale = std::min(area.width() / packing.width, area.height() / packing.height); + scale = std::min(scale, m_maxScale); + + const QMarginsF scaledMargins = QMarginsF(margins.left() * scale, + margins.top() * scale, + margins.right() * scale, + margins.bottom() * scale); + + // The maximum gap in additional to margins to leave between windows + qreal maxGapY = m_maxGapRatio * (scaledMargins.top() + scaledMargins.bottom()); + qreal maxGapX = m_maxGapRatio * (scaledMargins.left() + scaledMargins.right()); + + // center align y + qreal extraY = area.height() - packing.height * scale; + qreal gapY = std::min(maxGapY, extraY / (packing.layers.size() + 1)); + qreal y = area.y() + (extraY - gapY * (packing.layers.size() - 1)) / 2; + + QList finalWindowLayouts(windowSizes); + // smaller windows "float" to the top + for (const auto& layer : packing.layers) { + qreal extraX = area.width() - layer.width() * scale; + qreal gapX = std::min(maxGapX, extraX / (layer.ids.size() + 1)); + qreal x = area.x() + (extraX - gapX * (layer.ids.size() - 1)) / 2; + + QList ids(layer.ids); + std::stable_sort(ids.begin(), ids.end(), [¢ers](size_t a, size_t b) { + return centers[a].x() < centers[b].x(); // minimize horizontal movement + }); + for (auto id : std::as_const(ids)) { + QRectF& windowLayout = finalWindowLayouts[id]; + qreal newY + = y + (layer.maxHeight - windowLayout.height()) * scale / 2; // center align y + windowLayout + = QRectF(x, newY, windowLayout.width() * scale, windowLayout.height() * scale); + x += windowLayout.width() + gapX; + windowLayout -= scaledMargins; + } + y += layer.maxHeight * scale + gapY; + } + return finalWindowLayouts; } + +#include "moc_expolayout.cpp" diff --git a/plugins/effects/private/expolayout.h b/plugins/effects/private/expolayout.h index d0cc64d6e2..d9f886ddf8 100644 --- a/plugins/effects/private/expolayout.h +++ b/plugins/effects/private/expolayout.h @@ -1,11 +1,13 @@ /* SPDX-FileCopyrightText: 2021 Vlad Zahorodnii + SPDX-FileCopyrightText: 2024 Yifan Zhu SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once +#include #include #include #include @@ -13,33 +15,93 @@ #include class ExpoCell; - +struct Layer; +struct LayeredPacking; + +/** + * @brief Adapts the algorithm from [0] to layout the windows intelligently. + * + * Design goals: + * - use screen space efficiently, given diverse geometries of windows + * - be aesthetically pleasing + * - and minimize movement of windows from initial positions + * + * More concretely, the algorithm produces a layered layout, where each layer, + * or strip, is a row or column. The algorithm tries to ensure that different + * strips have similar widths, and uses binary search to find a packing with + * similar aspect ratio to the layout area. Within each strip, the algorithm + * tries to minimize horizontal movement (for rows) or vertical movement (for + * columns) of the windows. + * + * [0] Hirschberg, Daniel S., and Lawrence L. Larmore. "The least weight + * subsequence problem." SIAM Journal on Computing 16.4 (1987): 628-638. + */ class ExpoLayout : public QQuickItem { Q_OBJECT - Q_PROPERTY(LayoutMode mode READ mode WRITE setMode NOTIFY modeChanged) - Q_PROPERTY(bool fillGaps READ fillGaps WRITE setFillGaps NOTIFY fillGapsChanged) - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) + // Place windows in rows or columns. + Q_PROPERTY(PlacementMode placementMode READ placementMode WRITE setPlacementMode NOTIFY + placementModeChanged) Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) + /** + * Stop binary search when the two candidate strip widths are within tol (as a fraction of the + * larger strip width). Default is 0.2. + */ + Q_PROPERTY(qreal searchTolerance MEMBER m_searchTolerance NOTIFY searchToleranceChanged) + /** + * The ideal sum of window widths in a strip (including added margins), as a fraction of the + * strip width. *MUST* be strictly less than 1. Default is 0.8. + */ + Q_PROPERTY(qreal idealWidthRatio MEMBER m_idealWidthRatio NOTIFY idealWidthRatioChanged) + /** + * Left margin size, as a ratio of the short side of layout area. Default is 0.07. + * The margins are added to each window before layout. + */ + Q_PROPERTY( + qreal relativeMarginLeft MEMBER m_relativeMarginLeft NOTIFY relativeMarginLeftChanged) + /** + * Right margin size, as a ratio of the short side of layout area. Default is 0.07. + * The margins are added to each window before layout. + */ + Q_PROPERTY( + qreal relativeMarginRight MEMBER m_relativeMarginRight NOTIFY relativeMarginRightChanged) + /** + * Top margin size, as a ratio of the short side of layout area. Default is 0.07. + * The margins are added to each window before layout. + */ + Q_PROPERTY(qreal relativeMarginTop MEMBER m_relativeMarginTop NOTIFY relativeMarginTopChanged) + /** + * Bottom margin size, as a ratio of the short side of layout area. Default is 0.07. + * The margins are added to each window before layout. + */ + Q_PROPERTY( + qreal relativeMarginBottom MEMBER m_relativeMarginBottom NOTIFY relativeMarginBottomChanged) + /** + * Minimal length of windows, as a ratio of the short side of layout area. + * Smaller windows will be resized to this. Default is 0.15. + */ + Q_PROPERTY(qreal relativeMinLength MEMBER m_relativeMinLength NOTIFY relativeMinLengthChanged) + /** + * Maximum additional gap between windows, as a ratio of normal spacing (2*margin). Default + * is 1.5. + */ + Q_PROPERTY(qreal maxGapRatio MEMBER m_maxGapRatio NOTIFY maxGapRatioChanged) + /** + * Maximum scale applied to windows, *after* the minimum length is enforced. Default is 1.0. + */ + Q_PROPERTY(qreal maxScale MEMBER m_maxScale NOTIFY maxScaleChanged) public: - enum LayoutMode : uint { - LayoutClosest = 0, - LayoutNatural = 1, - LayoutNone = 2, + enum PlacementMode : uint { + Rows, + Columns, }; - Q_ENUM(LayoutMode) + Q_ENUM(PlacementMode) explicit ExpoLayout(QQuickItem* parent = nullptr); - LayoutMode mode() const; - void setMode(LayoutMode mode); - - bool fillGaps() const; - void setFillGaps(bool fill); - - int spacing() const; - void setSpacing(int spacing); + PlacementMode placementMode() const; + void setPlacementMode(PlacementMode mode); void addCell(ExpoCell* cell); void removeCell(ExpoCell* cell); @@ -53,23 +115,89 @@ class ExpoLayout : public QQuickItem void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override; void updatePolish() override; + /** + * @brief Layout the windows with @param windowSizes into @param area. + * + * This is the main entry point for the layout algorithm. + */ + QList layout(const QRectF& area, const QList& windowSizes); + + /** + * @brief First clip @param windowSizes to be between @param minSize and + * @param maxSize. Then add @param margins to each window size, and @return + * the adjusted window sizes. + */ + QList adjustSizes(const QRectF& minSize, + const QRectF& maxSize, + const QMarginsF& margins, + const QList& windowSizes); + + /** + * @brief Use binary search to find a good packing of the @param windowSizes + * into @param area such that the resulting packing has similar aspect ratio + * (height/width) to @param area. + * + * The binary search is performed on the logarithm of the width of the + * possible packings, and the search is terminated when the width of the + * packing is within @param tol of the ideal width. + * + * We try to find a packing such that the total widths of windows in each + * layer are close to @param idealWidthRatio times the maximum width of the + * packing. + * + * In the case of identical window heights, we also try to minimize vertical + * movement based on the @param centers of the windows. + * + * Run time is O(n log n log log (totalWidth / maxWidth)) + * Since we clip the window size, this is just O(n log n log log n) + */ + LayeredPacking findGoodPacking(const QRectF& area, + const QList& windowSizes, + const QList& centers, + qreal idealWidthRatio, + qreal tol); + + /** + * @brief Output the final window layouts from the packing. + * + * Geven @param windowSizes, scale @param packing to fit @param area, + * remove previously added @param margins, add padding and align, + * and @return the final layout. + * In each layer, sort the windows by x coordinates of the @param centers. + */ + QList refineAndApplyPacking(const QRectF& area, + const QMarginsF& margins, + const LayeredPacking& packing, + const QList& windowSizes, + const QList& centers); + Q_SIGNALS: - void modeChanged(); - void fillGapsChanged(); - void spacingChanged(); + void placementModeChanged(); void readyChanged(); + void searchToleranceChanged(); + void idealWidthRatioChanged(); + void relativeMarginLeftChanged(); + void relativeMarginRightChanged(); + void relativeMarginTopChanged(); + void relativeMarginBottomChanged(); + void relativeMinLengthChanged(); + void maxGapRatioChanged(); + void maxScaleChanged(); private: - void calculateWindowTransformationsClosest(); - void calculateWindowTransformationsNatural(); - void resetTransformations(); - QList m_cells; - LayoutMode m_mode = LayoutNatural; - int m_accuracy = 20; - int m_spacing = 10; + PlacementMode m_placementMode = Rows; bool m_ready = false; - bool m_fillGaps = false; + + qreal m_searchTolerance = 0.2; + qreal m_idealWidthRatio = 0.8; + qreal m_relativeMarginLeft = 0.07; + qreal m_relativeMarginRight = 0.07; + qreal m_relativeMarginTop = 0.07; + qreal m_relativeMarginBottom = 0.07; + qreal m_relativeMinLength = 0.15; + qreal m_maxGapRatio = 1.5; + qreal m_maxScale = 1.0; }; class ExpoCell : public QObject @@ -162,5 +290,73 @@ public Q_SLOTS: std::optional m_y; std::optional m_width; std::optional m_height; - QPointer m_layout; + ExpoLayout* m_layout{nullptr}; +}; + +/** + * @brief Each Layer is a horizontal strip of windows with a maximum width and + * height. + */ +struct Layer { + qreal maxWidth; + qreal maxHeight; + /** + * @brief The remaining width available to new windows in this layer. + * width() + remainingWidth() == maxWidth + */ + qreal remainingWidth; + + /** + * @brief The indices of windows in this layer. + */ + QList ids; + + /** + * @brief Initializes a new layer with the given maximum width and populates + * it with the given windows. + * + * @param maxWidth The maximum width of the layer. + * @param windowSizes The sizes of all the windows. Must be sorted in + * ascending order by height. + * @param windowIds Ids of the windows. + * @param startPos windowIds[startPos] is the first window in this layer. + * @param endPos windowIds[endPos-1] is the last window in this layer. + */ + Layer(qreal maxWidth, + const QList& windowSizes, + const QList& windowIds, + size_t startPos, + size_t endPos); + + /** + * @brief The total width of all the windows in this layer. + * + */ + qreal width() const; +}; + +/** + * @brief A LayeredPacking is a packing of windows into layers, which are + * horizontal strips of windows. + */ +struct LayeredPacking { + qreal maxWidth; + qreal width; + qreal height; + QList layers; + + /** + * @brief Construct a new LayeredPacking object from a list of windows + * sorted by height in descending order. + * + * @param maxWidth The maximum width of the packing. + * @param windowSizes must be sorted by height in ascending order + * @param ids Ids of the windows + * @param layerStartPos Array of indices into ids that indicate the start + * of a new layer. Must start with 0 and end with ids.size(). + */ + LayeredPacking(qreal maxWidth, + const QList& windowSizes, + const QList& ids, + const QList& layerStartPos); }; diff --git a/plugins/effects/private/qml/WindowHeap.qml b/plugins/effects/private/qml/WindowHeap.qml index 14a9743130..e6462086e8 100644 --- a/plugins/effects/private/qml/WindowHeap.qml +++ b/plugins/effects/private/qml/WindowHeap.qml @@ -126,8 +126,8 @@ FocusScope { anchors.fill: parent anchors.margins: heap.padding - fillGaps: true - spacing: Kirigami.Units.smallSpacing * 5 + + placementMode: width >= height ? ExpoLayout.Rows : ExpoLayout.Columns Instantiator { id: windowsInstantiator diff --git a/plugins/effects/private/qml/WindowHeapDelegate.qml b/plugins/effects/private/qml/WindowHeapDelegate.qml index 77d6ba92ad..b1b2620efd 100644 --- a/plugins/effects/private/qml/WindowHeapDelegate.qml +++ b/plugins/effects/private/qml/WindowHeapDelegate.qml @@ -8,7 +8,7 @@ import QtQuick import QtQuick.Window import Qt5Compat.GraphicalEffects -import org.kde.kirigami 2.20 as Kirigami +import org.kde.kirigami as Kirigami import org.kde.kwin as KWinComponents import org.kde.kwin.private.effects import org.kde.plasma.components 3.0 as PC3 @@ -136,7 +136,7 @@ Item { border.color: Kirigami.Theme.highlightColor anchors.fill: parent anchors.margins: -border.width - radius: border.width + radius: Kirigami.Units.cornerRadius color: "transparent" visible: !thumb.windowHeap.dragActive && (hoverHandler.hovered || (thumb.selected && Window.window.activeFocusItem)) && windowHeap.effectiveOrganized } diff --git a/plugins/effects/windowview/kcm/windowvieweffectkcm.ui b/plugins/effects/windowview/kcm/windowvieweffectkcm.ui index a52c2bd01b..0ac0000f23 100644 --- a/plugins/effects/windowview/kcm/windowvieweffectkcm.ui +++ b/plugins/effects/windowview/kcm/windowvieweffectkcm.ui @@ -16,28 +16,14 @@ - - + + - Layout mode: + Ignore &minimized windows - - - - - Closest - - - - - Natural - - - - - + @@ -50,13 +36,6 @@ - - - - Ignore &minimized windows - - - diff --git a/plugins/effects/windowview/qml/main.qml b/plugins/effects/windowview/qml/main.qml index adacb47b59..491176496a 100644 --- a/plugins/effects/windowview/qml/main.qml +++ b/plugins/effects/windowview/qml/main.qml @@ -178,7 +178,6 @@ Item { return container.effect.selectedIds; } } - layout.mode: effect.layout model: KWinComponents.WindowFilterModel { activity: KWinComponents.Workspace.currentActivity desktop: { @@ -225,7 +224,7 @@ Item { onDownGestureTriggered: window.closeWindow() TapHandler { - acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Pen + acceptedPointerTypes: PointerDevice.Generic | PointerDevice.Pen acceptedButtons: Qt.MiddleButton onTapped: window.closeWindow(); } diff --git a/plugins/effects/windowview/windowviewconfig.kcfg b/plugins/effects/windowview/windowviewconfig.kcfg index 90feb7de88..8cbdbec65f 100644 --- a/plugins/effects/windowview/windowviewconfig.kcfg +++ b/plugins/effects/windowview/windowviewconfig.kcfg @@ -10,9 +10,6 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - 1 - false diff --git a/plugins/effects/windowview/windowvieweffect.cpp b/plugins/effects/windowview/windowvieweffect.cpp index f928f74896..932fc165fb 100644 --- a/plugins/effects/windowview/windowvieweffect.cpp +++ b/plugins/effects/windowview/windowvieweffect.cpp @@ -137,19 +137,6 @@ void WindowViewEffect::setAnimationDuration(int duration) } } -int WindowViewEffect::layout() const -{ - return m_layout; -} - -void WindowViewEffect::setLayout(int layout) -{ - if (m_layout != layout) { - m_layout = layout; - Q_EMIT layoutChanged(); - } -} - bool WindowViewEffect::ignoreMinimized() const { return WindowViewConfig::ignoreMinimized(); @@ -164,7 +151,6 @@ void WindowViewEffect::reconfigure(ReconfigureFlags) { WindowViewConfig::self()->read(); setAnimationDuration(animationTime(300)); - setLayout(WindowViewConfig::layoutMode()); for (ElectricBorder border : std::as_const(m_borderActivate)) { effects->unreserveElectricBorder(border, this); diff --git a/plugins/effects/windowview/windowvieweffect.h b/plugins/effects/windowview/windowvieweffect.h index e91203c01e..3913499f92 100644 --- a/plugins/effects/windowview/windowvieweffect.h +++ b/plugins/effects/windowview/windowvieweffect.h @@ -20,7 +20,6 @@ class WindowViewEffect : public QuickSceneEffect { Q_OBJECT Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged) - Q_PROPERTY(int layout READ layout NOTIFY layoutChanged) Q_PROPERTY(bool ignoreMinimized READ ignoreMinimized NOTIFY ignoreMinimizedChanged) Q_PROPERTY(PresentWindowsMode mode READ mode NOTIFY modeChanged) Q_PROPERTY(qreal partialActivationFactor READ partialActivationFactor NOTIFY @@ -47,9 +46,6 @@ class WindowViewEffect : public QuickSceneEffect int animationDuration() const; void setAnimationDuration(int duration); - int layout() const; - void setLayout(int layout); - bool ignoreMinimized() const; void reconfigure(ReconfigureFlags) override; @@ -82,7 +78,6 @@ public Q_SLOTS: void partialActivationFactorChanged(); void gestureInProgressChanged(); void modeChanged(); - void layoutChanged(); void ignoreMinimizedChanged(); void searchTextChanged(); void selectedIdsChanged(); @@ -118,7 +113,6 @@ public Q_SLOTS: qreal m_partialActivationFactor = 0; PresentWindowsMode m_mode; int m_animationDuration = 400; - int m_layout = 1; bool m_gestureInProgress = false; }; diff --git a/plugins/kdecorations/aurorae/src/aurorae.knsrc.cmake b/plugins/kdecorations/aurorae/src/aurorae.knsrc.cmake index b45ea8f3a4..b2257f70ff 100644 --- a/plugins/kdecorations/aurorae/src/aurorae.knsrc.cmake +++ b/plugins/kdecorations/aurorae/src/aurorae.knsrc.cmake @@ -43,6 +43,7 @@ Name[zh_CN]=Aurorae 窗口装饰 Name[zh_TW]=Aurorae 視窗裝飾 ProvidersUrl=https://autoconfig.kde.org/ocs/providers.xml +ContentWarning=Executables Categories=Window Decoration Aurorae Uncompress=archive TargetDir=aurorae/themes diff --git a/plugins/kdecorations/aurorae/themes/plastik/package/contents/ui/PlastikButton.qml b/plugins/kdecorations/aurorae/themes/plastik/package/contents/ui/PlastikButton.qml index 5ddf294c75..f0e69da800 100644 --- a/plugins/kdecorations/aurorae/themes/plastik/package/contents/ui/PlastikButton.qml +++ b/plugins/kdecorations/aurorae/themes/plastik/package/contents/ui/PlastikButton.qml @@ -73,6 +73,8 @@ DecorationButton { width: size height: size Rectangle { + // Intentionally not using Kirigami.Units.cornerRadius to mimic a + // particular style radius: 2 smooth: true anchors.fill: parent @@ -87,6 +89,8 @@ DecorationButton { } } Rectangle { + // Intentionally not using Kirigami.Units.cornerRadius to mimic a + // particular style radius: 2 smooth: true anchors { diff --git a/plugins/kpackage/effect/effect.cpp b/plugins/kpackage/effect/effect.cpp index db4cad8859..cb7e598dd2 100644 --- a/plugins/kpackage/effect/effect.cpp +++ b/plugins/kpackage/effect/effect.cpp @@ -18,8 +18,8 @@ class EffectPackageStructure : public KPackage::PackageStructure package->addDirectoryDefinition("code", QStringLiteral("code")); package->setMimeTypes("code", QStringList{QStringLiteral("text/plain")}); - package->addFileDefinition("mainscript", QStringLiteral("code/main.js")); - package->setRequired("mainscript", true); + package->addDirectoryDefinition("ui", QStringLiteral("ui")); + package->setMimeTypes("ui", QStringList{QStringLiteral("text/plain")}); package->addFileDefinition("config", QStringLiteral("config/main.xml")); package->setMimeTypes("config", QStringList{QStringLiteral("text/xml")}); @@ -27,6 +27,22 @@ class EffectPackageStructure : public KPackage::PackageStructure package->addFileDefinition("configui", QStringLiteral("ui/config.ui")); package->setMimeTypes("configui", QStringList{QStringLiteral("text/xml")}); } + + void pathChanged(KPackage::Package* package) override + { + if (!package->metadata().isValid()) { + return; + } + + const QString api = package->metadata().value(QStringLiteral("X-Plasma-API")); + if (api == QStringLiteral("javascript")) { + package->addFileDefinition("mainscript", QStringLiteral("code/main.js")); + package->setRequired("mainscript", true); + } else if (api == QStringLiteral("declarativescript")) { + package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml")); + package->setRequired("mainscript", true); + } + } }; K_PLUGIN_CLASS_WITH_JSON(EffectPackageStructure, "effect.json") diff --git a/plugins/qpa/integration.cpp b/plugins/qpa/integration.cpp index 5ee8660a08..41e64f21af 100644 --- a/plugins/qpa/integration.cpp +++ b/plugins/qpa/integration.cpp @@ -26,9 +26,12 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -#include #include +#if !defined(QT_NO_ACCESSIBILITY_ATSPI_BRIDGE) +#include +#endif + namespace como { @@ -147,7 +150,9 @@ QPlatformOpenGLContext* Integration::createPlatformOpenGLContext(QOpenGLContext* QPlatformAccessibility* Integration::accessibility() const { if (!m_accessibility) { +#if !defined(QT_NO_ACCESSIBILITY_ATSPI_BRIDGE) m_accessibility.reset(new QSpiAccessibleBridge()); +#endif } return m_accessibility.get(); } diff --git a/plugins/qpa/window.cpp b/plugins/qpa/window.cpp index 7c280df81b..c600a4a488 100644 --- a/plugins/qpa/window.cpp +++ b/plugins/qpa/window.cpp @@ -137,6 +137,7 @@ void Window::map() } m_handle = win::singleton_interface::create_internal_window(window()); + QObject::connect(m_handle, &QObject::destroyed, m_handle, [this] { m_handle = nullptr; }); } void Window::unmap() diff --git a/plugins/qpa/window.h b/plugins/qpa/window.h index 0b854f659b..b47a9cb1fd 100644 --- a/plugins/qpa/window.h +++ b/plugins/qpa/window.h @@ -11,7 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include -#include #include #include @@ -43,7 +42,7 @@ class Window : public QPlatformWindow void map(); void unmap(); - QPointer m_handle; + win::internal_window_singleton* m_handle{nullptr}; std::shared_ptr m_contentFBO; quint32 m_windowId; bool m_resized = false; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bb87b8a2d8..565d80d677 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,7 +8,7 @@ Include(FetchContent) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.3.1 + GIT_TAG v3.5.3 ) FetchContent_MakeAvailable(Catch2) diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index a39c9db451..3bda5432a1 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -110,10 +110,11 @@ add_executable(tests ) target_compile_definitions(tests PRIVATE USE_XWL=1) +set_target_properties(tests PROPERTIES UNITY_BUILD ON) target_link_libraries(tests PRIVATE - desktop-kde + desktop-kde-wl como::wayland como::xwayland script @@ -188,10 +189,11 @@ add_executable(tests-wl ) target_compile_definitions(tests-wl PRIVATE USE_XWL=0) +set_target_properties(tests-wl PROPERTIES UNITY_BUILD ON) target_link_libraries(tests-wl PRIVATE - desktop-kde + desktop-kde-wl como::wayland script Qt::Test diff --git a/tests/integration/activation.cpp b/tests/integration/activation.cpp index c61d7baab9..cd7debdf51 100644 --- a/tests/integration/activation.cpp +++ b/tests/integration/activation.cpp @@ -39,7 +39,6 @@ TEST_CASE("activation", "[win]") SECTION("switch to left window") { // Verifies that "Switch to Window to the Left" shortcut works. - using namespace Wrapland::Client; // Prepare the test environment. stackScreensHorizontally(); @@ -107,8 +106,6 @@ TEST_CASE("activation", "[win]") { // Verifies that "Switch to Window to the Right" shortcut works. - using namespace Wrapland::Client; - // Prepare the test environment. stackScreensHorizontally(); @@ -175,8 +172,6 @@ TEST_CASE("activation", "[win]") { // Verifies that "Switch to Window Above" shortcut works. - using namespace Wrapland::Client; - // Prepare the test environment. stackScreensVertically(); @@ -243,8 +238,6 @@ TEST_CASE("activation", "[win]") { // Verifies that "Switch to Window Bottom" shortcut works. - using namespace Wrapland::Client; - // Prepare the test environment. stackScreensVertically(); @@ -312,8 +305,6 @@ TEST_CASE("activation", "[win]") // Verifies that we switch to the top-most maximized client, i.e. // the one that user sees at the moment. See bug 411356. - using namespace Wrapland::Client; - // Prepare the test environment. stackScreensHorizontally(); @@ -324,7 +315,8 @@ TEST_CASE("activation", "[win]") REQUIRE(client1); REQUIRE(client1->control->active); - QSignalSpy configureRequestedSpy1(shellSurface1.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy1(shellSurface1.get(), + &Wrapland::Client::XdgShellToplevel::configured); REQUIRE(configureRequestedSpy1.isValid()); REQUIRE(configureRequestedSpy1.wait()); @@ -348,7 +340,8 @@ TEST_CASE("activation", "[win]") REQUIRE(client2); REQUIRE(client2->control->active); - QSignalSpy configureRequestedSpy2(shellSurface2.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy2(shellSurface2.get(), + &Wrapland::Client::XdgShellToplevel::configured); REQUIRE(configureRequestedSpy2.isValid()); REQUIRE(configureRequestedSpy2.wait()); @@ -415,8 +408,6 @@ TEST_CASE("activation", "[win]") // Verifies that we switch to the top-most fullscreen fullscreen, i.e. // the one that user sees at the moment. See bug 411356. - using namespace Wrapland::Client; - // Prepare the test environment. stackScreensVertically(); @@ -427,7 +418,8 @@ TEST_CASE("activation", "[win]") REQUIRE(client1); REQUIRE(client1->control->active); - QSignalSpy configureRequestedSpy1(shellSurface1.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy1(shellSurface1.get(), + &Wrapland::Client::XdgShellToplevel::configured); REQUIRE(configureRequestedSpy1.isValid()); REQUIRE(configureRequestedSpy1.wait()); @@ -449,7 +441,8 @@ TEST_CASE("activation", "[win]") REQUIRE(client2); REQUIRE(client2->control->active); - QSignalSpy configureRequestedSpy2(shellSurface2.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy2(shellSurface2.get(), + &Wrapland::Client::XdgShellToplevel::configured); REQUIRE(configureRequestedSpy2.isValid()); REQUIRE(configureRequestedSpy2.wait()); diff --git a/tests/integration/bindings.cpp b/tests/integration/bindings.cpp index c3e1aea9e3..d9972597ea 100644 --- a/tests/integration/bindings.cpp +++ b/tests/integration/bindings.cpp @@ -13,8 +13,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { diff --git a/tests/integration/buffer_size_change.cpp b/tests/integration/buffer_size_change.cpp index fe7ab63cf9..13ddd2002f 100644 --- a/tests/integration/buffer_size_change.cpp +++ b/tests/integration/buffer_size_change.cpp @@ -21,9 +21,6 @@ TEST_CASE("buffer size change", "[render]") SECTION("shm") { // Verifies that an SHM buffer size change is handled correctly. - - using namespace Wrapland::Client; - auto surface = create_surface(); QVERIFY(surface); @@ -48,8 +45,6 @@ TEST_CASE("buffer size change", "[render]") SECTION("shm on subsurface") { - using namespace Wrapland::Client; - // setup parent surface auto parentSurface = create_surface(); QVERIFY(parentSurface); @@ -59,7 +54,7 @@ TEST_CASE("buffer size change", "[render]") // setup sub surface auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr subSurface(create_subsurface(surface, parentSurface)); + auto subSurface = create_subsurface(surface, parentSurface); QVERIFY(subSurface); // set buffer sizes @@ -74,7 +69,7 @@ TEST_CASE("buffer size change", "[render]") QSignalSpy damagedParentSpy(parent->qobject.get(), &win::window_qobject::damaged); QVERIFY(damagedParentSpy.isValid()); render(surface, QSize(20, 10), Qt::red); - parentSurface->commit(Surface::CommitFlag::None); + parentSurface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(damagedParentSpy.wait()); QTRY_COMPARE(damagedParentSpy.count(), 2); diff --git a/tests/integration/dbus_interface.cpp b/tests/integration/dbus_interface.cpp index 6bb50a8794..734043bc1d 100644 --- a/tests/integration/dbus_interface.cpp +++ b/tests/integration/dbus_interface.cpp @@ -14,8 +14,6 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -60,8 +58,8 @@ TEST_CASE("dbus interface", "[base]") &space::qobject_t::wayland_window_added); QVERIFY(clientAddedSpy.isValid()); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); shellSurface->setTitle(QStringLiteral("Test window")); diff --git a/tests/integration/debug_console.cpp b/tests/integration/debug_console.cpp index a745233488..178389c1ce 100644 --- a/tests/integration/debug_console.cpp +++ b/tests/integration/debug_console.cpp @@ -325,11 +325,12 @@ TEST_CASE("debug console", "[debug]") setup_wayland_connection(); // create the Surface and ShellSurface - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); + QVERIFY(surface); QVERIFY(surface->isValid()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + render(surface, QSize(10, 10), Qt::red); // now we have the window, it should be added to our model @@ -388,8 +389,8 @@ TEST_CASE("debug console", "[debug]") QSignalSpy rowsRemovedSpy(model.get(), &QAbstractItemModel::rowsRemoved); QVERIFY(rowsRemovedSpy.isValid()); - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); shellSurface.reset(); flush_wayland_connection(); QVERIFY(rowsRemovedSpy.wait(500)); diff --git a/tests/integration/decoration_input.cpp b/tests/integration/decoration_input.cpp index 53fab82981..d41b870d2a 100644 --- a/tests/integration/decoration_input.cpp +++ b/tests/integration/decoration_input.cpp @@ -71,31 +71,29 @@ TEST_CASE("decoration input", "[input],[win]") } client; auto showWindow = [&]() -> space::wayland_window* { - using namespace Wrapland::Client; - #define VERIFY(statement) \ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \ return nullptr; #define COMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return nullptr; - client.surface = create_surface(); VERIFY(client.surface.get()); client.toplevel = create_xdg_shell_toplevel(client.surface, CreationSetup::CreateOnly); VERIFY(client.toplevel.get()); - QSignalSpy configureRequestedSpy(client.toplevel.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(client.toplevel.get(), + &Wrapland::Client::XdgShellToplevel::configured); auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( client.toplevel.get(), client.toplevel.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); VERIFY(decoSpy.isValid()); - deco->setMode(XdgDecoration::Mode::ServerSide); - COMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + COMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(client.surface, client.toplevel); COMPARE(decoSpy.count(), 1); - COMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + COMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); VERIFY(configureRequestedSpy.count() > 0 || configureRequestedSpy.wait()); COMPARE(configureRequestedSpy.count(), 1); @@ -425,7 +423,7 @@ TEST_CASE("decoration input", "[input],[win]") }; auto test_data = GENERATE(data{"to right", {10, 0}, {20, 0}, {30, 0}}, data{"to left", {-10, 0}, {-20, 0}, {-30, 0}}, - data{"to bottom", {0, 10}, {0, 20}, {0, 30}}, + data{"to top", {0, 10}, {0, 20}, {0, 30}}, data{"to bottom", {0, -10}, {0, -20}, {0, -30}}); auto c = showWindow(); @@ -482,8 +480,12 @@ TEST_CASE("decoration input", "[input],[win]") QTRY_VERIFY(!win::is_move(c)); QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2); + // TODO(romangg): A local variable is needed, otherwise the test fails on release builds + // There seems to be a race condition. Needs to be investigated. + auto const compare_pos = oldPos + test_data.offset2 + test_data.offset3; + // TODO: the offset should also be included - QCOMPARE(c->geo.pos(), oldPos + test_data.offset2 + test_data.offset3); + QCOMPARE(c->geo.pos(), compare_pos); } SECTION("resize outside window") diff --git a/tests/integration/effects/fade.cpp b/tests/integration/effects/fade.cpp index fe1f5b6232..e1b067f78d 100644 --- a/tests/integration/effects/fade.cpp +++ b/tests/integration/effects/fade.cpp @@ -10,8 +10,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -64,8 +62,8 @@ TEST_CASE("fade", "[effect]") QSignalSpy windowClosedSpy(effects, &EffectsHandler::windowClosed); QVERIFY(windowClosedSpy.isValid()); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); QTRY_COMPARE(windowAddedSpy.count(), 1); @@ -80,8 +78,8 @@ TEST_CASE("fade", "[effect]") QTRY_COMPARE(fade_effect->isActive(), false); // now unmap the surface - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(windowHiddenSpy.wait()); QCOMPARE(fade_effect->isActive(), false); @@ -91,8 +89,8 @@ TEST_CASE("fade", "[effect]") QCOMPARE(fade_effect->isActive(), false); // and unmap once more - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(windowHiddenSpy.wait()); QCOMPARE(fade_effect->isActive(), false); diff --git a/tests/integration/effects/maximize_animation.cpp b/tests/integration/effects/maximize_animation.cpp index f0f03d1b19..1584b2a630 100644 --- a/tests/integration/effects/maximize_animation.cpp +++ b/tests/integration/effects/maximize_animation.cpp @@ -43,19 +43,17 @@ TEST_CASE("maximize animation", "[effect]") // This test verifies that the maximize effect animates a client // when it's maximized or restored. - using namespace Wrapland::Client; - // Create the test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); // Wait for the initial configure event. - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); @@ -63,8 +61,8 @@ TEST_CASE("maximize animation", "[effect]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(0, 0)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Draw contents of the surface. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -78,8 +76,8 @@ TEST_CASE("maximize animation", "[effect]") QCOMPARE(configureRequestedSpy.count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Load effect that will be tested. const QString effectName = QStringLiteral("maximize"); @@ -106,8 +104,8 @@ TEST_CASE("maximize animation", "[effect]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Draw contents of the maximized client. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -128,8 +126,8 @@ TEST_CASE("maximize animation", "[effect]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(100, 50)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Draw contents of the restored client. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); diff --git a/tests/integration/effects/minimize_animation.cpp b/tests/integration/effects/minimize_animation.cpp index 988bb4430f..1dc1443d97 100644 --- a/tests/integration/effects/minimize_animation.cpp +++ b/tests/integration/effects/minimize_animation.cpp @@ -50,27 +50,27 @@ TEST_CASE("minimize animation", "[effect]") { // This test verifies that a minimize effect tries to animate a client // when it's minimized or unminimized. - using namespace Wrapland::Client; - auto effectName = GENERATE(QString("magiclamp"), QString("squash")); QSignalSpy plasmaWindowCreatedSpy(get_client().interfaces.window_management.get(), - &PlasmaWindowManagement::windowCreated); + &Wrapland::Client::PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // Create a panel at the top of the screen. const QRect panelRect = QRect(0, 0, 1280, 36); - std::unique_ptr panelSurface(create_surface()); + auto panelSurface = create_surface(); QVERIFY(panelSurface); - std::unique_ptr panelShellSurface( - create_xdg_shell_toplevel(panelSurface)); + auto panelShellSurface = create_xdg_shell_toplevel(panelSurface); QVERIFY(panelShellSurface); - std::unique_ptr plasmaPanelShellSurface( + + std::unique_ptr plasmaPanelShellSurface( get_client().interfaces.plasma_shell->createSurface(panelSurface.get())); QVERIFY(plasmaPanelShellSurface); - plasmaPanelShellSurface->setRole(PlasmaShellSurface::Role::Panel); + + plasmaPanelShellSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); plasmaPanelShellSurface->setPosition(panelRect.topLeft()); - plasmaPanelShellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible); + plasmaPanelShellSurface->setPanelBehavior( + Wrapland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible); auto panel = render_and_wait_for_shown(panelSurface, panelRect.size(), Qt::blue); QVERIFY(panel); QVERIFY(win::is_dock(panel)); @@ -79,10 +79,11 @@ TEST_CASE("minimize animation", "[effect]") QCOMPARE(plasmaWindowCreatedSpy.count(), 1); // Create the test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::red); QVERIFY(client); QVERIFY(plasmaWindowCreatedSpy.wait()); @@ -90,7 +91,8 @@ TEST_CASE("minimize animation", "[effect]") // We have to set the minimized geometry because the squash effect needs it, // otherwise it won't start animation. - auto window = plasmaWindowCreatedSpy.last().first().value(); + auto window + = plasmaWindowCreatedSpy.last().first().value(); QVERIFY(window); const QRect iconRect = QRect(0, 0, 42, 36); window->setMinimizedGeometry(panelSurface.get(), iconRect); diff --git a/tests/integration/effects/popup_open_close_animation.cpp b/tests/integration/effects/popup_open_close_animation.cpp index 86b65b58e9..d3144c9edf 100644 --- a/tests/integration/effects/popup_open_close_animation.cpp +++ b/tests/integration/effects/popup_open_close_animation.cpp @@ -50,8 +50,7 @@ TEST_CASE("popup open close animation", "[effect]") QVERIFY(effectsImpl); // Create the main window. - using namespace Wrapland::Client; - std::unique_ptr mainWindowSurface(create_surface()); + auto mainWindowSurface = create_surface(); QVERIFY(mainWindowSurface); auto mainWindowShellSurface = create_xdg_shell_toplevel(mainWindowSurface); QVERIFY(mainWindowShellSurface); @@ -68,10 +67,10 @@ TEST_CASE("popup open close animation", "[effect]") QVERIFY(!effect->isActive()); // Create a popup, it should be animated. - std::unique_ptr popupSurface(create_surface()); + auto popupSurface = create_surface(); QVERIFY(popupSurface); - xdg_shell_positioner_data pos_data; + Wrapland::Client::xdg_shell_positioner_data pos_data; pos_data.size = QSize(20, 20); pos_data.anchor.rect = QRect(0, 0, 10, 10); pos_data.anchor.edge = Qt::BottomEdge | Qt::LeftEdge; @@ -115,8 +114,7 @@ TEST_CASE("popup open close animation", "[effect]") QVERIFY(effectsImpl); // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); @@ -167,15 +165,15 @@ TEST_CASE("popup open close animation", "[effect]") QVERIFY(effectsImpl); // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr deco( + std::unique_ptr deco( get_client().interfaces.xdg_decoration->getToplevelDecoration(shellSurface.get())); QVERIFY(deco); - deco->setMode(XdgDecoration::Mode::ServerSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); QVERIFY(win::decoration(client)); diff --git a/tests/integration/effects/scripted_effects.cpp b/tests/integration/effects/scripted_effects.cpp index 07ed243864..f6ba8dc722 100644 --- a/tests/integration/effects/scripted_effects.cpp +++ b/tests/integration/effects/scripted_effects.cpp @@ -146,7 +146,6 @@ TEST_CASE("scripted effects", "[effect]") // trigger windowAdded signal // create a window - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -220,7 +219,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(effect->load(QString::fromStdString(test_data.file))); // animated after window added connect - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -326,7 +324,6 @@ TEST_CASE("scripted effects", "[effect]") QSignalSpy isActiveFullScreenEffectSpyOther( effectOther, &scripting::effect::isActiveFullScreenEffectChanged); - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -385,7 +382,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(effect->load(QString::fromStdString(test_data.file))); // create a window - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -432,7 +428,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(effect->load(QStringLiteral("grabTest"))); // create test client - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -465,7 +460,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(grabber->load(QStringLiteral("grabAlreadyGrabbedWindowTest_grabber"))); // create test client - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -502,7 +496,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(thief->load(QStringLiteral("grabAlreadyGrabbedWindowForcedTest_thief"))); // create test client - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -533,7 +526,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(effect->load(QStringLiteral("ungrabTest"))); // create test client - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -574,7 +566,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(effect->load(test_data.file)); // create test client - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); @@ -651,7 +642,6 @@ TEST_CASE("scripted effects", "[effect]") QVERIFY(effect->load(QStringLiteral("completeTest"))); // create test client - using namespace Wrapland::Client; auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); diff --git a/tests/integration/effects/slidingpopups.cpp b/tests/integration/effects/slidingpopups.cpp index a818cee588..3dfccbe754 100644 --- a/tests/integration/effects/slidingpopups.cpp +++ b/tests/integration/effects/slidingpopups.cpp @@ -239,26 +239,27 @@ TEST_CASE("slidingpopups", "[effect]") QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded); QVERIFY(windowAddedSpy.isValid()); - using namespace Wrapland::Client; // the test created the slide protocol, let's create a Registry and listen for it - std::unique_ptr registry(new Registry); + std::unique_ptr registry(new Wrapland::Client::Registry); registry->create(get_client().connection); - QSignalSpy interfacesAnnouncedSpy(registry.get(), &Registry::interfacesAnnounced); + QSignalSpy interfacesAnnouncedSpy(registry.get(), + &Wrapland::Client::Registry::interfacesAnnounced); QVERIFY(interfacesAnnouncedSpy.isValid()); registry->setup(); QVERIFY(interfacesAnnouncedSpy.wait()); - auto slideInterface = registry->interface(Registry::Interface::Slide); + auto slideInterface = registry->interface(Wrapland::Client::Registry::Interface::Slide); QVERIFY(slideInterface.name != 0); - std::unique_ptr slideManager( + std::unique_ptr slideManager( registry->createSlideManager(slideInterface.name, slideInterface.version)); QVERIFY(slideManager); // create Wayland window - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr slide(slideManager->createSlide(surface.get())); - slide->setLocation(Slide::Location::Left); + + std::unique_ptr slide(slideManager->createSlide(surface.get())); + slide->setLocation(Wrapland::Client::Slide::Location::Left); slide->commit(); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); diff --git a/tests/integration/effects/subspace_switching_animation.cpp b/tests/integration/effects/subspace_switching_animation.cpp index f42c732f0c..e0aee7e53c 100644 --- a/tests/integration/effects/subspace_switching_animation.cpp +++ b/tests/integration/effects/subspace_switching_animation.cpp @@ -17,8 +17,6 @@ TEST_CASE("subspace switching animation", "[effect]") { // This test verifies that subspace switching animation effects actually // try to animate switching between subspaces. - using namespace Wrapland::Client; - auto effectName = GENERATE(QString("cubeslide"), QString("fadedesktop"), QString("slide")); qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2")); @@ -52,10 +50,11 @@ TEST_CASE("subspace switching animation", "[effect]") // The Fade Desktop effect will do nothing if there are no clients to fade, // so we have to create a dummy test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); QCOMPARE(client->topo.subspaces.size(), 1); diff --git a/tests/integration/effects/window_open_close_animation.cpp b/tests/integration/effects/window_open_close_animation.cpp index 9d829a47f8..283c6fa43c 100644 --- a/tests/integration/effects/window_open_close_animation.cpp +++ b/tests/integration/effects/window_open_close_animation.cpp @@ -62,11 +62,11 @@ TEST_CASE("window open close animation", "[effect]") QVERIFY(!effect->isActive()); // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); QVERIFY(effect->isActive()); @@ -98,12 +98,11 @@ TEST_CASE("window open close animation", "[effect]") QVERIFY(effectsImpl); // Create the main window. - using namespace Wrapland::Client; - std::unique_ptr mainWindowSurface(create_surface()); + auto mainWindowSurface = create_surface(); QVERIFY(mainWindowSurface); - std::unique_ptr mainWindowShellSurface( - create_xdg_shell_toplevel(mainWindowSurface)); + auto mainWindowShellSurface = create_xdg_shell_toplevel(mainWindowSurface); QVERIFY(mainWindowShellSurface); + auto mainWindow = render_and_wait_for_shown(mainWindowSurface, QSize(100, 50), Qt::blue); QVERIFY(mainWindow); @@ -117,7 +116,7 @@ TEST_CASE("window open close animation", "[effect]") QVERIFY(!effect->isActive()); // Create a popup, it should not be animated. - std::unique_ptr popupSurface(create_surface()); + auto popupSurface = create_surface(); QVERIFY(popupSurface); Wrapland::Client::xdg_shell_positioner_data pos_data; @@ -126,8 +125,8 @@ TEST_CASE("window open close animation", "[effect]") pos_data.anchor.edge = Qt::BottomEdge | Qt::LeftEdge; pos_data.gravity = Qt::BottomEdge | Qt::RightEdge; - std::unique_ptr popupShellSurface( - create_xdg_shell_popup(popupSurface, mainWindowShellSurface, pos_data)); + auto popupShellSurface + = create_xdg_shell_popup(popupSurface, mainWindowShellSurface, pos_data); QVERIFY(popupShellSurface); auto popup = render_and_wait_for_shown(popupSurface, pos_data.size, Qt::red); QVERIFY(popup); diff --git a/tests/integration/global_shortcuts.cpp b/tests/integration/global_shortcuts.cpp index 4cede6df71..4da4383490 100644 --- a/tests/integration/global_shortcuts.cpp +++ b/tests/integration/global_shortcuts.cpp @@ -15,8 +15,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -187,8 +185,8 @@ TEST_CASE("global shortcuts", "[input]") // * https://github.com/xkbcommon/libxkbcommon/issues/17 // first create a window - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(surface); QVERIFY(shellSurface); @@ -388,8 +386,8 @@ TEST_CASE("global shortcuts", "[input]") SECTION("wayland window shortcut") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QCOMPARE(get_wayland_window(setup.base->mod.space->stacking.active), client); @@ -434,9 +432,9 @@ TEST_CASE("global shortcuts", "[input]") { // QTBUG-62102 - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); diff --git a/tests/integration/idle.cpp b/tests/integration/idle.cpp index 6d4a382c5a..bd7d5b43f6 100644 --- a/tests/integration/idle.cpp +++ b/tests/integration/idle.cpp @@ -103,12 +103,11 @@ TEST_CASE("idle", "[input]") { struct notification_wrap { notification_wrap(uint32_t duration) - : interface { - get_client().interfaces.idle_notifier->get_notification( + : interface{get_client().interfaces.idle_notifier->get_notification( duration, - get_client().interfaces.seat.get()) - }, idle_spy{interface.get(), &Wrapland::Client::idle_notification_v1::idled}, - resume_spy{interface.get(), &Wrapland::Client::idle_notification_v1::resumed} + get_client().interfaces.seat.get())} + , idle_spy{interface.get(), &Wrapland::Client::idle_notification_v1::idled} + , resume_spy{interface.get(), &Wrapland::Client::idle_notification_v1::resumed} { } diff --git a/tests/integration/idle_inhibition.cpp b/tests/integration/idle_inhibition.cpp index 80ec7b20f8..dd300adf0a 100644 --- a/tests/integration/idle_inhibition.cpp +++ b/tests/integration/idle_inhibition.cpp @@ -13,8 +13,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -32,8 +30,10 @@ TEST_CASE("idle inhibition", "[win]") QCOMPARE(idle.inhibit_count, 0); // now create window - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); auto notification = std::unique_ptr( get_client().interfaces.idle_notifier->get_notification( @@ -49,7 +49,7 @@ TEST_CASE("idle inhibition", "[win]") QVERIFY(idle_spy.wait()); // now create inhibition on window - std::unique_ptr inhibitor( + std::unique_ptr inhibitor( get_client().interfaces.idle_inhibit->createInhibitor(surface.get())); QVERIFY(inhibitor->isValid()); @@ -104,13 +104,13 @@ TEST_CASE("idle inhibition", "[win]") QCOMPARE(idle.inhibit_count, 0); // Create the test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // Create the inhibitor object. - std::unique_ptr inhibitor( + std::unique_ptr inhibitor( get_client().interfaces.idle_inhibit->createInhibitor(surface.get())); QVERIFY(inhibitor->isValid()); @@ -155,13 +155,13 @@ TEST_CASE("idle inhibition", "[win]") QCOMPARE(idle.inhibit_count, 0); // Create the test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // Create the inhibitor object. - std::unique_ptr inhibitor( + std::unique_ptr inhibitor( get_client().interfaces.idle_inhibit->createInhibitor(surface.get())); QVERIFY(inhibitor->isValid()); @@ -196,13 +196,13 @@ TEST_CASE("idle inhibition", "[win]") QCOMPARE(idle.inhibit_count, 0); // Create the test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // Create the inhibitor object. - std::unique_ptr inhibitor( + std::unique_ptr inhibitor( get_client().interfaces.idle_inhibit->createInhibitor(surface.get())); QVERIFY(inhibitor->isValid()); @@ -216,8 +216,8 @@ TEST_CASE("idle inhibition", "[win]") // Unmap the client. QSignalSpy hiddenSpy(c->qobject.get(), &win::window_qobject::windowHidden); QVERIFY(hiddenSpy.isValid()); - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(hiddenSpy.wait()); // The surface is no longer visible, so the compositor don't have to honor the @@ -254,13 +254,13 @@ TEST_CASE("idle inhibition", "[win]") QCOMPARE(idle.inhibit_count, 0); // Create the test client. - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // Create the inhibitor object. - std::unique_ptr inhibitor( + std::unique_ptr inhibitor( get_client().interfaces.idle_inhibit->createInhibitor(surface.get())); QVERIFY(inhibitor->isValid()); diff --git a/tests/integration/input_stacking_order.cpp b/tests/integration/input_stacking_order.cpp index 5db47ff487..00fcf63ee7 100644 --- a/tests/integration/input_stacking_order.cpp +++ b/tests/integration/input_stacking_order.cpp @@ -49,15 +49,15 @@ TEST_CASE("input stacking order", "[win]") // the pointer is in the overlapping area which means the top most window has focus // as soon as the top most window gets lowered the window should lose focus and the // other window should gain focus without a mouse event in between - using namespace Wrapland::Client; + // create pointer and signal spy for enter and leave signals auto seat = get_client().interfaces.seat.get(); auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(pointer, &Pointer::left); + QSignalSpy leftSpy(pointer, &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); // now create the two windows and make them overlap diff --git a/tests/integration/internal_window.cpp b/tests/integration/internal_window.cpp index 1f44d1c694..dd40d3ebd9 100644 --- a/tests/integration/internal_window.cpp +++ b/tests/integration/internal_window.cpp @@ -16,7 +16,8 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; +namespace como::detail::test::internal_window +{ namespace { @@ -128,9 +129,6 @@ void HelperWindow::keyReleaseEvent(QKeyEvent* event) } -namespace como::detail::test -{ - TEST_CASE("internal window", "[win]") { #if USE_XWL @@ -326,15 +324,17 @@ TEST_CASE("internal window", "[win]") { // this test verifies that a leave event is sent to a client when an internal window // gets a key event - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); QVERIFY(keyboard); QVERIFY(keyboard->isValid()); - QSignalSpy enteredSpy(keyboard.get(), &Keyboard::entered); + QSignalSpy enteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(keyboard.get(), &Keyboard::left); + QSignalSpy leftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); QVERIFY(leftSpy.isValid()); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); // now let's render auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); diff --git a/tests/integration/keymap_creation_failure.cpp b/tests/integration/keymap_creation_failure.cpp index 6c2b0c73d1..f09aa77692 100644 --- a/tests/integration/keymap_creation_failure.cpp +++ b/tests/integration/keymap_creation_failure.cpp @@ -9,8 +9,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { diff --git a/tests/integration/layer_shell.cpp b/tests/integration/layer_shell.cpp index 482e6fd825..f81563f7f0 100644 --- a/tests/integration/layer_shell.cpp +++ b/tests/integration/layer_shell.cpp @@ -10,11 +10,11 @@ #include #include -namespace Clt = Wrapland::Client; - -namespace como::detail::test +namespace como::detail::test::layer_shell { +namespace Clt = Wrapland::Client; + namespace { diff --git a/tests/integration/lib/helpers.cpp b/tests/integration/lib/helpers.cpp index 7b8945787d..90ed290bf1 100644 --- a/tests/integration/lib/helpers.cpp +++ b/tests/integration/lib/helpers.cpp @@ -13,6 +13,7 @@ #include "como/input/backend/wlroots/keyboard.h" #include "como/input/backend/wlroots/pointer.h" #include "como/input/backend/wlroots/touch.h" +#include "como/win/wayland/screen_lock.h" #include "como/win/wayland/space.h" #include "como/win/wayland/window.h" @@ -230,9 +231,8 @@ create_subsurface(std::unique_ptr const& surface, if (!get_client().interfaces.subcompositor) { return nullptr; } - auto subsurface - = std::unique_ptr(get_client().interfaces.subcompositor->createSubSurface( - surface.get(), parent_surface.get())); + auto subsurface = std::unique_ptr( + get_client().interfaces.subcompositor->createSubSurface(*surface, *parent_surface)); if (!subsurface->isValid()) { return nullptr; } @@ -326,7 +326,7 @@ void init_xdg_shell_popup(std::unique_ptr const& surface, void lock_screen() { - QVERIFY(!base::wayland::is_screen_locked(app()->base)); + QVERIFY(!win::wayland::screen_lock_is_locked(*app()->base->mod.space)); QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); @@ -338,7 +338,7 @@ void lock_screen() ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); QCOMPARE(lockStateChangedSpy.count(), 1); - QVERIFY(base::wayland::is_screen_locked(app()->base)); + QVERIFY(win::wayland::screen_lock_is_locked(*app()->base->mod.space)); QVERIFY(lockWatcherSpy.wait()); QCOMPARE(lockWatcherSpy.count(), 1); QCOMPARE(lockStateChangedSpy.count(), 2); @@ -382,7 +382,7 @@ void unlock_screen() QCOMPARE(lockWatcherSpy.count(), 1); QCOMPARE(lockStateChangedSpy.count(), 1); - QVERIFY(!base::wayland::is_screen_locked(app()->base)); + QVERIFY(!win::wayland::screen_lock_is_locked(*app()->base->mod.space)); QVERIFY(!app()->base->mod.space->mod.desktop->screen_locker_watcher->is_locked()); } @@ -480,7 +480,11 @@ void pointer_motion_absolute(QPointF const& position, uint32_t time) wlr_signal_emit_safe(&test_app->pointer->events.frame, test_app->pointer); } +#if WLR_HAVE_WL_POINTER_ENUMS +void pointer_button_impl(uint32_t button, uint32_t time, wl_pointer_button_state state) +#else void pointer_button_impl(uint32_t button, uint32_t time, wlr_button_state state) +#endif { auto test_app = app(); @@ -499,19 +503,35 @@ void pointer_button_impl(uint32_t button, uint32_t time, wlr_button_state state) void pointer_button_pressed(uint32_t button, uint32_t time) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_button_impl(button, time, WL_POINTER_BUTTON_STATE_PRESSED); +#else pointer_button_impl(button, time, WLR_BUTTON_PRESSED); +#endif } void pointer_button_released(uint32_t button, uint32_t time) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_button_impl(button, time, WL_POINTER_BUTTON_STATE_RELEASED); +#else pointer_button_impl(button, time, WLR_BUTTON_RELEASED); +#endif } +#if WLR_HAVE_WL_POINTER_ENUMS +void pointer_axis_impl(double delta, + uint32_t time, + int32_t discrete_delta, + wl_pointer_axis orientation, + wl_pointer_axis_source source) +#else void pointer_axis_impl(double delta, uint32_t time, int32_t discrete_delta, wlr_axis_orientation orientation, wlr_axis_source source) +#endif { auto test_app = app(); @@ -532,14 +552,27 @@ void pointer_axis_impl(double delta, void pointer_axis_horizontal(double delta, uint32_t time, int32_t discrete_delta) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_axis_impl(delta, + time, + discrete_delta, + WL_POINTER_AXIS_HORIZONTAL_SCROLL, + WL_POINTER_AXIS_SOURCE_WHEEL); +#else pointer_axis_impl( delta, time, discrete_delta, WLR_AXIS_ORIENTATION_HORIZONTAL, WLR_AXIS_SOURCE_WHEEL); +#endif } void pointer_axis_vertical(double delta, uint32_t time, int32_t discrete_delta) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_axis_impl( + delta, time, discrete_delta, WL_POINTER_AXIS_VERTICAL_SCROLL, WL_POINTER_AXIS_SOURCE_WHEEL); +#else pointer_axis_impl( delta, time, discrete_delta, WLR_AXIS_ORIENTATION_VERTICAL, WLR_AXIS_SOURCE_WHEEL); +#endif } void keyboard_key_impl(uint32_t key, diff --git a/tests/integration/lib/setup.cpp b/tests/integration/lib/setup.cpp index 1da264f991..5c0f975816 100644 --- a/tests/integration/lib/setup.cpp +++ b/tests/integration/lib/setup.cpp @@ -8,6 +8,7 @@ #include "como/base/backend/wlroots/helpers.h" #include "como/base/config.h" #include "como/desktop/kde/platform.h" +#include "como/desktop/kde/screen_locker.h" #include "como/input/wayland/platform.h" #include "como/render/shortcuts_init.h" #include "como/render/wayland/platform.h" @@ -144,7 +145,8 @@ void setup::start() metadata.physical_size = {1280, 1024}; out->wrapland_output()->set_metadata(metadata); - base->server->init_screen_locker(); + base->mod.space->mod.desktop->screen_locker = std::make_unique( + *base->server, base->process_environment, false); #if USE_XWL if (base->operation_mode == base::operation_mode::xwayland) { diff --git a/tests/integration/lockscreen.cpp b/tests/integration/lockscreen.cpp index d2a8377702..8ec5861a55 100644 --- a/tests/integration/lockscreen.cpp +++ b/tests/integration/lockscreen.cpp @@ -27,9 +27,7 @@ namespace void unlock() { - using namespace ScreenLocker; - - const auto children = KSldApp::self()->children(); + const auto children = ScreenLocker::KSldApp::self()->children(); for (auto it = children.begin(); it != children.end(); ++it) { if (qstrcmp((*it)->metaObject()->className(), "LogindIntegration") != 0) { continue; @@ -71,13 +69,13 @@ class HelperEffect : public Effect }; #define LOCK \ - QVERIFY(!base::wayland::is_screen_locked(setup.base)); \ + QVERIFY(!win::wayland::screen_lock_is_locked(setup.base->mod.space)); \ QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), \ &ScreenLocker::KSldApp::lockStateChanged); \ QVERIFY(lockStateChangedSpy.isValid()); \ ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); \ QCOMPARE(lockStateChangedSpy.count(), 1); \ - QVERIFY(base::wayland::is_screen_locked(setup.base)); + QVERIFY(win::wayland::screen_lock_is_locked(setup.base->mod.space)); // We use a while loop to check the spy condition repeatedly. We do not wait directly with a spy // timer because this can be problematic with the screenlocker process acting simultaneously. @@ -93,7 +91,7 @@ class HelperEffect : public Effect QTest::qWait(100); \ } \ QCOMPARE(lockStateChangedSpy.count(), expectedLockCount + 1); \ - QVERIFY(!base::wayland::is_screen_locked(setup.base)); + QVERIFY(!win::wayland::screen_lock_is_locked(setup.base->mod.space)); #define MOTION(target) pointer_motion_absolute(target, timestamp++) @@ -128,8 +126,6 @@ TEST_CASE("lockscreen", "[base]") std::unique_ptr toplevel_holder; auto showWindow = [&]() { - using namespace Wrapland::Client; - surface_holder = create_surface(); REQUIRE(surface_holder.get()); toplevel_holder = create_xdg_shell_toplevel(surface_holder); @@ -164,13 +160,12 @@ TEST_CASE("lockscreen", "[base]") SECTION("pointer") { - using namespace Wrapland::Client; - - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); QVERIFY(pointer); - QSignalSpy enteredSpy(pointer.get(), &Pointer::entered); - QSignalSpy leftSpy(pointer.get(), &Pointer::left); + QSignalSpy enteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); + QSignalSpy leftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); QVERIFY(enteredSpy.isValid()); @@ -212,13 +207,12 @@ TEST_CASE("lockscreen", "[base]") SECTION("pointer button") { - using namespace Wrapland::Client; - - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); QVERIFY(pointer); - QSignalSpy enteredSpy(pointer.get(), &Pointer::entered); - QSignalSpy buttonChangedSpy(pointer.get(), &Pointer::buttonStateChanged); + QSignalSpy enteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); + QSignalSpy buttonChangedSpy(pointer.get(), &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(enteredSpy.isValid()); QVERIFY(buttonChangedSpy.isValid()); @@ -256,13 +250,12 @@ TEST_CASE("lockscreen", "[base]") SECTION("pointer axis") { - using namespace Wrapland::Client; - - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); QVERIFY(pointer); - QSignalSpy axisChangedSpy(pointer.get(), &Pointer::axisChanged); - QSignalSpy enteredSpy(pointer.get(), &Pointer::entered); + QSignalSpy axisChangedSpy(pointer.get(), &Wrapland::Client::Pointer::axisChanged); + QSignalSpy enteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(axisChangedSpy.isValid()); QVERIFY(enteredSpy.isValid()); @@ -299,14 +292,13 @@ TEST_CASE("lockscreen", "[base]") SECTION("keyboard") { - using namespace Wrapland::Client; - - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); QVERIFY(keyboard); - QSignalSpy enteredSpy(keyboard.get(), &Keyboard::entered); - QSignalSpy leftSpy(keyboard.get(), &Keyboard::left); - QSignalSpy keyChangedSpy(keyboard.get(), &Keyboard::keyChanged); + QSignalSpy enteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); + QSignalSpy leftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); + QSignalSpy keyChangedSpy(keyboard.get(), &Wrapland::Client::Keyboard::keyChanged); QVERIFY(enteredSpy.isValid()); QVERIFY(leftSpy.isValid()); QVERIFY(keyChangedSpy.isValid()); @@ -322,16 +314,16 @@ TEST_CASE("lockscreen", "[base]") QVERIFY(keyChangedSpy.wait()); QCOMPARE(keyChangedSpy.count(), 1); QCOMPARE(keyChangedSpy.at(0).at(0).value(), quint32(KEY_A)); - QCOMPARE(keyChangedSpy.at(0).at(1).value(), - Keyboard::KeyState::Pressed); + QCOMPARE(keyChangedSpy.at(0).at(1).value(), + Wrapland::Client::Keyboard::KeyState::Pressed); QCOMPARE(keyChangedSpy.at(0).at(2).value(), quint32(1)); KEYRELEASE(KEY_A); QVERIFY(keyChangedSpy.wait()); QCOMPARE(keyChangedSpy.count(), 2); QCOMPARE(keyChangedSpy.at(1).at(0).value(), quint32(KEY_A)); - QCOMPARE(keyChangedSpy.at(1).at(1).value(), - Keyboard::KeyState::Released); + QCOMPARE(keyChangedSpy.at(1).at(1).value(), + Wrapland::Client::Keyboard::KeyState::Released); QCOMPARE(keyChangedSpy.at(1).at(2).value(), quint32(2)); LOCK QVERIFY(leftSpy.wait()); @@ -356,10 +348,10 @@ TEST_CASE("lockscreen", "[base]") QCOMPARE(keyChangedSpy.at(3).at(0).value(), quint32(KEY_C)); QCOMPARE(keyChangedSpy.at(2).at(2).value(), quint32(5)); QCOMPARE(keyChangedSpy.at(3).at(2).value(), quint32(6)); - QCOMPARE(keyChangedSpy.at(2).at(1).value(), - Keyboard::KeyState::Pressed); - QCOMPARE(keyChangedSpy.at(3).at(1).value(), - Keyboard::KeyState::Released); + QCOMPARE(keyChangedSpy.at(2).at(1).value(), + Wrapland::Client::Keyboard::KeyState::Pressed); + QCOMPARE(keyChangedSpy.at(3).at(1).value(), + Wrapland::Client::Keyboard::KeyState::Released); } SECTION("screen edge") @@ -509,8 +501,6 @@ TEST_CASE("lockscreen", "[base]") SECTION("move window") { - using namespace Wrapland::Client; - auto c = showWindow(); QVERIFY(c); @@ -556,8 +546,6 @@ TEST_CASE("lockscreen", "[base]") SECTION("pointer shortcut") { - using namespace Wrapland::Client; - std::unique_ptr action(new QAction(nullptr)); QSignalSpy actionSpy(action.get(), &QAction::triggered); QVERIFY(actionSpy.isValid()); @@ -590,8 +578,6 @@ TEST_CASE("lockscreen", "[base]") SECTION("axis shortcut") { - using namespace Wrapland::Client; - auto direction = GENERATE(Qt::Vertical, Qt::Horizontal); auto sign = GENERATE(-1, 1); @@ -640,8 +626,6 @@ TEST_CASE("lockscreen", "[base]") SECTION("keyboard shortcut") { - using namespace Wrapland::Client; - std::unique_ptr action(new QAction(nullptr)); QSignalSpy actionSpy(action.get(), &QAction::triggered); QVERIFY(actionSpy.isValid()); @@ -695,8 +679,6 @@ TEST_CASE("lockscreen", "[base]") SECTION("touch") { - using namespace Wrapland::Client; - auto touch = get_client().interfaces.seat->createTouch(get_client().interfaces.seat.get()); QVERIFY(touch); QVERIFY(touch->isValid()); @@ -704,11 +686,11 @@ TEST_CASE("lockscreen", "[base]") auto c = showWindow(); QVERIFY(c); - QSignalSpy sequenceStartedSpy(touch, &Touch::sequenceStarted); + QSignalSpy sequenceStartedSpy(touch, &Wrapland::Client::Touch::sequenceStarted); QVERIFY(sequenceStartedSpy.isValid()); - QSignalSpy cancelSpy(touch, &Touch::sequenceCanceled); + QSignalSpy cancelSpy(touch, &Wrapland::Client::Touch::sequenceCanceled); QVERIFY(cancelSpy.isValid()); - QSignalSpy pointRemovedSpy(touch, &Touch::pointRemoved); + QSignalSpy pointRemovedSpy(touch, &Wrapland::Client::Touch::pointRemoved); QVERIFY(pointRemovedSpy.isValid()); quint32 timestamp = 1; diff --git a/tests/integration/maximize.cpp b/tests/integration/maximize.cpp index b6e72343ca..a7cb656a30 100644 --- a/tests/integration/maximize.cpp +++ b/tests/integration/maximize.cpp @@ -17,8 +17,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -141,23 +139,23 @@ TEST_CASE("maximize", "[win]") // This test verifies that a window created as maximized, will be maximized. // Create the test client. - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); shellSurface->setMaximized(true); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); auto cfgdata = shellSurface->get_configure_data(); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Now let's render in an incorrect size. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -187,22 +185,23 @@ TEST_CASE("maximize", "[win]") QCOMPARE(setup.base->mod.space->options->qobject->borderlessMaximizedWindows(), true); // Create the test client. - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - std::unique_ptr decoration( + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + std::unique_ptr decoration( get_client().interfaces.xdg_decoration->getToplevelDecoration(shellSurface.get())); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); shellSurface->setMaximized(true); - QSignalSpy decorationConfiguredSpy(decoration.get(), &XdgDecoration::modeChanged); + QSignalSpy decorationConfiguredSpy(decoration.get(), + &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decorationConfiguredSpy.isValid()); - decoration->setMode(XdgDecoration::Mode::ServerSide); - surface->commit(Surface::CommitFlag::None); + decoration->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy.wait()); @@ -210,8 +209,8 @@ TEST_CASE("maximize", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); auto client = render_and_wait_for_shown(surface, QSize(1280, 1024), Qt::blue); @@ -224,7 +223,7 @@ TEST_CASE("maximize", "[win]") QCOMPARE(client->geo.frame, QRect(0, 0, 1280, 1024)); QTRY_VERIFY(decorationConfiguredSpy.count()); - QCOMPARE(decoration->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(decoration->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); // Destroy the client. shellSurface.reset(); @@ -348,12 +347,13 @@ TEST_CASE("maximize", "[win]") win::space_reconfigure(*setup.base->mod.space); QCOMPARE(setup.base->mod.space->options->qobject->borderlessMaximizedWindows(), true); - std::unique_ptr surface(create_surface()); - std::unique_ptr xdgShellToplevel(create_xdg_shell_toplevel(surface)); - std::unique_ptr deco( + auto surface = create_surface(); + auto xdgShellToplevel = create_xdg_shell_toplevel(surface); + std::unique_ptr deco( get_client().interfaces.xdg_decoration->getToplevelDecoration(xdgShellToplevel.get())); - QSignalSpy decorationConfiguredSpy(deco.get(), &XdgDecoration::modeChanged); + QSignalSpy decorationConfiguredSpy(deco.get(), + &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decorationConfiguredSpy.isValid()); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -361,7 +361,8 @@ TEST_CASE("maximize", "[win]") QSignalSpy geometryChangedSpy(client->qobject.get(), &win::window_qobject::frame_geometry_changed); QVERIFY(geometryChangedSpy.isValid()); - QSignalSpy configureRequestedSpy(xdgShellToplevel.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(xdgShellToplevel.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(win::decoration(client)); @@ -371,8 +372,9 @@ TEST_CASE("maximize", "[win]") QCOMPARE(decorationConfiguredSpy.count(), 1); auto cfgdata = xdgShellToplevel->get_configure_data(); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); // go to maximized xdgShellToplevel->setMaximized(true); @@ -380,7 +382,8 @@ TEST_CASE("maximize", "[win]") QCOMPARE(configureRequestedSpy.count(), 2); cfgdata = xdgShellToplevel->get_configure_data(); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); for (auto const& sig : configureRequestedSpy) { xdgShellToplevel->ackConfigure(sig.front().toInt()); @@ -393,7 +396,7 @@ TEST_CASE("maximize", "[win]") QVERIFY(!win::decoration(client)); QVERIFY(client->noBorder()); // but still server-side - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); // go back to normal xdgShellToplevel->setMaximized(false); @@ -410,7 +413,7 @@ TEST_CASE("maximize", "[win]") QVERIFY(win::decoration(client)); QVERIFY(!client->noBorder()); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); } } diff --git a/tests/integration/modifier_only_shortcut.cpp b/tests/integration/modifier_only_shortcut.cpp index f0ec1b2864..967c607ceb 100644 --- a/tests/integration/modifier_only_shortcut.cpp +++ b/tests/integration/modifier_only_shortcut.cpp @@ -11,16 +11,17 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - -static const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.ModifierOnlyShortcut"); -static const QString s_path = QStringLiteral("/Test"); -static const QStringList trigger - = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; +namespace como::detail::test::modifier_only_shortcut +{ -namespace como::detail::test +namespace { +const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.ModifierOnlyShortcut"); +const QString s_path = QStringLiteral("/Test"); +const QStringList trigger + = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; + class Target : public QObject { Q_OBJECT @@ -56,6 +57,8 @@ void Target::shortcut() Q_EMIT shortcutTriggered(); } +} + TEST_CASE("modifier only shortcut", "[input]") { qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1"); diff --git a/tests/integration/move_resize_window.cpp b/tests/integration/move_resize_window.cpp index 5eca534f10..3877d294b8 100644 --- a/tests/integration/move_resize_window.cpp +++ b/tests/integration/move_resize_window.cpp @@ -67,12 +67,9 @@ TEST_CASE("move resize window", "[win]") SECTION("move") { - using namespace Wrapland::Client; - - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -158,25 +155,22 @@ TEST_CASE("move resize window", "[win]") SECTION("resize") { // a test case which manually resizes a window - using namespace Wrapland::Client; - - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); QVERIFY(shellSurface); // Wait for the initial configure event. - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); auto cfgdata = shellSurface->get_configure_data(); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // Let's render. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -187,9 +181,10 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); QVERIFY(c); QCOMPARE(get_wayland_window(setup.base->mod.space->stacking.active), c); @@ -223,8 +218,8 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 3); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // Trigger a change. auto const cursorPos = cursor()->pos(); @@ -237,10 +232,11 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 4); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); QCOMPARE(cfgdata.size, QSize(108, 50)); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); // Now render new size. @@ -260,10 +256,11 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 5); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); QCOMPARE(cfgdata.size, QSize(108, 58)); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); // Now render new size. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -287,8 +284,8 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 6); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // Destroy the client. surface.reset(); @@ -297,8 +294,6 @@ TEST_CASE("move resize window", "[win]") SECTION("pack to") { - using namespace Wrapland::Client; - struct data { std::string method_name; QRect expected_geo; @@ -309,10 +304,9 @@ TEST_CASE("move resize window", "[win]") data{"right", {1180, 487, 100, 50}}, data{"down", {590, 974, 100, 50}}); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // let's render @@ -337,8 +331,6 @@ TEST_CASE("move resize window", "[win]") SECTION("pack against client") { - using namespace Wrapland::Client; - struct data { std::string method_name; QRect expected_geo; @@ -349,25 +341,25 @@ TEST_CASE("move resize window", "[win]") data{"right", {1170, 487, 100, 50}}, data{"down", {590, 964, 100, 50}}); - std::unique_ptr surface1(create_surface()); + auto surface1 = create_surface(); QVERIFY(surface1); - std::unique_ptr surface2(create_surface()); + auto surface2 = create_surface(); QVERIFY(surface2); - std::unique_ptr surface3(create_surface()); + auto surface3 = create_surface(); QVERIFY(surface3); - std::unique_ptr surface4(create_surface()); + auto surface4 = create_surface(); QVERIFY(surface4); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(shellSurface1); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(shellSurface2); - std::unique_ptr shellSurface3(create_xdg_shell_toplevel(surface3)); + auto shellSurface3 = create_xdg_shell_toplevel(surface3); QVERIFY(shellSurface3); - std::unique_ptr shellSurface4(create_xdg_shell_toplevel(surface4)); + auto shellSurface4 = create_xdg_shell_toplevel(surface4); QVERIFY(shellSurface4); - auto renderWindow = [&setup](std::unique_ptr const& surface, + auto renderWindow = [&setup](auto const& surface, std::function const& method_call, const QRect& expectedGeometry) { // let's render @@ -387,10 +379,11 @@ TEST_CASE("move resize window", "[win]") renderWindow(surface3, &win::active_window_pack_right, QRect(1270, 507, 10, 10)); renderWindow(surface4, &win::active_window_pack_down, QRect(635, 1014, 10, 10)); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); @@ -407,8 +400,6 @@ TEST_CASE("move resize window", "[win]") SECTION("grow shrink") { - using namespace Wrapland::Client; - struct data { std::string method_name; QRect expected_geo; @@ -421,9 +412,9 @@ TEST_CASE("move resize window", "[win]") // This helper surface ensures the test surface will shrink when calling the respective // methods. - std::unique_ptr surface1(create_surface()); + auto surface1 = create_surface(); QVERIFY(surface1); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(shellSurface1); auto window = render_and_wait_for_shown(surface1, QSize(650, 514), Qt::blue); @@ -431,16 +422,16 @@ TEST_CASE("move resize window", "[win]") win::active_window_pack_right(*setup.base->mod.space); win::active_window_pack_down(*setup.base->mod.space); - std::unique_ptr surface(create_surface()); - QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - QVERIFY(shellSurface); + auto surface2 = create_surface(); + QVERIFY(surface2); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); + QVERIFY(shellSurface2); - QSignalSpy configure_spy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configure_spy(shellSurface2.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configure_spy.isValid()); - auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); + auto c = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::blue); QVERIFY(c); QCOMPARE(get_wayland_window(setup.base->mod.space->stacking.active), c); @@ -463,8 +454,8 @@ TEST_CASE("move resize window", "[win]") QVERIFY(configure_spy.wait()); QCOMPARE(configure_spy.count(), 2); - shellSurface->ackConfigure(configure_spy.back().front().value()); - render(surface, shellSurface->get_configure_data().size, Qt::red); + shellSurface2->ackConfigure(configure_spy.back().front().value()); + render(surface2, shellSurface2->get_configure_data().size, Qt::red); QVERIFY(geometryChangedSpy.wait()); REQUIRE(c->geo.frame == test_data.expected_geo); @@ -474,8 +465,6 @@ TEST_CASE("move resize window", "[win]") { // this test verifies that moving a window through pointer only ends if all buttons are // released - using namespace Wrapland::Client; - auto additional_button = GENERATE(BTN_RIGHT, BTN_MIDDLE, BTN_SIDE, @@ -485,10 +474,9 @@ TEST_CASE("move resize window", "[win]") BTN_TASK, range(BTN_TASK + 1, BTN_JOYSTICK)); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // let's render @@ -522,18 +510,21 @@ TEST_CASE("move resize window", "[win]") SECTION("window side move") { - using namespace Wrapland::Client; cursor()->set_pos(640, 512); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - QSignalSpy pointerEnteredSpy(pointer.get(), &Pointer::entered); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); - QSignalSpy pointerLeftSpy(pointer.get(), &Pointer::left); + QSignalSpy pointerLeftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(pointerLeftSpy.isValid()); - QSignalSpy buttonSpy(pointer.get(), &Pointer::buttonStateChanged); + QSignalSpy buttonSpy(pointer.get(), &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); @@ -579,8 +570,6 @@ TEST_CASE("move resize window", "[win]") { // this test verifies that certain window types from PlasmaShellSurface are not moveable or // resizable - using namespace Wrapland::Client; - struct data { Wrapland::Client::PlasmaShellSurface::Role role; bool movable; @@ -594,13 +583,13 @@ TEST_CASE("move resize window", "[win]") data{Wrapland::Client::PlasmaShellSurface::Role::Panel, false, false, false}, data{Wrapland::Client::PlasmaShellSurface::Role::OnScreenDisplay, false, false, false}); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + // and a PlasmaShellSurface - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( get_client().interfaces.plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); plasmaSurface->setRole(test_data.role); @@ -779,12 +768,11 @@ TEST_CASE("move resize window", "[win]") QVERIFY(win::is_dock(panel)); // let's create a window - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto testWindow = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(testWindow); @@ -840,8 +828,6 @@ TEST_CASE("move resize window", "[win]") { // this test verifies that auto hiding panels are ignored when adjusting client geometry // see BUG 365892 - using namespace Wrapland::Client; - struct data { QRect panel_geo; QPoint target_point; @@ -856,16 +842,18 @@ TEST_CASE("move resize window", "[win]") data{{1280 - 20, 0, 20, 100}, {1280 - 25 - 100, 50}, {1280 - 20 - 100, 50}}); // first create our panel - std::unique_ptr panelSurface(create_surface()); + auto panelSurface = create_surface(); QVERIFY(panelSurface); - std::unique_ptr panelShellSurface( - create_xdg_shell_toplevel(panelSurface)); + auto panelShellSurface = create_xdg_shell_toplevel(panelSurface); QVERIFY(panelShellSurface); - std::unique_ptr plasmaSurface( + + std::unique_ptr plasmaSurface( get_client().interfaces.plasma_shell->createSurface(panelSurface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); - plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AutoHide); + + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); + plasmaSurface->setPanelBehavior( + Wrapland::Client::PlasmaShellSurface::PanelBehavior::AutoHide); plasmaSurface->setPosition(test_data.panel_geo.topLeft()); // let's render @@ -875,11 +863,11 @@ TEST_CASE("move resize window", "[win]") QVERIFY(win::is_dock(panel)); // let's create a window - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto testWindow = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(testWindow); @@ -928,11 +916,11 @@ TEST_CASE("move resize window", "[win]") // the associated client is destroyed. // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); @@ -967,11 +955,11 @@ TEST_CASE("move resize window", "[win]") // the associated client is destroyed. // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); @@ -1006,11 +994,11 @@ TEST_CASE("move resize window", "[win]") // the associated client is unmapped. // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); @@ -1034,8 +1022,8 @@ TEST_CASE("move resize window", "[win]") // Unmap the client while we're moving it. QSignalSpy hiddenSpy(client->qobject.get(), &win::window_qobject::windowHidden); QVERIFY(hiddenSpy.isValid()); - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(hiddenSpy.wait()); QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); QVERIFY(!setup.base->mod.space->move_resize_window); @@ -1054,11 +1042,11 @@ TEST_CASE("move resize window", "[win]") // the associated client is unmapped. // Create the test client. - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); @@ -1082,8 +1070,10 @@ TEST_CASE("move resize window", "[win]") // Unmap the client while we're resizing it. QSignalSpy hiddenSpy(client->qobject.get(), &win::window_qobject::windowHidden); QVERIFY(hiddenSpy.isValid()); - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); + QVERIFY(hiddenSpy.wait()); QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); QVERIFY(!setup.base->mod.space->move_resize_window); @@ -1099,12 +1089,9 @@ TEST_CASE("move resize window", "[win]") SECTION("set fullscreen while moving") { // Ensure we disable moving event when setFullScreen is triggered - using namespace Wrapland::Client; - - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(500, 800), Qt::blue); @@ -1112,7 +1099,8 @@ TEST_CASE("move resize window", "[win]") QSignalSpy fullscreen_spy(client->qobject.get(), &win::window_qobject::fullScreenChanged); QVERIFY(fullscreen_spy.isValid()); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); @@ -1123,8 +1111,8 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 2); auto cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::fullscreen)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::fullscreen)); QCOMPARE(cfgdata.size, QSize(500, 800)); @@ -1136,7 +1124,7 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(configureRequestedSpy.count(), 3); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::fullscreen)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::fullscreen)); QCOMPARE(cfgdata.size, get_output(0)->geometry().size()); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -1158,12 +1146,9 @@ TEST_CASE("move resize window", "[win]") SECTION("set maximize while moving") { // Ensure we disable moving event when changeMaximize is triggered - using namespace Wrapland::Client; - - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // let's render diff --git a/tests/integration/no_crash_cancel_animation.cpp b/tests/integration/no_crash_cancel_animation.cpp index 29b6d25cc7..1c7d764a59 100644 --- a/tests/integration/no_crash_cancel_animation.cpp +++ b/tests/integration/no_crash_cancel_animation.cpp @@ -37,8 +37,6 @@ TEST_CASE("no crash cancel animation", "[render]") setup.base->mod.render->effects->loader->effectLoaded(effect, "crashy"); QVERIFY(setup.base->mod.render->effects->isEffectLoaded(QStringLiteral("crashy"))); - using namespace Wrapland::Client; - // create a window auto surface = std::unique_ptr(create_surface()); QVERIFY(surface); diff --git a/tests/integration/no_crash_cursor_physical_size_empty.cpp b/tests/integration/no_crash_cursor_physical_size_empty.cpp index a6f71578b9..27197ae793 100644 --- a/tests/integration/no_crash_cursor_physical_size_empty.cpp +++ b/tests/integration/no_crash_cursor_physical_size_empty.cpp @@ -14,8 +14,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -41,8 +39,8 @@ TEST_CASE("no crash cursor physical size empty", "[win]") { // This test ensures that there is no endless recursion if the cursor theme cannot be // created a reason for creation failure could be physical size not existing see BUG: 390314 - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); get_client().interfaces.xdg_decoration->getToplevelDecoration(shellSurface.get(), shellSurface.get()); diff --git a/tests/integration/no_crash_no_border.cpp b/tests/integration/no_crash_no_border.cpp index 3c42db3b1e..d9f32f9714 100644 --- a/tests/integration/no_crash_no_border.cpp +++ b/tests/integration/no_crash_no_border.cpp @@ -17,7 +17,6 @@ namespace como::detail::test TEST_CASE("no crash no border", "[win]") { // Create a window and ensure that this doesn't crash. - using namespace Wrapland::Client; // this test needs to enforce OpenGL compositing to get into the crashy condition qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2")); @@ -39,22 +38,21 @@ TEST_CASE("no crash no border", "[win]") setup_wayland_connection(global_selection::xdg_decoration); cursor()->set_pos(QPoint(640, 512)); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); QVERIFY(shellSurface); auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration(shellSurface.get(), shellSurface.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decoSpy.isValid()); - deco->setMode(XdgDecoration::Mode::ServerSide); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(surface, shellSurface); // Without server-side decoration available the mode set by the compositor will be client-side. - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); // let's render auto c = render_and_wait_for_shown(surface, QSize(500, 50), Qt::blue); diff --git a/tests/integration/no_crash_reinitialize_compositor.cpp b/tests/integration/no_crash_reinitialize_compositor.cpp index dd5eac242e..4b703e4adf 100644 --- a/tests/integration/no_crash_reinitialize_compositor.cpp +++ b/tests/integration/no_crash_reinitialize_compositor.cpp @@ -18,8 +18,6 @@ TEST_CASE("no crash reinit compositor", "[render]") // This test verifies that KWin doesn't crash when the compositor settings have been changed // while a scripted effect animates the disappearing of a window. - using namespace Wrapland::Client; - qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); qputenv("COMO_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1")); qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2")); @@ -53,9 +51,9 @@ TEST_CASE("no crash reinit compositor", "[render]") // Create the test client. setup_wayland_connection(); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); diff --git a/tests/integration/no_crash_useractions_menu.cpp b/tests/integration/no_crash_useractions_menu.cpp index af8912f762..c654d746fe 100644 --- a/tests/integration/no_crash_useractions_menu.cpp +++ b/tests/integration/no_crash_useractions_menu.cpp @@ -15,8 +15,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -35,12 +33,12 @@ TEST_CASE("no crash useractions menu", "[win]") setup_wayland_connection(); cursor()->set_pos(QPoint(1280, 512)); - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); - QVERIFY(surface1); - QVERIFY(shellSurface1); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(surface); + QVERIFY(shellSurface); - auto client = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); setup.base->mod.space->user_actions_menu->show(QRect(), client); diff --git a/tests/integration/no_global_shortcuts.cpp b/tests/integration/no_global_shortcuts.cpp index 304ae90ff3..88dd820ffc 100644 --- a/tests/integration/no_global_shortcuts.cpp +++ b/tests/integration/no_global_shortcuts.cpp @@ -12,16 +12,17 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - -static const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.NoGlobalShortcuts"); -static const QString s_path = QStringLiteral("/Test"); -static const QStringList trigger - = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; +namespace como::detail::test::no_global_shortcuts +{ namespace { +const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.NoGlobalShortcuts"); +const QString s_path = QStringLiteral("/Test"); +const QStringList trigger + = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; + class Target : public QObject { Q_OBJECT @@ -59,9 +60,6 @@ void Target::shortcut() } -namespace como::detail::test -{ - TEST_CASE("no global shortcuts", "[input]") { qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1"); diff --git a/tests/integration/opengl_shadow.cpp b/tests/integration/opengl_shadow.cpp index 8e4a497a51..382104c5e9 100644 --- a/tests/integration/opengl_shadow.cpp +++ b/tests/integration/opengl_shadow.cpp @@ -20,9 +20,7 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - -namespace como::detail::test +namespace como::detail::test::opengl_shadow { namespace @@ -545,8 +543,11 @@ TEST_CASE("opengl shadow", "[render]") setup_wayland_connection(global_selection::shadow); // Create a surface. - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto* client = render_and_wait_for_shown(surface, QSize(512, 512), Qt::blue); QVERIFY(client); QVERIFY(!win::decoration(client)); @@ -567,20 +568,18 @@ TEST_CASE("opengl shadow", "[render]") auto shmPool = get_client().interfaces.shm.get(); - Buffer::Ptr bufferTop - = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128, 0, 1, 128))); + auto bufferTop = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128, 0, 1, 128))); clientShadow->attachTop(bufferTop); - Buffer::Ptr bufferRight + auto bufferRight = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128 + 1, 128, 128, 1))); clientShadow->attachRight(bufferRight); - Buffer::Ptr bufferBottom + auto bufferBottom = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128, 128 + 1, 1, 128))); clientShadow->attachBottom(bufferBottom); - Buffer::Ptr bufferLeft - = shmPool->createBuffer(referenceShadowTexture.copy(QRect(0, 128, 128, 1))); + auto bufferLeft = shmPool->createBuffer(referenceShadowTexture.copy(QRect(0, 128, 128, 1))); clientShadow->attachLeft(bufferLeft); clientShadow->setOffsets(QMarginsF(128, 128, 128, 128)); @@ -588,13 +587,13 @@ TEST_CASE("opengl shadow", "[render]") QSignalSpy commit_spy(client->surface, &Wrapland::Server::Surface::committed); QVERIFY(commit_spy.isValid()); clientShadow->commit(); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(commit_spy.wait()); // Check that we got right shadow from the client. - QPointer shadowIface = client->surface->state().shadow; + auto shadowIface = client->surface->state().shadow; QVERIFY(client->surface->state().updates & Wrapland::Server::surface_change::shadow); - QVERIFY(!shadowIface.isNull()); + QVERIFY(shadowIface); QCOMPARE(shadowIface->offset().left(), 128.0); QCOMPARE(shadowIface->offset().top(), 128.0); QCOMPARE(shadowIface->offset().right(), 128.0); @@ -645,13 +644,15 @@ TEST_CASE("opengl shadow", "[render]") SECTION("distribute huge corner tiles") { // this test verifies that huge corner tiles are distributed correctly - setup_wayland_connection(global_selection::shadow); // Create a surface. - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - auto* client = render_and_wait_for_shown(surface, QSize(64, 64), Qt::blue); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + + auto client = render_and_wait_for_shown(surface, QSize(64, 64), Qt::blue); QVERIFY(client); QVERIFY(!win::decoration(client)); @@ -665,10 +666,10 @@ TEST_CASE("opengl shadow", "[render]") auto shmPool = get_client().interfaces.shm.get(); - Buffer::Ptr bufferTopLeft = shmPool->createBuffer(referenceTileTexture); + auto bufferTopLeft = shmPool->createBuffer(referenceTileTexture); clientShadow->attachTopLeft(bufferTopLeft); - Buffer::Ptr bufferTopRight = shmPool->createBuffer(referenceTileTexture); + auto bufferTopRight = shmPool->createBuffer(referenceTileTexture); clientShadow->attachTopRight(bufferTopRight); clientShadow->setOffsets(QMarginsF(256, 256, 256, 0)); @@ -676,12 +677,12 @@ TEST_CASE("opengl shadow", "[render]") QSignalSpy commit_spy(client->surface, &Wrapland::Server::Surface::committed); QVERIFY(commit_spy.isValid()); clientShadow->commit(); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(commit_spy.wait()); // Check that we got right shadow from the client. - QPointer shadowIface = client->surface->state().shadow; - QVERIFY(!shadowIface.isNull()); + auto shadowIface = client->surface->state().shadow; + QVERIFY(shadowIface); QCOMPARE(shadowIface->offset().left(), 256.0); QCOMPARE(shadowIface->offset().top(), 256.0); QCOMPARE(shadowIface->offset().right(), 256.0); diff --git a/tests/integration/placement.cpp b/tests/integration/placement.cpp index c8c1f6d1aa..fe9add40db 100644 --- a/tests/integration/placement.cpp +++ b/tests/integration/placement.cpp @@ -15,8 +15,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -77,10 +75,10 @@ TEST_CASE("placement", "[win]") // create a new window rc.surface = create_surface(); rc.toplevel = create_xdg_shell_toplevel(rc.surface, CreationSetup::CreateOnly); - QSignalSpy configSpy(rc.toplevel.get(), &XdgShellToplevel::configured); + QSignalSpy configSpy(rc.toplevel.get(), &Wrapland::Client::XdgShellToplevel::configured); assert(configSpy.isValid()); - rc.surface->commit(Surface::CommitFlag::None); + rc.surface->commit(Wrapland::Client::Surface::CommitFlag::None); configSpy.wait(); auto cfgdata = rc.toplevel->get_configure_data(); @@ -152,14 +150,14 @@ TEST_CASE("placement", "[win]") setPlacementPolicy(win::placement::maximizing); // add a top panel - std::unique_ptr panelSurface(create_surface()); - std::unique_ptr panelShellSurface(create_xdg_shell_toplevel(panelSurface)); + auto panelSurface = create_surface(); + auto panelShellSurface = create_xdg_shell_toplevel(panelSurface); QVERIFY(panelSurface); QVERIFY(panelShellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( get_client().interfaces.plasma_shell->createSurface(panelSurface.get())); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); plasmaSurface->setPosition(QPoint(0, 0)); render_and_wait_for_shown(panelSurface, QSize(1280, 20), Qt::blue); @@ -168,7 +166,8 @@ TEST_CASE("placement", "[win]") for (int i = 0; i < 4; i++) { placements.push_back(createAndPlaceWindow(QSize(600, 500))); auto const& placement = placements.back(); - QVERIFY(placement.initiallyConfiguredStates & xdg_shell_state::maximized); + QVERIFY(placement.initiallyConfiguredStates + & Wrapland::Client::xdg_shell_state::maximized); QCOMPARE(placement.initiallyConfiguredSize, QSize(1280, 1024 - 20)); // under the panel @@ -181,13 +180,14 @@ TEST_CASE("placement", "[win]") setPlacementPolicy(win::placement::maximizing); // add a top panel - std::unique_ptr panelSurface(create_surface()); - std::unique_ptr panelShellSurface(create_xdg_shell_toplevel(panelSurface)); + auto panelSurface = create_surface(); + auto panelShellSurface = create_xdg_shell_toplevel(panelSurface); QVERIFY(panelSurface); QVERIFY(panelShellSurface); - std::unique_ptr plasmaSurface( + + std::unique_ptr plasmaSurface( get_client().interfaces.plasma_shell->createSurface(panelSurface.get())); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); plasmaSurface->setPosition(QPoint(0, 0)); render_and_wait_for_shown(panelSurface, QSize(1280, 20), Qt::blue); @@ -198,8 +198,9 @@ TEST_CASE("placement", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); shellSurface->setFullscreen(true); - QSignalSpy configSpy(shellSurface.get(), &XdgShellToplevel::configured); - surface->commit(Surface::CommitFlag::None); + QSignalSpy configSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configSpy.wait(); auto cfgdata = shellSurface->get_configure_data(); @@ -209,7 +210,7 @@ TEST_CASE("placement", "[win]") auto c = render_and_wait_for_shown(surface, initiallyConfiguredSize, Qt::red); - QVERIFY(initiallyConfiguredStates & xdg_shell_state::fullscreen); + QVERIFY(initiallyConfiguredStates & Wrapland::Client::xdg_shell_state::fullscreen); QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024)); QCOMPARE(c->geo.frame, QRect(0, 0, 1280, 1024)); } @@ -224,8 +225,8 @@ TEST_CASE("placement", "[win]") group.sync(); win::space_reconfigure(*setup.base->mod.space); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::red); QVERIFY(client); QCOMPARE(client->geo.frame, QRect(590, 487, 100, 50)); @@ -246,8 +247,8 @@ TEST_CASE("placement", "[win]") cursor()->set_pos(QPoint(200, 300)); QCOMPARE(cursor()->pos(), QPoint(200, 300)); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::red); QVERIFY(client); QCOMPARE(client->geo.frame, QRect(151, 276, 100, 50)); @@ -265,21 +266,21 @@ TEST_CASE("placement", "[win]") group.sync(); win::space_reconfigure(*setup.base->mod.space); - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); auto client1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::red); QVERIFY(client1); QCOMPARE(client1->geo.size(), QSize(100, 50)); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto surface2 = create_surface(); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); auto client2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::blue); QVERIFY(client2); QVERIFY(client2->geo.pos() != client1->geo.pos()); QCOMPARE(client2->geo.size(), QSize(100, 50)); - std::unique_ptr surface3(create_surface()); - std::unique_ptr shellSurface3(create_xdg_shell_toplevel(surface3)); + auto surface3 = create_surface(); + auto shellSurface3 = create_xdg_shell_toplevel(surface3); auto client3 = render_and_wait_for_shown(surface3, QSize(100, 50), Qt::green); QVERIFY(client3); QVERIFY(client3->geo.pos() != client1->geo.pos()); diff --git a/tests/integration/plasma_surface.cpp b/tests/integration/plasma_surface.cpp index 3ba5fcd3b4..c184241f7e 100644 --- a/tests/integration/plasma_surface.cpp +++ b/tests/integration/plasma_surface.cpp @@ -15,8 +15,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -39,24 +37,25 @@ TEST_CASE("plasma surface", "[win]") // this test verifies that a XdgShellClient is set on all subspaces when the role changes struct data { - PlasmaShellSurface::Role role; + Wrapland::Client::PlasmaShellSurface::Role role; bool expected_on_all_subspaces; }; - auto test_data = GENERATE(data{PlasmaShellSurface::Role::Desktop, true}, - data{PlasmaShellSurface::Role::Panel, true}, - data{PlasmaShellSurface::Role::OnScreenDisplay, true}, - data{PlasmaShellSurface::Role::Normal, false}, - data{PlasmaShellSurface::Role::Notification, true}, - data{PlasmaShellSurface::Role::ToolTip, true}, - data{PlasmaShellSurface::Role::CriticalNotification, true}, - data{PlasmaShellSurface::Role::AppletPopup, true}); + auto test_data + = GENERATE(data{Wrapland::Client::PlasmaShellSurface::Role::Desktop, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::Panel, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::OnScreenDisplay, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::Normal, false}, + data{Wrapland::Client::PlasmaShellSurface::Role::Notification, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::ToolTip, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::CriticalNotification, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::AppletPopup, true}); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); @@ -77,13 +76,13 @@ TEST_CASE("plasma surface", "[win]") // let's create a second window where we init a little bit different // first creating the PlasmaSurface then the Shell Surface - std::unique_ptr surface2(create_surface()); + auto surface2 = create_surface(); QVERIFY(surface2); - std::unique_ptr plasmaSurface2( + std::unique_ptr plasmaSurface2( plasma_shell->createSurface(surface2.get())); QVERIFY(plasmaSurface2); plasmaSurface2->setRole(test_data.role); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(shellSurface2); auto c2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::blue); @@ -98,26 +97,26 @@ TEST_CASE("plasma surface", "[win]") // this test verifies that some surface roles don't get focus struct data { - PlasmaShellSurface::Role role; + Wrapland::Client::PlasmaShellSurface::Role role; bool wants_input; bool active; }; - auto test_data - = GENERATE(data{PlasmaShellSurface::Role::Desktop, true, true}, - data{PlasmaShellSurface::Role::Panel, true, false}, - data{PlasmaShellSurface::Role::OnScreenDisplay, false, false}, - data{PlasmaShellSurface::Role::Normal, true, true}, - data{PlasmaShellSurface::Role::Notification, false, false}, - data{PlasmaShellSurface::Role::ToolTip, false, false}, - data{PlasmaShellSurface::Role::CriticalNotification, false, false}, - data{PlasmaShellSurface::Role::AppletPopup, true, true}); - - std::unique_ptr surface(create_surface()); + auto test_data = GENERATE( + data{Wrapland::Client::PlasmaShellSurface::Role::Desktop, true, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::Panel, true, false}, + data{Wrapland::Client::PlasmaShellSurface::Role::OnScreenDisplay, false, false}, + data{Wrapland::Client::PlasmaShellSurface::Role::Normal, true, true}, + data{Wrapland::Client::PlasmaShellSurface::Role::Notification, false, false}, + data{Wrapland::Client::PlasmaShellSurface::Role::ToolTip, false, false}, + data{Wrapland::Client::PlasmaShellSurface::Role::CriticalNotification, false, false}, + data{Wrapland::Client::PlasmaShellSurface::Role::AppletPopup, true, true}); + + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); plasmaSurface->setRole(test_data.role); @@ -132,14 +131,14 @@ TEST_CASE("plasma surface", "[win]") SECTION("desktop is opaque") { - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::Desktop); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Desktop); // now render to map the window auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -176,16 +175,17 @@ TEST_CASE("plasma surface", "[win]") data{{1250, 0, 30, 800}, {1080, 0, 200, 300}, {1279, 100}}, data{{1250, 200, 30, 824}, {1080, 0, 200, 300}, {1279, 250}}); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); plasmaSurface->setPosition(test_data.panel_geo.topLeft()); - plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsCanCover); + plasmaSurface->setPanelBehavior( + Wrapland::Client::PlasmaShellSurface::PanelBehavior::WindowsCanCover); // now render and map the window auto panel = render_and_wait_for_shown(surface, test_data.panel_geo.size(), Qt::blue); @@ -201,9 +201,9 @@ TEST_CASE("plasma surface", "[win]") QCOMPARE(win::get_layer(*panel), win::layer::above); // create a Window - std::unique_ptr surface2(create_surface()); + auto surface2 = create_surface(); QVERIFY(surface2); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(shellSurface2); auto c = render_and_wait_for_shown(surface2, test_data.window_geo.size(), Qt::red); @@ -235,14 +235,14 @@ TEST_CASE("plasma surface", "[win]") SECTION("osd placement") { - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::OnScreenDisplay); // now render and map the window auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -276,16 +276,16 @@ TEST_CASE("plasma surface", "[win]") SECTION("osd placement manual position") { - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::OnScreenDisplay); plasmaSurface->setPosition(QPoint(50, 70)); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); // now render and map the window @@ -301,37 +301,38 @@ TEST_CASE("plasma surface", "[win]") SECTION("panel type has strut") { struct data { - PlasmaShellSurface::PanelBehavior panel_behavior; + Wrapland::Client::PlasmaShellSurface::PanelBehavior panel_behavior; bool expected_strut; QRect expected_max_area; win::layer expected_layer; }; - auto test_data = GENERATE(data{PlasmaShellSurface::PanelBehavior::AlwaysVisible, - true, - {0, 50, 1280, 974}, - win::layer::above}, - data{PlasmaShellSurface::PanelBehavior::AutoHide, - false, - {0, 0, 1280, 1024}, - win::layer::above}, - data{PlasmaShellSurface::PanelBehavior::WindowsCanCover, - false, - {0, 0, 1280, 1024}, - win::layer::above}, - data{PlasmaShellSurface::PanelBehavior::WindowsGoBelow, - false, - {0, 0, 1280, 1024}, - win::layer::above}); - - std::unique_ptr surface(create_surface()); + auto test_data + = GENERATE(data{Wrapland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible, + true, + {0, 50, 1280, 974}, + win::layer::above}, + data{Wrapland::Client::PlasmaShellSurface::PanelBehavior::AutoHide, + false, + {0, 0, 1280, 1024}, + win::layer::above}, + data{Wrapland::Client::PlasmaShellSurface::PanelBehavior::WindowsCanCover, + false, + {0, 0, 1280, 1024}, + win::layer::above}, + data{Wrapland::Client::PlasmaShellSurface::PanelBehavior::WindowsGoBelow, + false, + {0, 0, 1280, 1024}, + win::layer::above}); + + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); plasmaSurface->setPosition(QPoint(0, 0)); plasmaSurface->setPanelBehavior(test_data.panel_behavior); @@ -353,14 +354,14 @@ TEST_CASE("plasma surface", "[win]") { auto activate = GENERATE(true, false); - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); plasmaSurface->setPanelTakesFocus(activate); auto panel = render_and_wait_for_shown(surface, QSize(100, 200), Qt::blue); @@ -388,12 +389,11 @@ TEST_CASE("plasma surface", "[win]") auto surface = create_surface(); QVERIFY(surface); - auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); - auto plasmaSurface - = std::unique_ptr(plasma_shell->createSurface(surface.get())); + auto plasmaSurface = std::unique_ptr( + plasma_shell->createSurface(surface.get())); QVERIFY(plasmaSurface); plasmaSurface->request_open_under_cursor(); diff --git a/tests/integration/plasma_window.cpp b/tests/integration/plasma_window.cpp index 93e598d23c..ef122dd5f7 100644 --- a/tests/integration/plasma_window.cpp +++ b/tests/integration/plasma_window.cpp @@ -16,9 +16,7 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - -namespace como::detail::test +namespace como::detail::test::plasma_window { namespace @@ -213,7 +211,7 @@ TEST_CASE("plasma window", "[win]") // this test verifies that a PlasmaWindow gets unmapped on Client side when an X11 client is // destroyed QSignalSpy plasmaWindowCreatedSpy(window_management, - &PlasmaWindowManagement::windowCreated); + &Wrapland::Client::PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // create an xcb window @@ -288,7 +286,8 @@ TEST_CASE("plasma window", "[win]") QVERIFY(res_name_spy.wait()); QCOMPARE(pw->resource_name(), "org.kwinft.wm_class.name2"); - QSignalSpy unmappedSpy(window_management->windows().constFirst(), &PlasmaWindow::unmapped); + QSignalSpy unmappedSpy(window_management->windows().constFirst(), + &Wrapland::Client::PlasmaWindow::unmapped); QVERIFY(unmappedSpy.isValid()); QSignalSpy destroyedSpy(window_management->windows().constFirst(), &QObject::destroyed); QVERIFY(destroyedSpy.isValid()); @@ -311,7 +310,7 @@ TEST_CASE("plasma window", "[win]") { // this test verifies that an internal window is not added as a PlasmaWindow to the client QSignalSpy plasmaWindowCreatedSpy(window_management, - &PlasmaWindowManagement::windowCreated); + &Wrapland::Client::PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); @@ -324,13 +323,12 @@ TEST_CASE("plasma window", "[win]") { // this test verifies that for a popup window no PlasmaWindow is sent to the client QSignalSpy plasmaWindowCreatedSpy(window_management, - &PlasmaWindowManagement::windowCreated); + &Wrapland::Client::PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // first create the parent window - std::unique_ptr parentSurface(create_surface()); - std::unique_ptr parentShellSurface( - create_xdg_shell_toplevel(parentSurface)); + auto parentSurface = create_surface(); + auto parentShellSurface = create_xdg_shell_toplevel(parentSurface); auto parentClient = render_and_wait_for_shown(parentSurface, QSize(100, 50), Qt::blue); QVERIFY(parentClient); QVERIFY(plasmaWindowCreatedSpy.wait()); @@ -343,9 +341,8 @@ TEST_CASE("plasma window", "[win]") pos_data.anchor.edge = Qt::BottomEdge | Qt::RightEdge; pos_data.gravity = pos_data.anchor.edge; - std::unique_ptr popupSurface(create_surface()); - std::unique_ptr popupShellSurface( - create_xdg_shell_popup(popupSurface, parentShellSurface, pos_data)); + auto popupSurface = create_surface(); + auto popupShellSurface = create_xdg_shell_popup(popupSurface, parentShellSurface, pos_data); auto popupClient = render_and_wait_for_shown(popupSurface, pos_data.size, Qt::blue); QVERIFY(popupClient); QVERIFY(!plasmaWindowCreatedSpy.wait(100)); @@ -362,7 +359,7 @@ TEST_CASE("plasma window", "[win]") { // this test verifies that lock screen windows are not exposed to PlasmaWindow QSignalSpy plasmaWindowCreatedSpy(window_management, - &PlasmaWindowManagement::windowCreated); + &Wrapland::Client::PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // this time we use a QSignalSpy on XdgShellClient as it'a a little bit more complex setup @@ -407,7 +404,7 @@ TEST_CASE("plasma window", "[win]") break; } QVERIFY(lockStateChangedSpy.wait()); - QVERIFY(!base::wayland::is_screen_locked(setup.base)); + QVERIFY(!win::wayland::screen_lock_is_locked(setup.base->mod.space)); } SECTION("destroyed but not unmapped") @@ -415,19 +412,19 @@ TEST_CASE("plasma window", "[win]") // this test verifies that also when a ShellSurface gets destroyed without a prior unmap // the PlasmaWindow gets destroyed on Client side QSignalSpy plasmaWindowCreatedSpy(window_management, - &PlasmaWindowManagement::windowCreated); + &Wrapland::Client::PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // first create the parent window - std::unique_ptr parentSurface(create_surface()); - std::unique_ptr parentShellSurface( - create_xdg_shell_toplevel(parentSurface)); + auto parentSurface = create_surface(); + auto parentShellSurface = create_xdg_shell_toplevel(parentSurface); // map that window render(parentSurface, QSize(100, 50), Qt::blue); // this should create a plasma window QVERIFY(plasmaWindowCreatedSpy.wait()); QCOMPARE(plasmaWindowCreatedSpy.count(), 1); - auto window = plasmaWindowCreatedSpy.first().first().value(); + auto window + = plasmaWindowCreatedSpy.first().first().value(); QVERIFY(window); QSignalSpy destroyedSpy(window, &QObject::destroyed); QVERIFY(destroyedSpy.isValid()); diff --git a/tests/integration/pointer_constraints.cpp b/tests/integration/pointer_constraints.cpp index 0dc6dc06d7..f95c9949bb 100644 --- a/tests/integration/pointer_constraints.cpp +++ b/tests/integration/pointer_constraints.cpp @@ -20,8 +20,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -60,15 +58,20 @@ TEST_CASE("pointer constraints", "[input]") data{&QRect::topLeft, {-1, -1}}, data{&QRect::topRight, {1, -1}}); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr confinedPointer( + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr confinedPointer( get_client().interfaces.pointer_constraints->confinePointer( - surface.get(), pointer.get(), nullptr, PointerConstraints::LifeTime::OneShot)); - QSignalSpy confinedSpy(confinedPointer.get(), &ConfinedPointer::confined); + surface.get(), + pointer.get(), + nullptr, + Wrapland::Client::PointerConstraints::LifeTime::OneShot)); + QSignalSpy confinedSpy(confinedPointer.get(), &Wrapland::Client::ConfinedPointer::confined); QVERIFY(confinedSpy.isValid()); - QSignalSpy unconfinedSpy(confinedPointer.get(), &ConfinedPointer::unconfined); + QSignalSpy unconfinedSpy(confinedPointer.get(), + &Wrapland::Client::ConfinedPointer::unconfined); QVERIFY(unconfinedSpy.isValid()); // now map the window @@ -152,10 +155,15 @@ TEST_CASE("pointer constraints", "[input]") // reconfine pointer (this time with persistent life time) confinedPointer.reset(get_client().interfaces.pointer_constraints->confinePointer( - surface.get(), pointer.get(), nullptr, PointerConstraints::LifeTime::Persistent)); - QSignalSpy confinedSpy2(confinedPointer.get(), &ConfinedPointer::confined); + surface.get(), + pointer.get(), + nullptr, + Wrapland::Client::PointerConstraints::LifeTime::Persistent)); + QSignalSpy confinedSpy2(confinedPointer.get(), + &Wrapland::Client::ConfinedPointer::confined); QVERIFY(confinedSpy2.isValid()); - QSignalSpy unconfinedSpy2(confinedPointer.get(), &ConfinedPointer::unconfined); + QSignalSpy unconfinedSpy2(confinedPointer.get(), + &Wrapland::Client::ConfinedPointer::unconfined); QVERIFY(unconfinedSpy2.isValid()); // activate it again, this confines again @@ -181,8 +189,8 @@ TEST_CASE("pointer constraints", "[input]") QCOMPARE(setup.base->mod.space->input->pointer->isConstrained(), true); // create a second window and move it above our constrained window - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto surface2 = create_surface(); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); auto c2 = render_and_wait_for_shown(surface2, QSize(1280, 1024), Qt::blue); QVERIFY(c2); QVERIFY(unconfinedSpy2.wait()); @@ -194,12 +202,12 @@ TEST_CASE("pointer constraints", "[input]") // let's set a region which results in unconfined auto r = get_client().interfaces.compositor->createRegion(QRegion(2, 2, 3, 3)); confinedPointer->setRegion(r.get()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(unconfinedSpy2.wait()); QCOMPARE(setup.base->mod.space->input->pointer->isConstrained(), false); // and set a full region again, that should confine confinedPointer->setRegion(nullptr); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(confinedSpy2.wait()); QCOMPARE(setup.base->mod.space->input->pointer->isConstrained(), true); @@ -220,8 +228,12 @@ TEST_CASE("pointer constraints", "[input]") // confine again confinedPointer.reset(get_client().interfaces.pointer_constraints->confinePointer( - surface.get(), pointer.get(), nullptr, PointerConstraints::LifeTime::Persistent)); - QSignalSpy confinedSpy3(confinedPointer.get(), &ConfinedPointer::confined); + surface.get(), + pointer.get(), + nullptr, + Wrapland::Client::PointerConstraints::LifeTime::Persistent)); + QSignalSpy confinedSpy3(confinedPointer.get(), + &Wrapland::Client::ConfinedPointer::confined); QVERIFY(confinedSpy3.isValid()); QVERIFY(confinedSpy3.wait()); QCOMPARE(setup.base->mod.space->input->pointer->isConstrained(), true); @@ -239,18 +251,22 @@ TEST_CASE("pointer constraints", "[input]") // simple interaction test to verify that the pointer gets locked // the various ways to unlock are not tested as that's already verified by // testConfinedPointer - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(surface); QVERIFY(shellSurface); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr lockedPointer( + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr lockedPointer( get_client().interfaces.pointer_constraints->lockPointer( - surface.get(), pointer.get(), nullptr, PointerConstraints::LifeTime::OneShot)); - QSignalSpy lockedSpy(lockedPointer.get(), &LockedPointer::locked); + surface.get(), + pointer.get(), + nullptr, + Wrapland::Client::PointerConstraints::LifeTime::OneShot)); + QSignalSpy lockedSpy(lockedPointer.get(), &Wrapland::Client::LockedPointer::locked); QVERIFY(lockedSpy.isValid()); - QSignalSpy unlockedSpy(lockedPointer.get(), &LockedPointer::unlocked); + QSignalSpy unlockedSpy(lockedPointer.get(), &Wrapland::Client::LockedPointer::unlocked); QVERIFY(unlockedSpy.isValid()); // now map the window @@ -280,8 +296,11 @@ TEST_CASE("pointer constraints", "[input]") QCOMPARE(cursor()->pos(), c->geo.frame.center() + QPoint(1, 1)); lockedPointer.reset(get_client().interfaces.pointer_constraints->lockPointer( - surface.get(), pointer.get(), nullptr, PointerConstraints::LifeTime::Persistent)); - QSignalSpy lockedSpy2(lockedPointer.get(), &LockedPointer::locked); + surface.get(), + pointer.get(), + nullptr, + Wrapland::Client::PointerConstraints::LifeTime::Persistent)); + QSignalSpy lockedSpy2(lockedPointer.get(), &Wrapland::Client::LockedPointer::locked); QVERIFY(lockedSpy2.isValid()); // activate the client again, this should lock again @@ -319,15 +338,19 @@ TEST_CASE("pointer constraints", "[input]") { // test case which verifies that the pointer gets unlocked when the window for it gets // closed - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr lockedPointer( + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr lockedPointer( get_client().interfaces.pointer_constraints->lockPointer( - surface.get(), pointer.get(), nullptr, PointerConstraints::LifeTime::OneShot)); - QSignalSpy lockedSpy(lockedPointer.get(), &LockedPointer::locked); + surface.get(), + pointer.get(), + nullptr, + Wrapland::Client::PointerConstraints::LifeTime::OneShot)); + QSignalSpy lockedSpy(lockedPointer.get(), &Wrapland::Client::LockedPointer::locked); QVERIFY(lockedSpy.isValid()); - QSignalSpy unlockedSpy(lockedPointer.get(), &LockedPointer::unlocked); + QSignalSpy unlockedSpy(lockedPointer.get(), &Wrapland::Client::LockedPointer::unlocked); QVERIFY(unlockedSpy.isValid()); // now map the window diff --git a/tests/integration/pointer_input.cpp b/tests/integration/pointer_input.cpp index ce4b813268..727bde9086 100644 --- a/tests/integration/pointer_input.cpp +++ b/tests/integration/pointer_input.cpp @@ -23,7 +23,7 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -namespace como::detail::test +namespace como::detail::test::pointer_input { namespace @@ -124,14 +124,14 @@ TEST_CASE("pointer input", "[input]") SECTION("warping updates focus") { // this test verifies that warping the pointer creates pointer enter and leave events - using namespace Wrapland::Client; + // create pointer and signal spy for enter and leave signals auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(pointer, &Pointer::left); + QSignalSpy leftSpy(pointer, &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); // create a window @@ -175,14 +175,14 @@ TEST_CASE("pointer input", "[input]") SECTION("warping generates pointer moition") { // this test verifies that warping the pointer creates pointer motion events - using namespace Wrapland::Client; + // create pointer and signal spy for enter and motion auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy movedSpy(pointer, &Pointer::motion); + QSignalSpy movedSpy(pointer, &Wrapland::Client::Pointer::motion); QVERIFY(movedSpy.isValid()); // create a window @@ -214,13 +214,12 @@ TEST_CASE("pointer input", "[input]") { // this test verifies that pointer motion is handled correctly if // the pointer gets warped during processing of input events - using namespace Wrapland::Client; // create pointer auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy movedSpy(pointer, &Pointer::motion); + QSignalSpy movedSpy(pointer, &Wrapland::Client::Pointer::motion); QVERIFY(movedSpy.isValid()); // warp cursor into expected geometry @@ -264,7 +263,6 @@ TEST_CASE("pointer input", "[input]") { // This test verifies that a pointer enter event is generated when the cursor changes to // another screen due to removal of screen. - using namespace Wrapland::Client; // Ensure cursor is on second screen. cursor()->set_pos(1500, 300); @@ -273,7 +271,7 @@ TEST_CASE("pointer input", "[input]") auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); // Create a window. @@ -315,9 +313,6 @@ TEST_CASE("pointer input", "[input]") SECTION("modifier click unrestricted move") { // this test ensures that Alt+mouse button press triggers unrestricted move - - using namespace Wrapland::Client; - enum class key { meta, alt, @@ -351,7 +346,7 @@ TEST_CASE("pointer input", "[input]") auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); + QSignalSpy buttonSpy(pointer, &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); // first modify the config for this run @@ -374,10 +369,12 @@ TEST_CASE("pointer input", "[input]") QSignalSpy clientAddedSpy(setup.base->mod.space->qobject.get(), &space::qobject_t::wayland_window_added); QVERIFY(clientAddedSpy.isValid()); + auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + render(surface); QVERIFY(clientAddedSpy.wait()); auto window = get_wayland_window(setup.base->mod.space->stacking.active); @@ -420,12 +417,12 @@ TEST_CASE("pointer input", "[input]") SECTION("modifier click unrestricted move global shortcuts disabled") { // this test ensures that Alt+mouse button press triggers unrestricted move - using namespace Wrapland::Client; + // create pointer and signal spy for button events auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); + QSignalSpy buttonSpy(pointer, &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); // first modify the config for this run @@ -452,6 +449,7 @@ TEST_CASE("pointer input", "[input]") QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); + render(surface); QVERIFY(clientAddedSpy.wait()); auto window = get_wayland_window(setup.base->mod.space->stacking.active); @@ -483,9 +481,6 @@ TEST_CASE("pointer input", "[input]") { // this test verifies that mod+wheel performs a window operation and does not // pass the wheel to the window - - using namespace Wrapland::Client; - enum class key { meta, alt, @@ -515,7 +510,7 @@ TEST_CASE("pointer input", "[input]") auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy axisSpy(pointer, &Pointer::axisChanged); + QSignalSpy axisSpy(pointer, &Wrapland::Client::Pointer::axisChanged); QVERIFY(axisSpy.isValid()); // first modify the config for this run @@ -571,13 +566,12 @@ TEST_CASE("pointer input", "[input]") { // this test verifies that mod+wheel performs a window operation and does not // pass the wheel to the window - using namespace Wrapland::Client; // create pointer and signal spy for button events auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy axisSpy(pointer, &Pointer::axisChanged); + QSignalSpy axisSpy(pointer, &Wrapland::Client::Pointer::axisChanged); QVERIFY(axisSpy.isValid()); // first modify the config for this run @@ -627,12 +621,10 @@ TEST_CASE("pointer input", "[input]") SECTION("scroll action") { // this test verifies that scroll on inactive window performs a mouse action - using namespace Wrapland::Client; - auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy axisSpy(pointer, &Pointer::axisChanged); + QSignalSpy axisSpy(pointer, &Wrapland::Client::Pointer::axisChanged); QVERIFY(axisSpy.isValid()); // first modify the config for this run @@ -681,8 +673,6 @@ TEST_CASE("pointer input", "[input]") SECTION("focus follows mouse") { - using namespace Wrapland::Client; - // need to create a pointer, otherwise it doesn't accept focus auto pointer = seat->createPointer(seat); QVERIFY(pointer); @@ -784,8 +774,6 @@ TEST_CASE("pointer input", "[input]") { // This test performs the mouse button window action on an inactive window it should // activate the window and raise it. - using namespace Wrapland::Client; - auto button = GENERATE(BTN_LEFT, BTN_MIDDLE, BTN_RIGHT); // First modify the config for this run - disable FocusFollowsMouse. @@ -876,8 +864,6 @@ TEST_CASE("pointer input", "[input]") { // This test verifies the mouse action performed on an active window for all buttons it // should trigger a window raise depending on the click raise option. - using namespace Wrapland::Client; - auto click_raise = GENERATE(true, false); auto button = GENERATE(range(BTN_LEFT, BTN_JOYSTICK)); @@ -885,7 +871,7 @@ TEST_CASE("pointer input", "[input]") auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); + QSignalSpy buttonSpy(pointer, &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); // Adjust config for this run. @@ -980,13 +966,12 @@ TEST_CASE("pointer input", "[input]") { // This test verifies that the pointer image gets updated correctly from the client provided // data. - using namespace Wrapland::Client; // We need a pointer to get the enter event. auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); // Move cursor somewhere the new window won't open. @@ -1024,7 +1009,8 @@ TEST_CASE("pointer input", "[input]") // Create a cursor on the pointer. auto cursorSurface = create_surface(); QVERIFY(cursorSurface); - QSignalSpy cursorRenderedSpy(cursorSurface.get(), &Surface::frameRendered); + QSignalSpy cursorRenderedSpy(cursorSurface.get(), + &Wrapland::Client::Surface::frameRendered); QVERIFY(cursorRenderedSpy.isValid()); auto red = QImage(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); @@ -1091,15 +1077,14 @@ TEST_CASE("pointer input", "[input]") SECTION("effect override cursor image") { // This test verifies the effect cursor override handling. - using namespace Wrapland::Client; // We need a pointer to get the enter event and set a cursor. auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(pointer, &Pointer::left); + QSignalSpy leftSpy(pointer, &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); // Move cursor somewhere the new window won't open. @@ -1178,17 +1163,16 @@ TEST_CASE("pointer input", "[input]") // a button press outside the window should dismiss the popup // first create a parent surface - using namespace Wrapland::Client; auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(pointer, &Pointer::left); + QSignalSpy leftSpy(pointer, &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); - QSignalSpy buttonStateChangedSpy(pointer, &Pointer::buttonStateChanged); + QSignalSpy buttonStateChangedSpy(pointer, &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(buttonStateChangedSpy.isValid()); - QSignalSpy motionSpy(pointer, &Pointer::motion); + QSignalSpy motionSpy(pointer, &Wrapland::Client::Pointer::motion); QVERIFY(motionSpy.isValid()); cursor()->set_pos(800, 800); @@ -1239,7 +1223,8 @@ TEST_CASE("pointer input", "[input]") QVERIFY(popupSurface); auto popupShellSurface = create_xdg_shell_popup(popupSurface, shellSurface, pos_data); QVERIFY(popupShellSurface); - QSignalSpy popupDoneSpy(popupShellSurface.get(), &XdgShellPopup::popupDone); + QSignalSpy popupDoneSpy(popupShellSurface.get(), + &Wrapland::Client::XdgShellPopup::popupDone); QVERIFY(popupDoneSpy.isValid()); popupShellSurface->requestGrab(seat, 0); // FIXME: Serial. render(popupSurface, pos_data.size); @@ -1302,17 +1287,16 @@ TEST_CASE("pointer input", "[input]") // cancels the popup // first create a parent surface - using namespace Wrapland::Client; auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(pointer, &Pointer::left); + QSignalSpy leftSpy(pointer, &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); - QSignalSpy buttonStateChangedSpy(pointer, &Pointer::buttonStateChanged); + QSignalSpy buttonStateChangedSpy(pointer, &Wrapland::Client::Pointer::buttonStateChanged); QVERIFY(buttonStateChangedSpy.isValid()); - QSignalSpy motionSpy(pointer, &Pointer::motion); + QSignalSpy motionSpy(pointer, &Wrapland::Client::Pointer::motion); QVERIFY(motionSpy.isValid()); cursor()->set_pos(800, 800); @@ -1326,12 +1310,12 @@ TEST_CASE("pointer input", "[input]") auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( shellSurface.get(), shellSurface.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decoSpy.isValid()); - deco->setMode(XdgDecoration::Mode::ServerSide); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(surface, shellSurface); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); render(surface); QVERIFY(clientAddedSpy.wait()); @@ -1362,7 +1346,8 @@ TEST_CASE("pointer input", "[input]") QVERIFY(popupSurface); auto popupShellSurface = create_xdg_shell_popup(popupSurface, shellSurface, pos_data); QVERIFY(popupShellSurface); - QSignalSpy popupDoneSpy(popupShellSurface.get(), &XdgShellPopup::popupDone); + QSignalSpy popupDoneSpy(popupShellSurface.get(), + &Wrapland::Client::XdgShellPopup::popupDone); QVERIFY(popupDoneSpy.isValid()); popupShellSurface->requestGrab(seat, 0); // FIXME: Serial. render(popupSurface, pos_data.size); @@ -1397,13 +1382,12 @@ TEST_CASE("pointer input", "[input]") // see BUG: 372876 // first create a parent surface - using namespace Wrapland::Client; auto pointer = seat->createPointer(seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); - QSignalSpy enteredSpy(pointer, &Pointer::entered); + QSignalSpy enteredSpy(pointer, &Wrapland::Client::Pointer::entered); QVERIFY(enteredSpy.isValid()); - QSignalSpy leftSpy(pointer, &Pointer::left); + QSignalSpy leftSpy(pointer, &Wrapland::Client::Pointer::left); QVERIFY(leftSpy.isValid()); cursor()->set_pos(800, 800); @@ -1586,8 +1570,7 @@ TEST_CASE("pointer input", "[input]") win::mouse_cmd::unrestricted_resize); // create a test client - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); @@ -1655,8 +1638,7 @@ TEST_CASE("pointer input", "[input]") win::mouse_cmd::unrestricted_move); // create a test client - using namespace Wrapland::Client; - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); QVERIFY(surface); auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); diff --git a/tests/integration/qpainter_shadow.cpp b/tests/integration/qpainter_shadow.cpp index 0d4027dc57..4adb58c3ad 100644 --- a/tests/integration/qpainter_shadow.cpp +++ b/tests/integration/qpainter_shadow.cpp @@ -26,9 +26,7 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - -namespace como::detail::test +namespace como::detail::test::qpainter_shadow { namespace @@ -496,9 +494,8 @@ TEST_CASE("qpainter shadow", "[render]") setup_wayland_connection(global_selection::xdg_decoration); // Create a decorated client. - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); get_client().interfaces.xdg_decoration->getToplevelDecoration(shellSurface.get(), shellSurface.get()); init_xdg_shell_toplevel(surface, shellSurface); @@ -556,8 +553,8 @@ TEST_CASE("qpainter shadow", "[render]") setup_wayland_connection(global_selection::shadow); // Create a surface. - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(surface); QVERIFY(shellSurface); @@ -588,35 +585,35 @@ TEST_CASE("qpainter shadow", "[render]") auto shmPool = get_client().interfaces.shm.get(); - Buffer::Ptr bufferTopLeft + Wrapland::Client::Buffer::Ptr bufferTopLeft = shmPool->createBuffer(referenceShadowTexture.copy(QRect(0, 0, 128, 128))); clientShadow->attachTopLeft(bufferTopLeft); - Buffer::Ptr bufferTop + Wrapland::Client::Buffer::Ptr bufferTop = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128, 0, 1, 128))); clientShadow->attachTop(bufferTop); - Buffer::Ptr bufferTopRight + Wrapland::Client::Buffer::Ptr bufferTopRight = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128 + 1, 0, 128, 128))); clientShadow->attachTopRight(bufferTopRight); - Buffer::Ptr bufferRight + Wrapland::Client::Buffer::Ptr bufferRight = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128 + 1, 128, 128, 1))); clientShadow->attachRight(bufferRight); - Buffer::Ptr bufferBottomRight + Wrapland::Client::Buffer::Ptr bufferBottomRight = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128 + 1, 128 + 1, 128, 128))); clientShadow->attachBottomRight(bufferBottomRight); - Buffer::Ptr bufferBottom + Wrapland::Client::Buffer::Ptr bufferBottom = shmPool->createBuffer(referenceShadowTexture.copy(QRect(128, 128 + 1, 1, 128))); clientShadow->attachBottom(bufferBottom); - Buffer::Ptr bufferBottomLeft + Wrapland::Client::Buffer::Ptr bufferBottomLeft = shmPool->createBuffer(referenceShadowTexture.copy(QRect(0, 128 + 1, 128, 128))); clientShadow->attachBottomLeft(bufferBottomLeft); - Buffer::Ptr bufferLeft + Wrapland::Client::Buffer::Ptr bufferLeft = shmPool->createBuffer(referenceShadowTexture.copy(QRect(0, 128, 128, 1))); clientShadow->attachLeft(bufferLeft); @@ -626,7 +623,7 @@ TEST_CASE("qpainter shadow", "[render]") QSignalSpy committed_spy(client->surface, &Wrapland::Server::Surface::committed); QVERIFY(committed_spy.isValid()); clientShadow->commit(); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(committed_spy.wait()); QVERIFY(client->surface->state().updates & Wrapland::Server::surface_change::shadow); diff --git a/tests/integration/quick_tiling.cpp b/tests/integration/quick_tiling.cpp index 52472f3193..264f2ecac3 100644 --- a/tests/integration/quick_tiling.cpp +++ b/tests/integration/quick_tiling.cpp @@ -23,7 +23,7 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -namespace como::detail::test +namespace como::detail::test::quick_tiling { namespace @@ -77,8 +77,6 @@ TEST_CASE("quick tiling", "[win]") SECTION("quick tiling") { - using namespace Wrapland::Client; - struct data { win::quicktiles mode; QRect expected_geo; @@ -135,7 +133,8 @@ TEST_CASE("quick tiling", "[win]") QCOMPARE(c->geo.frame, QRect(0, 0, 100, 50)); QCOMPARE(c->control->quicktiling, win::quicktiles::none); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QSignalSpy quickTileChangedSpy(c->qobject.get(), &win::window_qobject::quicktiling_changed); QVERIFY(quickTileChangedSpy.isValid()); @@ -162,7 +161,9 @@ TEST_CASE("quick tiling", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, test_data.expected_geo.size()); - REQUIRE(cfgdata.states == (get_client_tiles(test_data.mode) | xdg_shell_state::activated)); + REQUIRE( + cfgdata.states + == (get_client_tiles(test_data.mode) | Wrapland::Client::xdg_shell_state::activated)); // attach a new image shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -191,8 +192,6 @@ TEST_CASE("quick tiling", "[win]") SECTION("quick maximizing") { - using namespace Wrapland::Client; - auto mode = GENERATE(win::quicktiles::maximize, win::quicktiles::none); auto surface = create_surface(); @@ -209,13 +208,16 @@ TEST_CASE("quick tiling", "[win]") QCOMPARE(c->maximizeMode(), win::maximize_mode::restore); // We have to receive a configure event upon becoming active. - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); auto cfgdata = shellSurface->get_configure_data(); - REQUIRE(cfgdata.states == xdg_shell_states(xdg_shell_state::activated)); + REQUIRE( + cfgdata.states + == Wrapland::Client::xdg_shell_states(Wrapland::Client::xdg_shell_state::activated)); QSignalSpy quickTileChangedSpy(c->qobject.get(), &win::window_qobject::quicktiling_changed); QVERIFY(quickTileChangedSpy.isValid()); @@ -242,9 +244,10 @@ TEST_CASE("quick tiling", "[win]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - REQUIRE(cfgdata.states - == xdg_shell_states(get_client_tiles(win::quicktiles::maximize) - | xdg_shell_state::activated)); + REQUIRE( + cfgdata.states + == Wrapland::Client::xdg_shell_states(get_client_tiles(win::quicktiles::maximize) + | Wrapland::Client::xdg_shell_state::activated)); // Attach a new image. shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -274,7 +277,9 @@ TEST_CASE("quick tiling", "[win]") cfgdata = shellSurface->get_configure_data(); REQUIRE(cfgdata.size == QSize(100, 50)); - REQUIRE(cfgdata.states == xdg_shell_states(xdg_shell_state::activated)); + REQUIRE( + cfgdata.states + == Wrapland::Client::xdg_shell_states(Wrapland::Client::xdg_shell_state::activated)); // render again shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -289,8 +294,6 @@ TEST_CASE("quick tiling", "[win]") SECTION("keyboard move") { - using namespace Wrapland::Client; - struct data { QPoint target; win::quicktiles expected_mode; @@ -356,8 +359,6 @@ TEST_CASE("quick tiling", "[win]") SECTION("pointer move") { - using namespace Wrapland::Client; - struct data { QPoint target; win::quicktiles expected_mode; @@ -378,9 +379,10 @@ TEST_CASE("quick tiling", "[win]") QVERIFY(shellSurface); // wait for the initial configure event - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); @@ -425,8 +427,6 @@ TEST_CASE("quick tiling", "[win]") { // test verifies that touch on decoration also allows quick tiling // see BUG: 390113 - using namespace Wrapland::Client; - struct data { QPoint target; win::quicktiles expected_mode; @@ -448,17 +448,18 @@ TEST_CASE("quick tiling", "[win]") auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( shellSurface.get(), shellSurface.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decoSpy.isValid()); - deco->setMode(XdgDecoration::Mode::ServerSide); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); init_xdg_shell_toplevel(surface, shellSurface); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); QCOMPARE(configureRequestedSpy.count(), 1); QVERIFY(configureRequestedSpy.last().first().toSize().isEmpty()); @@ -700,8 +701,6 @@ TEST_CASE("quick tiling", "[win]") SECTION("shortcut") { - using namespace Wrapland::Client; - struct data { std::vector shortcuts; win::quicktiles expected_mode; @@ -751,7 +750,8 @@ TEST_CASE("quick tiling", "[win]") QCOMPARE(c->control->quicktiling, win::quicktiles::none); // We have to receive a configure event when the client becomes active. - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); @@ -803,8 +803,6 @@ TEST_CASE("quick tiling", "[win]") SECTION("script") { - using namespace Wrapland::Client; - struct data { std::string action; win::quicktiles expected_mode; @@ -836,7 +834,8 @@ TEST_CASE("quick tiling", "[win]") QCOMPARE(c->control->quicktiling, win::quicktiles::none); // We have to receive a configure event upon the client becoming active. - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); diff --git a/tests/integration/scene_qpainter.cpp b/tests/integration/scene_qpainter.cpp index e872e41dfe..974e6a5b7e 100644 --- a/tests/integration/scene_qpainter.cpp +++ b/tests/integration/scene_qpainter.cpp @@ -133,30 +133,29 @@ TEST_CASE("scene qpainter", "[render]") SECTION("window") { + // this test verifies that a window is rendered correctly auto cursor = test::cursor(); cursor->set_pos(45, 45); - // this test verifies that a window is rendered correctly - using namespace Wrapland::Client; - QVERIFY(wait_for_wayland_pointer()); - std::unique_ptr s(create_surface()); - std::unique_ptr ss(create_xdg_shell_toplevel(s)); - QVERIFY(s); - QVERIFY(ss); + auto surface = create_surface(); + QVERIFY(surface); + auto shell_surface = create_xdg_shell_toplevel(surface); + QVERIFY(shell_surface); - std::unique_ptr p(get_client().interfaces.seat->createPointer()); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); - QSignalSpy frameRenderedSpy(s.get(), &Wrapland::Client::Surface::frameRendered); + QSignalSpy frameRenderedSpy(surface.get(), &Wrapland::Client::Surface::frameRendered); QVERIFY(frameRenderedSpy.isValid()); auto scene = dynamic_cast(setup.base->mod.render->scene.get()); QVERIFY(scene); // now let's map the window - QVERIFY(render_and_wait_for_shown(s, QSize(200, 300), Qt::blue)); + QVERIFY(render_and_wait_for_shown(surface, QSize(200, 300), Qt::blue)); // which should trigger a frame - s->commit(); + surface->commit(); QVERIFY(frameRenderedSpy.wait()); // we didn't set a cursor image on the surface yet, so it should be just black + window and @@ -167,11 +166,12 @@ TEST_CASE("scene qpainter", "[render]") painter.fillRect(0, 0, 200, 300, Qt::blue); // now let's set a cursor image - std::unique_ptr cs(create_surface()); - QVERIFY(cs); - render(cs, QSize(10, 10), Qt::red); - p->setCursor(cs.get(), QPoint(5, 5)); - s->commit(); + auto cursor_surface = create_surface(); + QVERIFY(cursor_surface); + + render(cursor_surface, QSize(10, 10), Qt::red); + pointer->setCursor(cursor_surface.get(), QPoint(5, 5)); + surface->commit(); QVERIFY(frameRenderedSpy.wait()); painter.fillRect(cursor->pos().x() - 5, cursor->pos().y() - 5, 10, 10, Qt::red); @@ -181,7 +181,7 @@ TEST_CASE("scene qpainter", "[render]") // let's move the cursor again cursor->set_pos(10, 10); - s->commit(); + surface->commit(); QVERIFY(frameRenderedSpy.wait()); painter.fillRect(0, 0, 200, 300, Qt::blue); painter.fillRect(5, 5, 10, 10, Qt::red); @@ -194,33 +194,33 @@ TEST_CASE("scene qpainter", "[render]") SECTION("window scaled") { // this test verifies that a window is rendered correctly - using namespace Wrapland::Client; - cursor()->set_pos(10, 10); QVERIFY(wait_for_wayland_pointer()); - std::unique_ptr s(create_surface()); - std::unique_ptr ss(create_xdg_shell_toplevel(s)); - QVERIFY(s); - QVERIFY(ss); + auto surface = create_surface(); + QVERIFY(surface); + auto shell_surface = create_xdg_shell_toplevel(surface); + QVERIFY(shell_surface); - std::unique_ptr p(get_client().interfaces.seat->createPointer()); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); - QSignalSpy frameRenderedSpy(s.get(), &Wrapland::Client::Surface::frameRendered); + QSignalSpy frameRenderedSpy(surface.get(), &Wrapland::Client::Surface::frameRendered); QVERIFY(frameRenderedSpy.isValid()); - QSignalSpy pointerEnteredSpy(p.get(), &Pointer::entered); + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); auto scene = dynamic_cast(setup.base->mod.render->scene.get()); QVERIFY(scene); // now let's set a cursor image - std::unique_ptr cs(create_surface()); - QVERIFY(cs); - render(cs, QSize(10, 10), Qt::red); + auto cursor_surface = create_surface(); + QVERIFY(cursor_surface); + + render(cursor_surface, QSize(10, 10), Qt::red); // now let's map the window - s->setScale(2); + surface->setScale(2); // draw a blue square@400x600 with red rectangle@200x200 in the middle const QSize size(400, 600); @@ -230,10 +230,10 @@ TEST_CASE("scene qpainter", "[render]") surfacePainter.fillRect(200, 300, 200, 200, Qt::red); // Add buffer, also commit one more time with default flag to get frame event. - render(s, img); - s->commit(); + render(surface, img); + surface->commit(); QVERIFY(pointerEnteredSpy.wait()); - p->setCursor(cs.get(), QPoint(5, 5)); + pointer->setCursor(cursor_surface.get(), QPoint(5, 5)); // which should trigger a frame QVERIFY(frameRenderedSpy.wait()); @@ -254,15 +254,15 @@ TEST_CASE("scene qpainter", "[render]") cursor()->set_pos(400, 400); // first create a window - using namespace Wrapland::Client; - std::unique_ptr s(create_surface()); - std::unique_ptr ss(create_xdg_shell_toplevel(s)); - QVERIFY(s); - QVERIFY(ss); - QVERIFY(render_and_wait_for_shown(s, QSize(200, 300), Qt::blue)); - s->commit(); - - QSignalSpy frameRenderedSpy(s.get(), &Wrapland::Client::Surface::frameRendered); + auto surface = create_surface(); + QVERIFY(surface); + auto shell_surface = create_xdg_shell_toplevel(surface); + QVERIFY(shell_surface); + + QVERIFY(render_and_wait_for_shown(surface, QSize(200, 300), Qt::blue)); + surface->commit(); + + QSignalSpy frameRenderedSpy(surface.get(), &Wrapland::Client::Surface::frameRendered); QVERIFY(frameRenderedSpy.isValid()); // now let's try to reinitialize the compositing scene diff --git a/tests/integration/screen_changes.cpp b/tests/integration/screen_changes.cpp index 042225f91b..78d4c33e74 100644 --- a/tests/integration/screen_changes.cpp +++ b/tests/integration/screen_changes.cpp @@ -11,8 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -32,18 +30,19 @@ TEST_CASE("screen changes", "[base]") cursor()->set_pos(QPoint(640, 512)); // first create a registry to get signals about Outputs announced/removed - Registry registry; - QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced); + Wrapland::Client::Registry registry; + QSignalSpy allAnnounced(®istry, &Wrapland::Client::Registry::interfacesAnnounced); QVERIFY(allAnnounced.isValid()); - QSignalSpy outputAnnouncedSpy(®istry, &Registry::outputAnnounced); + QSignalSpy outputAnnouncedSpy(®istry, &Wrapland::Client::Registry::outputAnnounced); QVERIFY(outputAnnouncedSpy.isValid()); - QSignalSpy outputRemovedSpy(®istry, &Registry::outputRemoved); + QSignalSpy outputRemovedSpy(®istry, &Wrapland::Client::Registry::outputRemoved); QVERIFY(outputRemovedSpy.isValid()); registry.create(get_client().connection); QVERIFY(registry.isValid()); registry.setup(); QVERIFY(allAnnounced.wait()); - const auto xdgOMData = registry.interface(Registry::Interface::XdgOutputUnstableV1); + const auto xdgOMData + = registry.interface(Wrapland::Client::Registry::Interface::XdgOutputUnstableV1); auto xdgOutputManager = registry.createXdgOutputManager(xdgOMData.name, xdgOMData.version); // should be one output @@ -77,32 +76,32 @@ TEST_CASE("screen changes", "[base]") QCOMPARE(outputRemovedSpy.count(), 1); // let's create the output objects to ensure they are correct - std::unique_ptr o1( + std::unique_ptr o1( registry.createOutput(outputAnnouncedSpy.first().first().value(), outputAnnouncedSpy.first().last().value())); QVERIFY(o1->isValid()); - QSignalSpy o1ChangedSpy(o1.get(), &Output::changed); + QSignalSpy o1ChangedSpy(o1.get(), &Wrapland::Client::Output::changed); QVERIFY(o1ChangedSpy.isValid()); QVERIFY(o1ChangedSpy.wait()); QCOMPARE(o1->geometry(), geometries.at(0)); - std::unique_ptr o2( + std::unique_ptr o2( registry.createOutput(outputAnnouncedSpy.last().first().value(), outputAnnouncedSpy.last().last().value())); QVERIFY(o2->isValid()); - QSignalSpy o2ChangedSpy(o2.get(), &Output::changed); + QSignalSpy o2ChangedSpy(o2.get(), &Wrapland::Client::Output::changed); QVERIFY(o2ChangedSpy.isValid()); QVERIFY(o2ChangedSpy.wait()); QCOMPARE(o2->geometry(), geometries.at(1)); // and check XDGOutput is synced - std::unique_ptr xdgO1(xdgOutputManager->getXdgOutput(o1.get())); - QSignalSpy xdgO1ChangedSpy(xdgO1.get(), &XdgOutput::changed); + std::unique_ptr xdgO1(xdgOutputManager->getXdgOutput(o1.get())); + QSignalSpy xdgO1ChangedSpy(xdgO1.get(), &Wrapland::Client::XdgOutput::changed); QVERIFY(xdgO1ChangedSpy.isValid()); QVERIFY(xdgO1ChangedSpy.wait()); QCOMPARE(xdgO1->logicalPosition(), geometries.at(0).topLeft()); QCOMPARE(xdgO1->logicalSize(), geometries.at(0).size()); - std::unique_ptr xdgO2(xdgOutputManager->getXdgOutput(o2.get())); - QSignalSpy xdgO2ChangedSpy(xdgO2.get(), &XdgOutput::changed); + std::unique_ptr xdgO2(xdgOutputManager->getXdgOutput(o2.get())); + QSignalSpy xdgO2ChangedSpy(xdgO2.get(), &Wrapland::Client::XdgOutput::changed); QVERIFY(xdgO2ChangedSpy.isValid()); QVERIFY(xdgO2ChangedSpy.wait()); QCOMPARE(xdgO2->logicalPosition(), geometries.at(1).topLeft()); @@ -113,9 +112,9 @@ TEST_CASE("screen changes", "[base]") outputRemovedSpy.clear(); outputs_changed_spy.clear(); - QSignalSpy o1RemovedSpy(o1.get(), &Output::removed); + QSignalSpy o1RemovedSpy(o1.get(), &Wrapland::Client::Output::removed); QVERIFY(o1RemovedSpy.isValid()); - QSignalSpy o2RemovedSpy(o2.get(), &Output::removed); + QSignalSpy o2RemovedSpy(o2.get(), &Wrapland::Client::Output::removed); QVERIFY(o2RemovedSpy.isValid()); auto const geometries2 = std::vector{{0, 0, 1280, 1024}}; diff --git a/tests/integration/scripting/minimize_all.cpp b/tests/integration/scripting/minimize_all.cpp index ecaeb3b76f..c8e0156248 100644 --- a/tests/integration/scripting/minimize_all.cpp +++ b/tests/integration/scripting/minimize_all.cpp @@ -45,8 +45,6 @@ TEST_CASE("minimize all", "[script]") { // This test verifies that all windows are minimized when Meta+Shift+D // is pressed, and unminimized when the shortcut is pressed once again. - using namespace Wrapland::Client; - qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); #if USE_XWL @@ -72,15 +70,21 @@ TEST_CASE("minimize all", "[script]") QTRY_COMPARE(runningChangedSpy.count(), 1); // Create a couple of test clients. - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); + QVERIFY(surface1); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); + QVERIFY(shellSurface1); + auto client1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); QVERIFY(client1); QVERIFY(client1->control->active); QVERIFY(client1->isMinimizable()); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto surface2 = create_surface(); + QVERIFY(surface2); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); + QVERIFY(shellSurface2); + auto client2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::red); QVERIFY(client2); QVERIFY(client2->control->active); diff --git a/tests/integration/showing_desktop.cpp b/tests/integration/showing_desktop.cpp index c7b8ee9d4e..b65a3b552f 100644 --- a/tests/integration/showing_desktop.cpp +++ b/tests/integration/showing_desktop.cpp @@ -10,8 +10,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -29,14 +27,15 @@ TEST_CASE("showing desktop", "[win]") SECTION("restore focus") { - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(surface1); QVERIFY(shellSurface1); auto client1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + + auto surface2 = create_surface(); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(surface2); QVERIFY(shellSurface2); @@ -57,29 +56,28 @@ TEST_CASE("showing desktop", "[win]") { // first create a desktop window - std::unique_ptr desktopSurface(create_surface()); + auto desktopSurface = create_surface(); QVERIFY(desktopSurface); - std::unique_ptr desktopShellSurface( - create_xdg_shell_toplevel(desktopSurface)); + auto desktopShellSurface = create_xdg_shell_toplevel(desktopSurface); QVERIFY(desktopShellSurface); - std::unique_ptr plasmaSurface( + std::unique_ptr plasmaSurface( get_client().interfaces.plasma_shell->createSurface(desktopSurface.get())); QVERIFY(plasmaSurface); - plasmaSurface->setRole(PlasmaShellSurface::Role::Desktop); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Desktop); auto desktop = render_and_wait_for_shown(desktopSurface, QSize(100, 50), Qt::blue); QVERIFY(desktop); QVERIFY(win::is_desktop(desktop)); // now create some windows - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(surface1); QVERIFY(shellSurface1); auto client1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + auto surface2 = create_surface(); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(surface2); QVERIFY(shellSurface2); diff --git a/tests/integration/struts.cpp b/tests/integration/struts.cpp index 033d8eb20e..70ef1e0cfe 100644 --- a/tests/integration/struts.cpp +++ b/tests/integration/struts.cpp @@ -140,8 +140,6 @@ TEST_CASE("struts", "[win]") QRegion(0, 10, 32, 390).united(QRegion(0, 450, 40, 100))}); // this test verifies that struts on Wayland panels are handled correctly - using namespace Wrapland::Client; - auto const& outputs = setup.base->outputs; REQUIRE(win::space_window_area( *setup.base->mod.space, win::area_option::placement, outputs.at(0), 1) @@ -207,7 +205,7 @@ TEST_CASE("struts", "[win]") auto plasmaSurface = std::unique_ptr( plasma_shell->createSurface(surface.get())); plasmaSurface->setPosition(window_geo.topLeft()); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); init_xdg_shell_toplevel(surface, shellSurface); // map the window @@ -289,14 +287,14 @@ TEST_CASE("struts", "[win]") SECTION("move wayland panel") { // this test verifies that repositioning a Wayland panel updates the client area - using namespace Wrapland::Client; const QRect windowGeometry(0, 1000, 1280, 24); auto surface = create_surface(); auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); - std::unique_ptr plasmaSurface( + + auto plasmaSurface = std::unique_ptr( plasma_shell->createSurface(surface.get())); plasmaSurface->setPosition(windowGeometry.topLeft()); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); init_xdg_shell_toplevel(surface, shellSurface); // map the window @@ -350,8 +348,6 @@ TEST_CASE("struts", "[win]") SECTION("wayland mobile panel") { - using namespace Wrapland::Client; - // First enable maxmizing policy auto group = setup.base->config.main->group(QStringLiteral("Windows")); group.writeEntry("Placement", "maximizing"); @@ -360,17 +356,18 @@ TEST_CASE("struts", "[win]") // create first top panel const QRect windowGeometry(0, 0, 1280, 60); - auto surface = create_surface(); - auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); - std::unique_ptr plasmaSurface( - plasma_shell->createSurface(surface.get())); + auto surface1 = create_surface(); + auto shellSurface1 = create_xdg_shell_toplevel(surface1, CreationSetup::CreateOnly); + + auto plasmaSurface = std::unique_ptr( + plasma_shell->createSurface(surface1.get())); plasmaSurface->setPosition(windowGeometry.topLeft()); - plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); - init_xdg_shell_toplevel(surface, shellSurface); + plasmaSurface->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); + init_xdg_shell_toplevel(surface1, shellSurface1); // map the first panel auto c = render_and_wait_for_shown( - surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32); + surface1, windowGeometry.size(), Qt::red, QImage::Format_RGB32); QVERIFY(c); QVERIFY(!c->control->active); REQUIRE(c->geo.frame == windowGeometry); @@ -396,13 +393,13 @@ TEST_CASE("struts", "[win]") // create another bottom panel const QRect windowGeometry2(0, 874, 1280, 150); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2( - create_xdg_shell_toplevel(surface2, CreationSetup::CreateOnly)); - std::unique_ptr plasmaSurface2( + auto surface2 = create_surface(); + auto shellSurface2 = create_xdg_shell_toplevel(surface2, CreationSetup::CreateOnly); + + auto plasmaSurface2 = std::unique_ptr( plasma_shell->createSurface(surface2.get())); plasmaSurface2->setPosition(windowGeometry2.topLeft()); - plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface2->setRole(Wrapland::Client::PlasmaShellSurface::Role::Panel); init_xdg_shell_toplevel(surface2, shellSurface2); auto c1 = render_and_wait_for_shown( @@ -431,7 +428,7 @@ TEST_CASE("struts", "[win]") QRect(0, 60, 2560, 814)); // Destroy test clients. - shellSurface.reset(); + shellSurface1.reset(); QVERIFY(wait_for_destroyed(c)); shellSurface2.reset(); QVERIFY(wait_for_destroyed(c1)); diff --git a/tests/integration/subspace.cpp b/tests/integration/subspace.cpp index 24a14850dd..3de2ee499e 100644 --- a/tests/integration/subspace.cpp +++ b/tests/integration/subspace.cpp @@ -9,8 +9,6 @@ #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -846,9 +844,9 @@ TEST_CASE("subspace", "[win]") QCOMPARE(win::subspaces_get_current_x11id(*vd_manager), 2u); // now create a window on this subspace - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -881,9 +879,9 @@ TEST_CASE("subspace", "[win]") QCOMPARE(win::subspaces_get_current_x11id(*vd_manager), 3u); // now create a window on this subspace - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -965,9 +963,9 @@ TEST_CASE("subspace", "[win]") QCOMPARE(win::subspaces_get_current_x11id(*vd_manager), 3u); // now create a window on this subspace - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); diff --git a/tests/integration/tabbox.cpp b/tests/integration/tabbox.cpp index f9cbefb09f..39141f1e05 100644 --- a/tests/integration/tabbox.cpp +++ b/tests/integration/tabbox.cpp @@ -11,8 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -41,25 +39,27 @@ TEST_CASE("tabbox", "[win]") // this test verifies that Alt+tab works correctly moving forward // first create three windows - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); QVERIFY(surface1); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(shellSurface1); auto c1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); QVERIFY(c1); QVERIFY(c1->control->active); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + + auto surface2 = create_surface(); QVERIFY(surface2); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(shellSurface2); auto c2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::red); QVERIFY(c2); QVERIFY(c2->control->active); - std::unique_ptr surface3(create_surface()); - std::unique_ptr shellSurface3(create_xdg_shell_toplevel(surface3)); + + auto surface3 = create_surface(); QVERIFY(surface3); + auto shellSurface3 = create_xdg_shell_toplevel(surface3); QVERIFY(shellSurface3); auto c3 = render_and_wait_for_shown(surface3, QSize(100, 50), Qt::red); @@ -104,25 +104,27 @@ TEST_CASE("tabbox", "[win]") // this test verifies that Alt+Shift+tab works correctly moving backward // first create three windows - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); QVERIFY(surface1); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(shellSurface1); auto c1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); QVERIFY(c1); QVERIFY(c1->control->active); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + + auto surface2 = create_surface(); QVERIFY(surface2); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(shellSurface2); auto c2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::red); QVERIFY(c2); QVERIFY(c2->control->active); - std::unique_ptr surface3(create_surface()); - std::unique_ptr shellSurface3(create_xdg_shell_toplevel(surface3)); + + auto surface3 = create_surface(); QVERIFY(surface3); + auto shellSurface3 = create_xdg_shell_toplevel(surface3); QVERIFY(shellSurface3); auto c3 = render_and_wait_for_shown(surface3, QSize(100, 50), Qt::red); @@ -173,25 +175,27 @@ TEST_CASE("tabbox", "[win]") // bug 368590 // first create three windows - std::unique_ptr surface1(create_surface()); - std::unique_ptr shellSurface1(create_xdg_shell_toplevel(surface1)); + auto surface1 = create_surface(); QVERIFY(surface1); + auto shellSurface1 = create_xdg_shell_toplevel(surface1); QVERIFY(shellSurface1); auto c1 = render_and_wait_for_shown(surface1, QSize(100, 50), Qt::blue); QVERIFY(c1); QVERIFY(c1->control->active); - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); + + auto surface2 = create_surface(); QVERIFY(surface2); + auto shellSurface2 = create_xdg_shell_toplevel(surface2); QVERIFY(shellSurface2); auto c2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::red); QVERIFY(c2); QVERIFY(c2->control->active); - std::unique_ptr surface3(create_surface()); - std::unique_ptr shellSurface3(create_xdg_shell_toplevel(surface3)); + + auto surface3 = create_surface(); QVERIFY(surface3); + auto shellSurface3 = create_xdg_shell_toplevel(surface3); QVERIFY(shellSurface3); auto c3 = render_and_wait_for_shown(surface3, QSize(100, 50), Qt::red); diff --git a/tests/integration/touch_input.cpp b/tests/integration/touch_input.cpp index adbb460367..2faae8738f 100644 --- a/tests/integration/touch_input.cpp +++ b/tests/integration/touch_input.cpp @@ -44,8 +44,6 @@ TEST_CASE("touch input", "[input]") std::vector clients; auto showWindow = [&](bool decorated = false) -> wayland_window* { - using namespace Wrapland::Client; - window_holder client; client.surface = create_surface(); REQUIRE(client.surface.get()); @@ -55,12 +53,12 @@ TEST_CASE("touch input", "[input]") if (decorated) { auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( client.toplevel.get(), client.toplevel.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); REQUIRE(decoSpy.isValid()); - deco->setMode(XdgDecoration::Mode::ServerSide); - REQUIRE(deco->mode() == XdgDecoration::Mode::ClientSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + REQUIRE(deco->mode() == Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(client.surface, client.toplevel); - REQUIRE(deco->mode() == XdgDecoration::Mode::ServerSide); + REQUIRE(deco->mode() == Wrapland::Client::XdgDecoration::Mode::ServerSide); } else { init_xdg_shell_toplevel(client.surface, client.toplevel); } @@ -101,23 +99,21 @@ TEST_CASE("touch input", "[input]") SECTION("multiple touch points") { - using namespace Wrapland::Client; - auto decorated = GENERATE(false, true); auto c = showWindow(decorated); REQUIRE((win::decoration(c) != nullptr) == decorated); win::move(c, QPoint(100, 100)); QVERIFY(c); - QSignalSpy sequenceStartedSpy(touch.get(), &Touch::sequenceStarted); + QSignalSpy sequenceStartedSpy(touch.get(), &Wrapland::Client::Touch::sequenceStarted); QVERIFY(sequenceStartedSpy.isValid()); - QSignalSpy pointAddedSpy(touch.get(), &Touch::pointAdded); + QSignalSpy pointAddedSpy(touch.get(), &Wrapland::Client::Touch::pointAdded); QVERIFY(pointAddedSpy.isValid()); - QSignalSpy pointMovedSpy(touch.get(), &Touch::pointMoved); + QSignalSpy pointMovedSpy(touch.get(), &Wrapland::Client::Touch::pointMoved); QVERIFY(pointMovedSpy.isValid()); - QSignalSpy pointRemovedSpy(touch.get(), &Touch::pointRemoved); + QSignalSpy pointRemovedSpy(touch.get(), &Wrapland::Client::Touch::pointRemoved); QVERIFY(pointRemovedSpy.isValid()); - QSignalSpy endedSpy(touch.get(), &Touch::sequenceEnded); + QSignalSpy endedSpy(touch.get(), &Wrapland::Client::Touch::sequenceEnded); QVERIFY(endedSpy.isValid()); quint32 timestamp = 1; @@ -165,16 +161,14 @@ TEST_CASE("touch input", "[input]") SECTION("cancel") { - using namespace Wrapland::Client; - auto c = showWindow(); win::move(c, QPoint(100, 100)); QVERIFY(c); - QSignalSpy sequenceStartedSpy(touch.get(), &Touch::sequenceStarted); + QSignalSpy sequenceStartedSpy(touch.get(), &Wrapland::Client::Touch::sequenceStarted); QVERIFY(sequenceStartedSpy.isValid()); - QSignalSpy cancelSpy(touch.get(), &Touch::sequenceCanceled); + QSignalSpy cancelSpy(touch.get(), &Wrapland::Client::Touch::sequenceCanceled); QVERIFY(cancelSpy.isValid()); - QSignalSpy pointRemovedSpy(touch.get(), &Touch::pointRemoved); + QSignalSpy pointRemovedSpy(touch.get(), &Wrapland::Client::Touch::pointRemoved); QVERIFY(pointRemovedSpy.isValid()); quint32 timestamp = 1; @@ -195,7 +189,6 @@ TEST_CASE("touch input", "[input]") SECTION("touch mouse action") { // this test verifies that a touch down on an inactive client will activate it - using namespace Wrapland::Client; // create two windows auto c1 = showWindow(); QVERIFY(c1); @@ -206,7 +199,7 @@ TEST_CASE("touch input", "[input]") QVERIFY(c2->control->active); // also create a sequence started spy as the touch event should be passed through - QSignalSpy sequenceStartedSpy(touch.get(), &Touch::sequenceStarted); + QSignalSpy sequenceStartedSpy(touch.get(), &Wrapland::Client::Touch::sequenceStarted); QVERIFY(sequenceStartedSpy.isValid()); quint32 timestamp = 1; diff --git a/tests/integration/virtual_keyboard.cpp b/tests/integration/virtual_keyboard.cpp index 0631cf6c87..64722fa070 100644 --- a/tests/integration/virtual_keyboard.cpp +++ b/tests/integration/virtual_keyboard.cpp @@ -17,7 +17,7 @@ #include #include -namespace como::detail::test +namespace como::detail::test::virtual_keyboard { namespace diff --git a/tests/integration/window_rules.cpp b/tests/integration/window_rules.cpp index d69e3fa57d..392f996282 100644 --- a/tests/integration/window_rules.cpp +++ b/tests/integration/window_rules.cpp @@ -54,7 +54,7 @@ TEST_CASE("window rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // create the test window @@ -142,7 +142,7 @@ TEST_CASE("window rules", "[win]") group.writeEntry("wmclassmatch", 1); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // create the test window diff --git a/tests/integration/window_selection.cpp b/tests/integration/window_selection.cpp index d3f9cc467b..28629c5b7a 100644 --- a/tests/integration/window_selection.cpp +++ b/tests/integration/window_selection.cpp @@ -16,8 +16,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -43,17 +41,23 @@ TEST_CASE("window selection", "[win]") SECTION("select on window pointer") { // this test verifies window selection through pointer works - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); - QSignalSpy pointerEnteredSpy(pointer.get(), &Pointer::entered); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); + + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); - QSignalSpy pointerLeftSpy(pointer.get(), &Pointer::left); + QSignalSpy pointerLeftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(pointerLeftSpy.isValid()); - QSignalSpy keyboardEnteredSpy(keyboard.get(), &Keyboard::entered); + QSignalSpy keyboardEnteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); QVERIFY(keyboardEnteredSpy.isValid()); - QSignalSpy keyboardLeftSpy(keyboard.get(), &Keyboard::left); + QSignalSpy keyboardLeftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); QVERIFY(keyboardLeftSpy.isValid()); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -118,21 +122,22 @@ TEST_CASE("window selection", "[win]") SECTION("select on window keyboard") { // this test verifies window selection through keyboard key - auto key = GENERATE(KEY_ENTER, KEY_KPENTER, KEY_SPACE); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); + auto surface = create_surface(); + auto shellSurface = create_xdg_shell_toplevel(surface); + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); - QSignalSpy pointerEnteredSpy(pointer.get(), &Pointer::entered); + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); - QSignalSpy pointerLeftSpy(pointer.get(), &Pointer::left); + QSignalSpy pointerLeftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(pointerLeftSpy.isValid()); - QSignalSpy keyboardEnteredSpy(keyboard.get(), &Keyboard::entered); + QSignalSpy keyboardEnteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); QVERIFY(keyboardEnteredSpy.isValid()); - QSignalSpy keyboardLeftSpy(keyboard.get(), &Keyboard::left); + QSignalSpy keyboardLeftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); QVERIFY(keyboardLeftSpy.isValid()); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -195,13 +200,17 @@ TEST_CASE("window selection", "[win]") SECTION("select on window touch") { // this test verifies window selection through touch - std::unique_ptr touch(get_client().interfaces.seat->createTouch()); - QSignalSpy touchStartedSpy(touch.get(), &Touch::sequenceStarted); + std::unique_ptr touch(get_client().interfaces.seat->createTouch()); + QSignalSpy touchStartedSpy(touch.get(), &Wrapland::Client::Touch::sequenceStarted); QVERIFY(touchStartedSpy.isValid()); - QSignalSpy touchCanceledSpy(touch.get(), &Touch::sequenceCanceled); + QSignalSpy touchCanceledSpy(touch.get(), &Wrapland::Client::Touch::sequenceCanceled); QVERIFY(touchCanceledSpy.isValid()); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(client); @@ -258,17 +267,23 @@ TEST_CASE("window selection", "[win]") SECTION("cancel on window pointer") { // this test verifies that window selection cancels through right button click - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); - QSignalSpy pointerEnteredSpy(pointer.get(), &Pointer::entered); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); + + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); - QSignalSpy pointerLeftSpy(pointer.get(), &Pointer::left); + QSignalSpy pointerLeftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(pointerLeftSpy.isValid()); - QSignalSpy keyboardEnteredSpy(keyboard.get(), &Keyboard::entered); + QSignalSpy keyboardEnteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); QVERIFY(keyboardEnteredSpy.isValid()); - QSignalSpy keyboardLeftSpy(keyboard.get(), &Keyboard::left); + QSignalSpy keyboardLeftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); QVERIFY(keyboardLeftSpy.isValid()); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -315,17 +330,22 @@ TEST_CASE("window selection", "[win]") SECTION("cancel on window keyboard") { // this test verifies that cancel window selection through escape key works - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); - QSignalSpy pointerEnteredSpy(pointer.get(), &Pointer::entered); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); - QSignalSpy pointerLeftSpy(pointer.get(), &Pointer::left); + QSignalSpy pointerLeftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(pointerLeftSpy.isValid()); - QSignalSpy keyboardEnteredSpy(keyboard.get(), &Keyboard::entered); + QSignalSpy keyboardEnteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); QVERIFY(keyboardEnteredSpy.isValid()); - QSignalSpy keyboardLeftSpy(keyboard.get(), &Keyboard::left); + QSignalSpy keyboardLeftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); QVERIFY(keyboardLeftSpy.isValid()); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -372,17 +392,22 @@ TEST_CASE("window selection", "[win]") SECTION("select point pointer") { // this test verifies point selection through pointer works - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - std::unique_ptr pointer(get_client().interfaces.seat->createPointer()); - std::unique_ptr keyboard(get_client().interfaces.seat->createKeyboard()); - QSignalSpy pointerEnteredSpy(pointer.get(), &Pointer::entered); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + + std::unique_ptr pointer( + get_client().interfaces.seat->createPointer()); + std::unique_ptr keyboard( + get_client().interfaces.seat->createKeyboard()); + QSignalSpy pointerEnteredSpy(pointer.get(), &Wrapland::Client::Pointer::entered); QVERIFY(pointerEnteredSpy.isValid()); - QSignalSpy pointerLeftSpy(pointer.get(), &Pointer::left); + QSignalSpy pointerLeftSpy(pointer.get(), &Wrapland::Client::Pointer::left); QVERIFY(pointerLeftSpy.isValid()); - QSignalSpy keyboardEnteredSpy(keyboard.get(), &Keyboard::entered); + QSignalSpy keyboardEnteredSpy(keyboard.get(), &Wrapland::Client::Keyboard::entered); QVERIFY(keyboardEnteredSpy.isValid()); - QSignalSpy keyboardLeftSpy(keyboard.get(), &Keyboard::left); + QSignalSpy keyboardLeftSpy(keyboard.get(), &Wrapland::Client::Keyboard::left); QVERIFY(keyboardLeftSpy.isValid()); auto client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); diff --git a/tests/integration/x11_client.cpp b/tests/integration/x11_client.cpp index 41882bad91..f892b52210 100644 --- a/tests/integration/x11_client.cpp +++ b/tests/integration/x11_client.cpp @@ -10,8 +10,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -146,8 +144,11 @@ TEST_CASE("x11 window", "[win]") QCOMPARE(get_x11_window(setup.base->mod.space->stacking.order.stack.back()), client); // now let's open a Wayland window - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto waylandClient = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(waylandClient); QVERIFY(waylandClient->control->active); @@ -299,8 +300,11 @@ TEST_CASE("x11 window", "[win]") QVERIFY(client->control->active); // create Wayland window - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto waylandClient = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(waylandClient); QVERIFY(waylandClient->control->active); @@ -385,8 +389,11 @@ TEST_CASE("x11 window", "[win]") QCOMPARE(rootInfo.activeWindow(), client->xcb_windows.client); // activate a wayland window - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto waylandClient = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(waylandClient); QVERIFY(waylandClient->control->active); @@ -506,118 +513,6 @@ TEST_CASE("x11 window", "[win]") QVERIFY(glxgears.waitForFinished()); } - SECTION("caption multiple windows") - { - // BUG 384760 - // create first window - auto c = xcb_connection_create(); - QVERIFY(!xcb_connection_has_error(c.get())); - const QRect windowGeometry(0, 0, 100, 200); - xcb_window_t w = xcb_generate_id(c.get()); - xcb_create_window(c.get(), - XCB_COPY_FROM_PARENT, - w, - setup.base->x11_data.root_window, - windowGeometry.x(), - windowGeometry.y(), - windowGeometry.width(), - windowGeometry.height(), - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - XCB_COPY_FROM_PARENT, - 0, - nullptr); - xcb_size_hints_t hints; - memset(&hints, 0, sizeof(hints)); - xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); - xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); - xcb_icccm_set_wm_normal_hints(c.get(), w, &hints); - win::x11::net::win_info info(c.get(), - w, - setup.base->x11_data.root_window, - win::x11::net::Properties(), - win::x11::net::Properties2()); - info.setName("foo"); - xcb_map_window(c.get(), w); - xcb_flush(c.get()); - - QSignalSpy windowCreatedSpy(setup.base->mod.space->qobject.get(), - &space::qobject_t::clientAdded); - QVERIFY(windowCreatedSpy.isValid()); - QVERIFY(windowCreatedSpy.wait()); - - auto client = get_x11_window_from_id(windowCreatedSpy.first().first().value()); - QVERIFY(client); - QCOMPARE(client->xcb_windows.client, w); - QCOMPARE(win::caption(client), QStringLiteral("foo")); - - // create second window with same caption - xcb_window_t w2 = xcb_generate_id(c.get()); - xcb_create_window(c.get(), - XCB_COPY_FROM_PARENT, - w2, - setup.base->x11_data.root_window, - windowGeometry.x(), - windowGeometry.y(), - windowGeometry.width(), - windowGeometry.height(), - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - XCB_COPY_FROM_PARENT, - 0, - nullptr); - xcb_icccm_set_wm_normal_hints(c.get(), w2, &hints); - win::x11::net::win_info info2(c.get(), - w2, - setup.base->x11_data.root_window, - win::x11::net::Properties(), - win::x11::net::Properties2()); - info2.setName("foo"); - info2.setIconName("foo"); - xcb_map_window(c.get(), w2); - xcb_flush(c.get()); - - windowCreatedSpy.clear(); - QVERIFY(windowCreatedSpy.wait()); - - auto client2 = get_x11_window_from_id(windowCreatedSpy.first().first().value()); - QVERIFY(client2); - QCOMPARE(client2->xcb_windows.client, w2); - QCOMPARE(win::caption(client2), QStringLiteral("foo <2>\u200E")); - win::x11::net::win_info info3(setup.base->x11_data.connection, - w2, - setup.base->x11_data.root_window, - win::x11::net::WMVisibleName - | win::x11::net::WMVisibleIconName, - win::x11::net::Properties2()); - QCOMPARE(QByteArray(info3.visibleName()), QByteArrayLiteral("foo <2>\u200E")); - QCOMPARE(QByteArray(info3.visibleIconName()), QByteArrayLiteral("foo <2>\u200E")); - - QSignalSpy captionChangedSpy(client2->qobject.get(), &win::window_qobject::captionChanged); - QVERIFY(captionChangedSpy.isValid()); - - win::x11::net::win_info info4(c.get(), - w2, - setup.base->x11_data.root_window, - win::x11::net::Properties(), - win::x11::net::Properties2()); - info4.setName("foobar"); - info4.setIconName("foobar"); - xcb_map_window(c.get(), w2); - xcb_flush(c.get()); - - QVERIFY(captionChangedSpy.wait()); - QCOMPARE(win::caption(client2), QStringLiteral("foobar")); - win::x11::net::win_info info5(setup.base->x11_data.connection, - w2, - setup.base->x11_data.root_window, - win::x11::net::WMVisibleName - | win::x11::net::WMVisibleIconName, - win::x11::net::Properties2()); - QCOMPARE(QByteArray(info5.visibleName()), QByteArray()); - QTRY_COMPARE(QByteArray(info5.visibleIconName()), QByteArray()); - } - SECTION("fullscreen window groups") { // this test creates an X11 window and puts it to full screen diff --git a/tests/integration/xdg-shell_rules.cpp b/tests/integration/xdg-shell_rules.cpp index 176434286f..a5a06a93e7 100644 --- a/tests/integration/xdg-shell_rules.cpp +++ b/tests/integration/xdg-shell_rules.cpp @@ -11,8 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -36,10 +34,11 @@ TEST_CASE("xdg-shell rules", "[win]") return {config, group}; }; - auto createWindow = [&](const QByteArray& appId, - int timeout = 5000) -> std::tuple, - std::unique_ptr> { + auto createWindow = + [&](const QByteArray& appId, + int timeout = 5000) -> std::tuple, + std::unique_ptr> { // Create an xdg surface. auto surface = create_surface(); auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); @@ -48,8 +47,9 @@ TEST_CASE("xdg-shell rules", "[win]") shellSurface->setAppId(appId); // Wait for the initial configure event. - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); - surface->commit(Surface::CommitFlag::None); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); // Draw content of the surface. @@ -84,13 +84,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -117,13 +117,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -194,13 +194,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -271,13 +271,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -321,8 +321,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -341,7 +341,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); // The client should be moved to the position specified by the rule. QSignalSpy geometryChangedSpy(client->qobject.get(), @@ -407,13 +407,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -464,20 +464,20 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. - std::unique_ptr surface = create_surface(); - std::unique_ptr shellSurface + std::unique_ptr surface = create_surface(); + std::unique_ptr shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The window size shouldn't be enforced by the rule. QVERIFY(configureRequestedSpy->wait()); @@ -514,18 +514,17 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. auto surface = create_surface(); - std::unique_ptr shellSurface - = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The initial configure event should contain size hint set by the rule. QVERIFY(configureRequestedSpy->wait()); @@ -533,8 +532,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(480, 640)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -549,8 +548,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // One still should be able to resize the client. QSignalSpy geometryChangedSpy(client->qobject.get(), @@ -578,8 +577,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 3); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); auto const cursorPos = cursor()->pos(); @@ -590,9 +589,10 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 4); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); QCOMPARE(cfgdata.size, QSize(488, 640)); QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); @@ -619,9 +619,9 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); @@ -655,7 +655,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -663,9 +663,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The initial configure event should contain size hint set by the rule. QVERIFY(configureRequestedSpy->wait()); @@ -673,8 +673,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(480, 640)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -689,8 +689,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // One should still be able to resize the client. QSignalSpy geometryChangedSpy(client->qobject.get(), @@ -718,8 +718,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 3); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); auto const cursorPos = cursor()->pos(); @@ -730,9 +730,10 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 4); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); + QVERIFY( + cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); QCOMPARE(cfgdata.size, QSize(488, 640)); QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -758,9 +759,9 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); @@ -794,7 +795,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -802,9 +803,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The initial configure event should contain size hint set by the rule. QVERIFY(configureRequestedSpy->wait()); @@ -846,9 +847,9 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); @@ -879,9 +880,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The expected surface dimensions should be set by the rule. QVERIFY(configureRequestedSpy->wait()); @@ -912,7 +913,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The compositor should send a configure event with a new size. @@ -952,7 +953,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -960,9 +961,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The initial configure event should contain size hint set by the rule. QVERIFY(configureRequestedSpy->wait()); @@ -1006,9 +1007,9 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); @@ -1044,7 +1045,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -1052,9 +1053,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy->wait()); @@ -1062,8 +1063,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(0, 0)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -1081,8 +1082,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Destroy the client. shellSurface.reset(); @@ -1102,7 +1103,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -1110,9 +1111,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy->wait()); @@ -1120,8 +1121,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -1138,8 +1139,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // One should still be able to change the maximized state of the client. win::active_window_maximize(*setup.base->mod.space); @@ -1150,8 +1151,8 @@ TEST_CASE("xdg-shell rules", "[win]") // The size is empty since we did not have a restore size before. QVERIFY(cfgdata.size.isEmpty()); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); QSignalSpy geometryChangedSpy(client->qobject.get(), &win::window_qobject::frame_geometry_changed); @@ -1171,17 +1172,17 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); client = render_and_wait_for_shown(surface, QSize(1280, 1024), Qt::blue); @@ -1196,8 +1197,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Destroy the client. shellSurface.reset(); @@ -1217,7 +1218,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -1225,9 +1226,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy->wait()); @@ -1235,8 +1236,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -1253,8 +1254,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // One should still be able to change the maximized state of the client. win::active_window_maximize(*setup.base->mod.space); @@ -1265,8 +1266,8 @@ TEST_CASE("xdg-shell rules", "[win]") // The size is empty since we did not have a restore size before. QVERIFY(cfgdata.size.isEmpty()); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); QSignalSpy geometryChangedSpy(client->qobject.get(), &win::window_qobject::frame_geometry_changed); @@ -1285,17 +1286,17 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(0, 0)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -1310,8 +1311,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Destroy the client. shellSurface.reset(); @@ -1331,7 +1332,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -1339,9 +1340,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy->wait()); @@ -1349,8 +1350,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -1367,8 +1368,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Any attempt to change the maximized state should not succeed. const QRect oldGeometry = client->geo.frame; @@ -1385,17 +1386,17 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); client = render_and_wait_for_shown(surface, QSize(1280, 1024), Qt::blue); @@ -1410,8 +1411,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Destroy the client. shellSurface.reset(); @@ -1426,9 +1427,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy->wait()); @@ -1436,8 +1437,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(0, 0)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -1454,8 +1455,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Initialize RuleBook with the test rule. auto [config, group] = get_config(); @@ -1467,7 +1468,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // We should receive a configure event with a new surface size. @@ -1476,8 +1477,8 @@ TEST_CASE("xdg-shell rules", "[win]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Draw contents of the maximized client. QSignalSpy geometryChangedSpy(client->qobject.get(), @@ -1500,8 +1501,8 @@ TEST_CASE("xdg-shell rules", "[win]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(100, 50)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); render(surface, QSize(100, 50), Qt::blue); @@ -1536,7 +1537,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. @@ -1544,9 +1545,9 @@ TEST_CASE("xdg-shell rules", "[win]") auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); std::unique_ptr configureRequestedSpy; configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the initial configure event. QVERIFY(configureRequestedSpy->wait()); @@ -1554,8 +1555,8 @@ TEST_CASE("xdg-shell rules", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Map the client. shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); @@ -1572,8 +1573,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Any attempt to change the maximized state should not succeed. const QRect oldGeometry = client->geo.frame; @@ -1590,17 +1591,17 @@ TEST_CASE("xdg-shell rules", "[win]") surface = create_surface(); shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); configureRequestedSpy.reset( - new QSignalSpy(shellSurface.get(), &XdgShellToplevel::configured)); + new QSignalSpy(shellSurface.get(), &Wrapland::Client::XdgShellToplevel::configured)); shellSurface->setAppId("org.kde.foo"); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy->wait()); QCOMPARE(configureRequestedSpy->count(), 1); cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(0, 0)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->ackConfigure(configureRequestedSpy->back().front().value()); client = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -1615,8 +1616,8 @@ TEST_CASE("xdg-shell rules", "[win]") QCOMPARE(configureRequestedSpy->count(), 2); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::activated)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::activated)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Destroy the client. shellSurface.reset(); @@ -1641,13 +1642,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -1678,13 +1679,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -1731,13 +1732,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QCOMPARE(win::get_subspace(*client), 2); @@ -1781,13 +1782,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -1827,8 +1828,8 @@ TEST_CASE("xdg-shell rules", "[win]") // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QCOMPARE(win::get_subspace(*client), 1); @@ -1843,7 +1844,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should have been moved to the second subspace. @@ -1883,13 +1884,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -1937,13 +1938,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->isMinimizable()); @@ -1967,13 +1968,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; QSignalSpy toplevel_created_Spy(setup.base->mod.space->xdg_shell.get(), &Wrapland::Server::XdgShell::toplevelCreated); std::tie(client, surface, shellSurface) = createWindow("org.kde.foo", 500); @@ -2021,13 +2022,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->isMinimizable()); @@ -2070,13 +2071,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->isMinimizable()); @@ -2107,8 +2108,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->isMinimizable()); @@ -2122,7 +2123,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should be minimized now. @@ -2154,13 +2155,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->isMinimizable()); @@ -2197,13 +2198,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2226,13 +2227,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2267,13 +2268,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2310,13 +2311,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2347,8 +2348,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->control->skip_taskbar()); @@ -2361,7 +2362,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should not be on a taskbar now. @@ -2391,13 +2392,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2436,13 +2437,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2465,13 +2466,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2506,13 +2507,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2549,13 +2550,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2586,8 +2587,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->control->skip_pager()); @@ -2600,7 +2601,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should not be on a pager now. @@ -2630,13 +2631,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2675,13 +2676,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2704,13 +2705,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2745,13 +2746,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2788,13 +2789,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2825,8 +2826,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->control->skip_switcher()); @@ -2839,7 +2840,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should be excluded from window switching effects now. @@ -2869,13 +2870,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2914,13 +2915,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2943,13 +2944,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -2984,13 +2985,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3025,13 +3026,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3060,8 +3061,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->control->keep_above); @@ -3074,7 +3075,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should now be kept above other clients. @@ -3104,13 +3105,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3151,13 +3152,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3180,13 +3181,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3221,13 +3222,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3262,13 +3263,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3297,8 +3298,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(!client->control->keep_below); @@ -3311,7 +3312,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should now be kept below other clients. @@ -3341,13 +3342,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3388,13 +3389,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QCOMPARE(client->control->shortcut, QKeySequence()); @@ -3431,13 +3432,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3512,13 +3513,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3581,13 +3582,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3642,8 +3643,8 @@ TEST_CASE("xdg-shell rules", "[win]") { // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->shortcut.isEmpty()); @@ -3656,7 +3657,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // The client should now have a window shortcut assigned. @@ -3712,13 +3713,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); @@ -3825,13 +3826,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -3855,13 +3856,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -3883,13 +3884,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -3920,13 +3921,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -3954,13 +3955,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -3989,13 +3990,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -4035,13 +4036,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -4063,13 +4064,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -4091,13 +4092,13 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclasscomplete", false); group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); // Create the test client. wayland_window* client; - std::unique_ptr surface; - std::unique_ptr shellSurface; + std::unique_ptr surface; + std::unique_ptr shellSurface; std::tie(client, surface, shellSurface) = createWindow("org.kde.foo"); QVERIFY(client); QVERIFY(client->control->active); @@ -4127,7 +4128,7 @@ TEST_CASE("xdg-shell rules", "[win]") group.writeEntry("wmclassmatch", enum_index(win::rules::name_match::exact)); group.sync(); - setup.base->mod.space->rule_book->config = config; + setup.base->mod.space->rule_book->settings->setSharedConfig(config); win::space_reconfigure(*setup.base->mod.space); auto surface = create_surface(); diff --git a/tests/integration/xdg-shell_window.cpp b/tests/integration/xdg-shell_window.cpp index a4ee8113d5..a09e61c396 100644 --- a/tests/integration/xdg-shell_window.cpp +++ b/tests/integration/xdg-shell_window.cpp @@ -29,8 +29,6 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include -using namespace Wrapland::Client; - namespace como::detail::test { @@ -50,8 +48,10 @@ TEST_CASE("xdg-shell window", "[win]") &space::qobject_t::wayland_window_added); QVERIFY(clientAddedSpy.isValid()); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); // now let's render render(surface, QSize(100, 50), Qt::blue); @@ -103,8 +103,8 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(hiddenSpy.isValid()); QSignalSpy windowClosedSpy(client->space.qobject.get(), &space::qobject_t::remnant_created); QVERIFY(windowClosedSpy.isValid()); - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(hiddenSpy.wait()); QCOMPARE(client->render_data.ready_for_painting, true); QCOMPARE(client->isHiddenInternal(), true); @@ -131,8 +131,8 @@ TEST_CASE("xdg-shell window", "[win]") client->render->effect.get()); // let's unmap again - surface->attachBuffer(Buffer::Ptr()); - surface->commit(Surface::CommitFlag::None); + surface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(hiddenSpy.wait()); QCOMPARE(hiddenSpy.count(), 2); QCOMPARE(client->render_data.ready_for_painting, true); @@ -156,8 +156,11 @@ TEST_CASE("xdg-shell window", "[win]") { // this test simulates the situation that a transient window gets reused and the parent // window moved between the two usages - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); @@ -169,14 +172,14 @@ TEST_CASE("xdg-shell window", "[win]") pos_data.anchor.edge = Qt::BottomEdge | Qt::RightEdge; pos_data.gravity = pos_data.anchor.edge; - std::unique_ptr transientSurface(create_surface()); - std::unique_ptr transientShellSurface( - create_xdg_shell_popup(transientSurface, shellSurface, pos_data)); + auto transientSurface = create_surface(); QVERIFY(transientSurface); + auto transientShellSurface + = create_xdg_shell_popup(transientSurface, shellSurface, pos_data); QVERIFY(transientShellSurface); QSignalSpy transient_configure_spy(transientShellSurface.get(), - &XdgShellPopup::configureRequested); + &Wrapland::Client::XdgShellPopup::configureRequested); QVERIFY(transient_configure_spy.isValid()); auto transient = render_and_wait_for_shown(transientSurface, pos_data.size, Qt::blue); @@ -187,8 +190,8 @@ TEST_CASE("xdg-shell window", "[win]") // unmap the transient QSignalSpy windowHiddenSpy(transient->qobject.get(), &win::window_qobject::windowHidden); QVERIFY(windowHiddenSpy.isValid()); - transientSurface->attachBuffer(Buffer::Ptr()); - transientSurface->commit(Surface::CommitFlag::None); + transientSurface->attachBuffer(Wrapland::Client::Buffer::Ptr()); + transientSurface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(windowHiddenSpy.wait()); // now move the parent surface @@ -208,15 +211,15 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("window outputs") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto size = QSize(200, 200); - QSignalSpy outputEnteredSpy(surface.get(), &Surface::outputEntered); - QSignalSpy outputLeftSpy(surface.get(), &Surface::outputLeft); + QSignalSpy outputEnteredSpy(surface.get(), &Wrapland::Client::Surface::outputEntered); + QSignalSpy outputLeftSpy(surface.get(), &Wrapland::Client::Surface::outputLeft); auto c = render_and_wait_for_shown(surface, size, Qt::blue); // move to be in the first screen @@ -249,9 +252,9 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("minimize active window") { // this test verifies that when minimizing the active window it gets deactivated - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -283,24 +286,26 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("fullscreen") { // this test verifies that a window can be properly fullscreened - auto deco_mode = GENERATE(XdgDecoration::Mode::ClientSide, XdgDecoration::Mode::ServerSide); + auto deco_mode = GENERATE(Wrapland::Client::XdgDecoration::Mode::ClientSide, + Wrapland::Client::XdgDecoration::Mode::ServerSide); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); QVERIFY(shellSurface); // create deco auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( shellSurface.get(), shellSurface.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decoSpy.isValid()); deco->setMode(deco_mode); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(surface, shellSurface); QCOMPARE(deco->mode(), deco_mode); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -309,7 +314,8 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(win::get_layer(*c), win::layer::normal); QVERIFY(!c->control->fullscreen); QCOMPARE(win::frame_to_client_size(c, c->geo.size()), QSize(100, 50)); - REQUIRE((win::decoration(c) != nullptr) == (deco_mode == XdgDecoration::Mode::ServerSide)); + REQUIRE((win::decoration(c) != nullptr) + == (deco_mode == Wrapland::Client::XdgDecoration::Mode::ServerSide)); QCOMPARE(win::client_to_frame_size(c, win::frame_to_client_size(c, c->geo.size())), c->geo.frame.size()); @@ -367,19 +373,23 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(!c->control->fullscreen); QCOMPARE(win::get_layer(*c), win::layer::normal); - REQUIRE((win::decoration(c) != nullptr) == (deco_mode == XdgDecoration::Mode::ServerSide)); + REQUIRE((win::decoration(c) != nullptr) + == (deco_mode == Wrapland::Client::XdgDecoration::Mode::ServerSide)); } SECTION("fullscreen restore") { // this test verifies that windows created fullscreen can be later properly restored - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); + QVERIFY(surface); auto shell_surface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); - QSignalSpy configureRequestedSpy(shell_surface.get(), &XdgShellToplevel::configured); + QVERIFY(shell_surface); + QSignalSpy configureRequestedSpy(shell_surface.get(), + &Wrapland::Client::XdgShellToplevel::configured); // fullscreen the window shell_surface->setFullscreen(true); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); QCOMPARE(configureRequestedSpy.count(), 1); @@ -424,9 +434,9 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("user can set fullscreen") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -440,15 +450,16 @@ TEST_CASE("xdg-shell window", "[win]") { auto send_fs_geo = GENERATE(true, false); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); QVERIFY(shellSurface); // wait for the initial configure event - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); @@ -563,7 +574,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(configureRequestedSpy.count(), 1); auto cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.updates.testFlag(xdg_shell_toplevel_configure_change::size)); + QVERIFY(cfgdata.updates.testFlag(Wrapland::Client::xdg_shell_toplevel_configure_change::size)); shellSurface->setMaximized(true); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -635,22 +646,24 @@ TEST_CASE("xdg-shell window", "[win]") { // this test creates a window which is as large as the screen, but is decorated // the window should get resized to fit into the screen, BUG: 366632 - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); // create deco auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( shellSurface.get(), shellSurface.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decoSpy.isValid()); - deco->setMode(XdgDecoration::Mode::ServerSide); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + deco->setMode(Wrapland::Client::XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(surface, shellSurface); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); auto c = render_and_wait_for_shown(surface, get_output(0)->geometry().size(), Qt::blue); QVERIFY(c); @@ -660,15 +673,15 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(configureRequestedSpy.wait()); QVERIFY(shellSurface->get_configure_data().updates.testFlag( - xdg_shell_toplevel_configure_change::size)); + Wrapland::Client::xdg_shell_toplevel_configure_change::size)); } SECTION("hidden") { // this test verifies that when hiding window it doesn't get shown - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -698,10 +711,12 @@ TEST_CASE("xdg-shell window", "[win]") { QIcon::setThemeName(QStringLiteral("breeze")); // this test verifies that desktop file name is passed correctly to the window - std::unique_ptr surface(create_surface()); + auto surface = create_surface(); + QVERIFY(surface); // only xdg-shell as ShellSurface misses the setter - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); @@ -738,11 +753,14 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("caption simplified") { - // this test verifies that caption is properly trimmed - // see BUG 323798 comment #12 - std::unique_ptr surface(create_surface()); + // this test verifies that caption is properly trimmed, see BUG 323798 comment #12 + auto surface = create_surface(); + QVERIFY(surface); + // only done for xdg-shell as ShellSurface misses the setter - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); + const QString origTitle = QString::fromUtf8(QByteArrayLiteral( "Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies " "Hübner - Mozilla Firefox")); @@ -753,53 +771,6 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(win::caption(c), origTitle.simplified()); } - SECTION("caption multiple windows") - { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); - shellSurface->setTitle(QStringLiteral("foo")); - auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); - QVERIFY(c); - QCOMPARE(win::caption(c), QStringLiteral("foo")); - QCOMPARE(c->meta.caption.normal, QStringLiteral("foo")); - QCOMPARE(c->meta.caption.suffix, QString()); - - std::unique_ptr surface2(create_surface()); - std::unique_ptr shellSurface2(create_xdg_shell_toplevel(surface2)); - shellSurface2->setTitle(QStringLiteral("foo")); - auto c2 = render_and_wait_for_shown(surface2, QSize(100, 50), Qt::blue); - QVERIFY(c2); - QCOMPARE(win::caption(c2), QStringLiteral("foo <2>")); - QCOMPARE(c2->meta.caption.normal, QStringLiteral("foo")); - QCOMPARE(c2->meta.caption.suffix, QStringLiteral(" <2>")); - - std::unique_ptr surface3(create_surface()); - std::unique_ptr shellSurface3(create_xdg_shell_toplevel(surface3)); - shellSurface3->setTitle(QStringLiteral("foo")); - auto c3 = render_and_wait_for_shown(surface3, QSize(100, 50), Qt::blue); - QVERIFY(c3); - QCOMPARE(win::caption(c3), QStringLiteral("foo <3>")); - QCOMPARE(c3->meta.caption.normal, QStringLiteral("foo")); - QCOMPARE(c3->meta.caption.suffix, QStringLiteral(" <3>")); - - std::unique_ptr surface4(create_surface()); - std::unique_ptr shellSurface4(create_xdg_shell_toplevel(surface4)); - shellSurface4->setTitle(QStringLiteral("bar")); - auto c4 = render_and_wait_for_shown(surface4, QSize(100, 50), Qt::blue); - QVERIFY(c4); - QCOMPARE(win::caption(c4), QStringLiteral("bar")); - QCOMPARE(c4->meta.caption.normal, QStringLiteral("bar")); - QCOMPARE(c4->meta.caption.suffix, QString()); - QSignalSpy captionChangedSpy(c4->qobject.get(), &win::window_qobject::captionChanged); - QVERIFY(captionChangedSpy.isValid()); - shellSurface4->setTitle(QStringLiteral("foo")); - QVERIFY(captionChangedSpy.wait()); - QCOMPARE(captionChangedSpy.count(), 1); - QCOMPARE(win::caption(c4), QStringLiteral("foo <4>")); - QCOMPARE(c4->meta.caption.normal, QStringLiteral("foo")); - QCOMPARE(c4->meta.caption.suffix, QStringLiteral(" <4>")); - } - SECTION("unresponsive window") { // this test verifies that killWindow properly terminates a process @@ -889,14 +860,15 @@ TEST_CASE("xdg-shell window", "[win]") // register a faux appmenu client QVERIFY(QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); - std::unique_ptr menu(get_client().interfaces.app_menu->create(surface.get())); + std::unique_ptr menu( + get_client().interfaces.app_menu->create(surface.get())); QSignalSpy spy(c->qobject.get(), &win::window_qobject::hasApplicationMenuChanged); menu->setAddress("service.name", "object/path"); spy.wait(); @@ -910,20 +882,20 @@ TEST_CASE("xdg-shell window", "[win]") { // this test verifies that the decoration follows the default mode if no mode is explicitly // requested - std::unique_ptr surface(create_surface()); - - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); auto deco = get_client().interfaces.xdg_decoration->getToplevelDecoration( shellSurface.get(), shellSurface.get()); - QSignalSpy decoSpy(deco, &XdgDecoration::modeChanged); + QSignalSpy decoSpy(deco, &Wrapland::Client::XdgDecoration::modeChanged); QVERIFY(decoSpy.isValid()); deco->unsetMode(); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ClientSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ClientSide); init_xdg_shell_toplevel(surface, shellSurface); QCOMPARE(decoSpy.count(), 1); - QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); + QCOMPARE(deco->mode(), Wrapland::Client::XdgDecoration::Mode::ServerSide); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); @@ -937,16 +909,19 @@ TEST_CASE("xdg-shell window", "[win]") // to that subspace win::subspace_manager_set_count(*setup.base->mod.space->subspace_manager, 2); - std::unique_ptr surface{create_surface()}; - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); // let's create a transient window - std::unique_ptr transientSurface{create_surface()}; - std::unique_ptr transientShellSurface( - create_xdg_shell_toplevel(transientSurface)); + auto transientSurface = create_surface(); + QVERIFY(transientSurface); + auto transientShellSurface = create_xdg_shell_toplevel(transientSurface); + QVERIFY(transientShellSurface); transientShellSurface->setTransientFor(shellSurface.get()); auto transient = render_and_wait_for_shown(transientSurface, QSize(100, 50), Qt::blue); @@ -985,16 +960,19 @@ TEST_CASE("xdg-shell window", "[win]") // transients will be minimized/unminimized as well // create the main window - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); QVERIFY(c); QVERIFY(!c->control->minimized); // create a transient window - std::unique_ptr transientSurface(create_surface()); - std::unique_ptr transientShellSurface( - create_xdg_shell_toplevel(transientSurface)); + auto transientSurface = create_surface(); + QVERIFY(transientSurface); + auto transientShellSurface = create_xdg_shell_toplevel(transientSurface); + QVERIFY(transientShellSurface); transientShellSurface->setTransientFor(shellSurface.get()); auto transient = render_and_wait_for_shown(transientSurface, QSize(100, 50), Qt::red); QVERIFY(transient); @@ -1015,16 +993,20 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("xdg-deco") { - auto deco_mode = GENERATE(XdgDecoration::Mode::ClientSide, XdgDecoration::Mode::ServerSide); + auto deco_mode = GENERATE(Wrapland::Client::XdgDecoration::Mode::ClientSide, + Wrapland::Client::XdgDecoration::Mode::ServerSide); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - std::unique_ptr deco( + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); + std::unique_ptr deco( get_client().interfaces.xdg_decoration->getToplevelDecoration(shellSurface.get())); - QSignalSpy decorationConfiguredSpy(deco.get(), &XdgDecoration::modeChanged); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy decorationConfiguredSpy(deco.get(), + &Wrapland::Client::XdgDecoration::modeChanged); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); deco->setMode(deco_mode); @@ -1038,29 +1020,32 @@ TEST_CASE("xdg-shell window", "[win]") shellSurface->ackConfigure(configureRequestedSpy.back().front().toInt()); auto c = render_and_wait_for_shown(surface, QSize(100, 50), Qt::blue); - REQUIRE(c->userCanSetNoBorder() == (deco_mode == XdgDecoration::Mode::ServerSide)); - REQUIRE((win::decoration(c) != nullptr) == (deco_mode == XdgDecoration::Mode::ServerSide)); + REQUIRE(c->userCanSetNoBorder() + == (deco_mode == Wrapland::Client::XdgDecoration::Mode::ServerSide)); + REQUIRE((win::decoration(c) != nullptr) + == (deco_mode == Wrapland::Client::XdgDecoration::Mode::ServerSide)); } SECTION("never committed") { // check we don't crash if we create a shell object but delete the XdgShellClient before // committing it - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); QVERIFY(shellSurface); } SECTION("initial state") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); @@ -1080,13 +1065,15 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("initially maximized") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); shellSurface->setMaximized(true); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); @@ -1121,13 +1108,15 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("initially fullscreen") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); shellSurface->setFullscreen(true); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); QCOMPARE(configureRequestedSpy.count(), 1); @@ -1145,13 +1134,15 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("initially minimized") { - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); shellSurface->requestMinimize(); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); QCOMPARE(configureRequestedSpy.count(), 1); @@ -1175,10 +1166,9 @@ TEST_CASE("xdg-shell window", "[win]") // This test verifies that the effective window geometry corresponds to the // bounding rectangle of the main surface and its sub-surfaces if no window // geometry is set by the client. - - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); QVERIFY(shellSurface); auto client = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); @@ -1198,12 +1188,15 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(win::render_geometry(client).topLeft(), oldPosition); QCOMPARE(win::render_geometry(client).size(), QSize(100, 50)); - std::unique_ptr childSurface(create_surface()); - std::unique_ptr subSurface(create_subsurface(childSurface, surface)); + auto childSurface = create_surface(); + QVERIFY(childSurface); + auto subSurface = create_subsurface(childSurface, surface); QVERIFY(subSurface); + subSurface->setPosition(QPoint(-20, -10)); render(childSurface, QSize(100, 50), Qt::blue); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); + QVERIFY(geometryChangedSpy.wait()); QCOMPARE(client->geo.frame.topLeft(), oldPosition); QCOMPARE(client->geo.frame.size(), QSize(120, 60)); @@ -1217,9 +1210,11 @@ TEST_CASE("xdg-shell window", "[win]") // a new buffer is attached and xdg_surface.set_window_geometry is not called // again. Notice that the window geometry must remain the same even if the new // buffer is smaller. + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); auto client = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(client); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); @@ -1236,7 +1231,7 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(geometryChangedSpy.isValid()); shellSurface->setWindowGeometry(first_win_geo); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(client->geo.frame.topLeft(), first_pos); @@ -1256,7 +1251,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(win::render_geometry(client).size(), QSize(100, 50)); shellSurface->setWindowGeometry(second_win_geo); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The frame geometry must stay the same. QVERIFY(!geometryChangedSpy.wait(200)); @@ -1272,9 +1267,10 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("send to screen") { // This test verifies that we can send xdg-shell toplevels and popups to other screens. - - std::unique_ptr surface(create_surface()); - std::unique_ptr shell_surface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shell_surface = create_xdg_shell_toplevel(surface); + QVERIFY(shell_surface); auto window = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(window); @@ -1288,14 +1284,13 @@ TEST_CASE("xdg-shell window", "[win]") pos_data.anchor.edge = Qt::BottomEdge | Qt::RightEdge; pos_data.gravity = pos_data.anchor.edge; - std::unique_ptr popup_surface(create_surface()); - std::unique_ptr popup_shell_surface( - create_xdg_shell_popup(popup_surface, shell_surface, pos_data)); + auto popup_surface = create_surface(); QVERIFY(popup_surface); + auto popup_shell_surface = create_xdg_shell_popup(popup_surface, shell_surface, pos_data); QVERIFY(popup_shell_surface); QSignalSpy popup_configure_spy(popup_shell_surface.get(), - &XdgShellPopup::configureRequested); + &Wrapland::Client::XdgShellPopup::configureRequested); QVERIFY(popup_configure_spy.isValid()); auto popup = render_and_wait_for_shown(popup_surface, pos_data.size, Qt::blue); @@ -1332,9 +1327,11 @@ TEST_CASE("xdg-shell window", "[win]") // This test verifies that the effective window geometry remains the same // when a new sub-surface is added and xdg_surface.set_window_geometry is // not called again. + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); auto client = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(client); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); @@ -1352,7 +1349,7 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(geometryChangedSpy.isValid()); shellSurface->setWindowGeometry(first_win_geo); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(client->geo.frame.topLeft(), first_pos); @@ -1360,13 +1357,14 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(win::render_geometry(client).topLeft(), first_pos - QPoint(10, 10)); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); - std::unique_ptr childSurface(create_surface()); - std::unique_ptr subSurface(create_subsurface(childSurface, surface)); + auto childSurface = create_surface(); + QVERIFY(childSurface); + auto subSurface = create_subsurface(childSurface, surface); QVERIFY(subSurface); subSurface->setPosition(subsurface_offset); render(childSurface, QSize(100, 50), Qt::blue); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QCOMPARE(client->geo.frame.topLeft(), first_pos); QCOMPARE(client->geo.frame.size(), QSize(180, 80)); @@ -1374,7 +1372,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); shellSurface->setWindowGeometry(second_win_geo); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(geometryChangedSpy.wait()); // TODO: Is the buffer relative to the main surface's top-left corner or to the union of it @@ -1390,16 +1388,19 @@ TEST_CASE("xdg-shell window", "[win]") { // This test verifies that correct window geometry is provided along each // configure event when an xdg-shell is being interactively resized. + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); auto client = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(client); QVERIFY(client->control->active); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); QCOMPARE(client->geo.frame.size(), QSize(200, 100)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); @@ -1408,7 +1409,7 @@ TEST_CASE("xdg-shell window", "[win]") &win::window_qobject::frame_geometry_changed); QVERIFY(geometryChangedSpy.isValid()); shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); QCOMPARE(client->geo.frame.size(), QSize(180, 80)); @@ -1432,7 +1433,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(configureRequestedSpy.count(), 2); auto cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); // Go right. auto cursorPos = cursor()->pos(); @@ -1444,7 +1445,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(configureRequestedSpy.count(), 3); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); QCOMPARE(cfgdata.size, QSize(188, 80)); shellSurface->setWindowGeometry(QRect(10, 10, 188, 80)); @@ -1466,7 +1467,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(configureRequestedSpy.count(), 4); cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); QCOMPARE(cfgdata.size, QSize(188, 88)); shellSurface->setWindowGeometry(QRect(10, 10, 188, 88)); @@ -1488,7 +1489,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(configureRequestedSpy.count(), 5); cfgdata = shellSurface->get_configure_data(); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::resizing)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::resizing)); #endif shellSurface.reset(); @@ -1499,16 +1500,19 @@ TEST_CASE("xdg-shell window", "[win]") { // This test verifies that an xdg-shell receives correct window geometry when // its fullscreen state gets changed. + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); auto client = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(client); QVERIFY(client->control->active); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); QCOMPARE(client->geo.frame.size(), QSize(200, 100)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); @@ -1521,7 +1525,7 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(geometryChangedSpy.isValid()); shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(geometryChangedSpy.count(), 1); @@ -1538,7 +1542,7 @@ TEST_CASE("xdg-shell window", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::fullscreen)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::fullscreen)); shellSurface->setWindowGeometry(QRect(0, 0, 1280, 1024)); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -1554,7 +1558,7 @@ TEST_CASE("xdg-shell window", "[win]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(180, 80)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::fullscreen)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::fullscreen)); shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -1572,16 +1576,19 @@ TEST_CASE("xdg-shell window", "[win]") { // This test verifies that an xdg-shell receives correct window geometry when // its maximized state gets changed. + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface); + QVERIFY(shellSurface); - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface(create_xdg_shell_toplevel(surface)); auto client = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(client); QVERIFY(client->control->active); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); QCOMPARE(client->geo.frame.size(), QSize(200, 100)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); @@ -1590,7 +1597,7 @@ TEST_CASE("xdg-shell window", "[win]") &win::window_qobject::frame_geometry_changed); QVERIFY(geometryChangedSpy.isValid()); shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(win::render_geometry(client).size(), QSize(200, 100)); QCOMPARE(client->geo.frame.size(), QSize(180, 80)); @@ -1601,7 +1608,7 @@ TEST_CASE("xdg-shell window", "[win]") auto cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->setWindowGeometry(QRect(0, 0, 1280, 1024)); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -1617,7 +1624,7 @@ TEST_CASE("xdg-shell window", "[win]") cfgdata = shellSurface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(180, 80)); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); shellSurface->ackConfigure(configureRequestedSpy.back().front().value()); @@ -1637,25 +1644,28 @@ TEST_CASE("xdg-shell window", "[win]") // separated by the initial commit is handled properly. // Create the test surface. - std::unique_ptr surface(create_surface()); - std::unique_ptr shell_surface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); + auto surface = create_surface(); + QVERIFY(surface); + auto shell_surface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shell_surface); + shell_surface->setMaximized(true); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // Wait for the compositor to respond with a configure event. - QSignalSpy configureRequestedSpy(shell_surface.get(), &XdgShellToplevel::configured); + QSignalSpy configureRequestedSpy(shell_surface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 1); auto cfgdata = shell_surface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); REQUIRE(!(cfgdata.states & Wrapland::Client::xdg_shell_state::activated)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // Send another set_maximized() request, but do not attach any buffer yet. shell_surface->setMaximized(true); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); // The compositor must respond with another configure event even if the state hasn't // changed. @@ -1664,7 +1674,7 @@ TEST_CASE("xdg-shell window", "[win]") cfgdata = shell_surface->get_configure_data(); QCOMPARE(cfgdata.size, QSize(1280, 1024)); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); REQUIRE(!(cfgdata.states & Wrapland::Client::xdg_shell_state::activated)); shell_surface->ackConfigure(configureRequestedSpy.back().front().toUInt()); @@ -1675,7 +1685,7 @@ TEST_CASE("xdg-shell window", "[win]") QCOMPARE(configureRequestedSpy.count(), 3); cfgdata = shell_surface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); QVERIFY(cfgdata.states & Wrapland::Client::xdg_shell_state::activated); QCOMPARE(client->maximizeMode(), win::maximize_mode::full); @@ -1685,13 +1695,13 @@ TEST_CASE("xdg-shell window", "[win]") // event. shell_surface->setMaximized(true); shell_surface->ackConfigure(configureRequestedSpy.back().front().toUInt()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 4); cfgdata = shell_surface->get_configure_data(); - QVERIFY(cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); QCOMPARE(client->maximizeMode(), win::maximize_mode::full); QCOMPARE(client->geo.size(), QSize(1280, 1024)); @@ -1700,26 +1710,26 @@ TEST_CASE("xdg-shell window", "[win]") // configure event, this time with an empty size. shell_surface->setMaximized(false); shell_surface->ackConfigure(configureRequestedSpy.back().front().toUInt()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 5); cfgdata = shell_surface->get_configure_data(); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); QVERIFY(cfgdata.size.isEmpty()); // Request to unmaximize again. This will change nothing, but we receive another configure // event. shell_surface->setMaximized(false); shell_surface->ackConfigure(configureRequestedSpy.back().front().toUInt()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); QVERIFY(configureRequestedSpy.wait()); QCOMPARE(configureRequestedSpy.count(), 6); cfgdata = shell_surface->get_configure_data(); - QVERIFY(!cfgdata.states.testFlag(xdg_shell_state::maximized)); + QVERIFY(!cfgdata.states.testFlag(Wrapland::Client::xdg_shell_state::maximized)); // TODO(romangg): We change the synced geometry on commit. Use other geometry or don't do // that. @@ -1729,29 +1739,38 @@ TEST_CASE("xdg-shell window", "[win]") SECTION("wm capabilities") { // Checks that capabilities are initially sent correctly - std::unique_ptr surface(create_surface()); - std::unique_ptr shellSurface( - create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly)); - QSignalSpy configureRequestedSpy(shellSurface.get(), &XdgShellToplevel::configured); + auto surface = create_surface(); + QVERIFY(surface); + auto shellSurface = create_xdg_shell_toplevel(surface, CreationSetup::CreateOnly); + QVERIFY(shellSurface); + + QSignalSpy configureRequestedSpy(shellSurface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(configureRequestedSpy.isValid()); - surface->commit(Surface::CommitFlag::None); + surface->commit(Wrapland::Client::Surface::CommitFlag::None); configureRequestedSpy.wait(); QCOMPARE(configureRequestedSpy.count(), 1); auto cfgdata = shellSurface->get_configure_data(); - QVERIFY(cfgdata.wm_capabilities.contains(xdg_shell_wm_capability::fullscreen)); - QVERIFY(cfgdata.wm_capabilities.contains(xdg_shell_wm_capability::minimize)); - QVERIFY(cfgdata.wm_capabilities.contains(xdg_shell_wm_capability::maximize)); - QVERIFY(cfgdata.wm_capabilities.contains(xdg_shell_wm_capability::window_menu)); + QVERIFY(cfgdata.wm_capabilities.contains( + Wrapland::Client::xdg_shell_wm_capability::fullscreen)); + QVERIFY( + cfgdata.wm_capabilities.contains(Wrapland::Client::xdg_shell_wm_capability::minimize)); + QVERIFY( + cfgdata.wm_capabilities.contains(Wrapland::Client::xdg_shell_wm_capability::maximize)); + QVERIFY(cfgdata.wm_capabilities.contains( + Wrapland::Client::xdg_shell_wm_capability::window_menu)); } SECTION("popup reposition") { // Checks that xdg-popups are positioned and repositioned correctly. - std::unique_ptr surface(create_surface()); - std::unique_ptr shell_surface(create_xdg_shell_toplevel(surface)); + auto surface = create_surface(); + QVERIFY(surface); + auto shell_surface = create_xdg_shell_toplevel(surface); + QVERIFY(shell_surface); auto window = render_and_wait_for_shown(surface, QSize(200, 100), Qt::red); QVERIFY(window); @@ -1764,14 +1783,15 @@ TEST_CASE("xdg-shell window", "[win]") pos_data.anchor.edge = Qt::BottomEdge | Qt::RightEdge; pos_data.gravity = pos_data.anchor.edge; - std::unique_ptr popup_surface(create_surface()); - std::unique_ptr popup_shell_surface( - create_xdg_shell_popup(popup_surface, shell_surface, pos_data)); + auto popup_surface = create_surface(); + auto popup_shell_surface = create_xdg_shell_popup(popup_surface, shell_surface, pos_data); QVERIFY(popup_surface); QVERIFY(popup_shell_surface); - QSignalSpy repositioned_spy(popup_shell_surface.get(), &XdgShellPopup::repositioned); - QSignalSpy configure_spy(popup_shell_surface.get(), &XdgShellPopup::configureRequested); + QSignalSpy repositioned_spy(popup_shell_surface.get(), + &Wrapland::Client::XdgShellPopup::repositioned); + QSignalSpy configure_spy(popup_shell_surface.get(), + &Wrapland::Client::XdgShellPopup::configureRequested); QVERIFY(repositioned_spy.isValid()); QVERIFY(configure_spy.isValid()); @@ -1813,10 +1833,10 @@ TEST_CASE("xdg-shell window", "[win]") QRect{0, 0, 50, 100}, QRect{QRect{10, 15, 0, 0}.topLeft(), QRect{0, 0, 50, 100}.size()}); - std::unique_ptr parent_surface(create_surface()); - std::unique_ptr parent_shell_surface( - create_xdg_shell_toplevel(parent_surface)); - QSignalSpy parent_configure_spy(parent_shell_surface.get(), &XdgShellToplevel::configured); + auto parent_surface = create_surface(); + auto parent_shell_surface = create_xdg_shell_toplevel(parent_surface); + QSignalSpy parent_configure_spy(parent_shell_surface.get(), + &Wrapland::Client::XdgShellToplevel::configured); QVERIFY(parent_configure_spy.isValid()); QSize parent_size(200, 100); @@ -1835,14 +1855,16 @@ TEST_CASE("xdg-shell window", "[win]") pos_data.anchor.edge = Qt::BottomEdge | Qt::RightEdge; pos_data.gravity = pos_data.anchor.edge; - std::unique_ptr popup_surface(create_surface()); - std::unique_ptr popup_shell_surface( - create_xdg_shell_popup(popup_surface, parent_shell_surface, pos_data)); + auto popup_surface = create_surface(); + auto popup_shell_surface + = create_xdg_shell_popup(popup_surface, parent_shell_surface, pos_data); QVERIFY(popup_surface); QVERIFY(popup_shell_surface); - QSignalSpy popup_done_spy(popup_shell_surface.get(), &XdgShellPopup::popupDone); - QSignalSpy configure_spy(popup_shell_surface.get(), &XdgShellPopup::configureRequested); + QSignalSpy popup_done_spy(popup_shell_surface.get(), + &Wrapland::Client::XdgShellPopup::popupDone); + QSignalSpy configure_spy(popup_shell_surface.get(), + &Wrapland::Client::XdgShellPopup::configureRequested); QVERIFY(popup_done_spy.isValid()); QVERIFY(configure_spy.isValid()); @@ -1884,8 +1906,10 @@ TEST_CASE("xdg-shell window", "[win]") QVERIFY(popup_surface); QVERIFY(popup_shell_surface); - QSignalSpy popup_done_spy2(popup_shell_surface.get(), &XdgShellPopup::popupDone); - QSignalSpy configure_spy2(popup_shell_surface.get(), &XdgShellPopup::configureRequested); + QSignalSpy popup_done_spy2(popup_shell_surface.get(), + &Wrapland::Client::XdgShellPopup::popupDone); + QSignalSpy configure_spy2(popup_shell_surface.get(), + &Wrapland::Client::XdgShellPopup::configureRequested); QVERIFY(popup_done_spy2.isValid()); QVERIFY(configure_spy2.isValid()); diff --git a/tests/manual/README.md b/tests/manual/README.md index 9a8e85f4b5..43484c8324 100644 --- a/tests/manual/README.md +++ b/tests/manual/README.md @@ -1,3 +1,7 @@ + # Manual Tests This directory contains test binaries, that can be executed manually to test various diff --git a/tests/plasma/CMakeLists.txt b/tests/plasma/CMakeLists.txt index cb45618b37..f30d18af6a 100644 --- a/tests/plasma/CMakeLists.txt +++ b/tests/plasma/CMakeLists.txt @@ -14,7 +14,7 @@ kcoreaddons_target_static_plugins(kwin_x11 NAMESPACE "kwin/effects/plugins") add_executable(kwin_wayland main_wayland.cpp) target_link_libraries(kwin_wayland - desktop-kde + desktop-kde-wl como::script como::wayland como::xwayland diff --git a/tests/plasma/README.md b/tests/plasma/README.md index 1ae9483a5d..77a8fd28c2 100644 --- a/tests/plasma/README.md +++ b/tests/plasma/README.md @@ -1,3 +1,7 @@ + # Plasma Binaries These binaries are kept around and recompiled on every test build diff --git a/tests/plasma/main_wayland.cpp b/tests/plasma/main_wayland.cpp index c6965b59e6..1fe95dc345 100644 --- a/tests/plasma/main_wayland.cpp +++ b/tests/plasma/main_wayland.cpp @@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-2.0-or-later #include #include +#include #include #include #include