From fdd7f68c0a7e109a6865efc387928feed1869008 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 20 Feb 2024 21:52:56 +0100 Subject: [PATCH 01/21] build: provide CMakePresets.json It is good style to provide CMake presets with a CMake project. We replace the KDECompilerSettings with these presets. The removal of the exception flag means that consumers are more free in selecting the right behavior for them. At the moment exceptions are required though. The CI is adapted in that we need to set a preset for having sensible warnings being set. As we now enable more warnings than KDECompilerSettings did, this means the CI pipeline will produce also more warnings. --- .github/workflows/build.yml | 12 ++++- .github/workflows/change.yml | 1 + .github/workflows/rebuild.yml | 1 + CMakeLists.txt | 25 +++++----- CMakePresets.json | 89 +++++++++++++++++++++++++++++++++++ como/base/CMakeLists.txt | 2 - 6 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 CMakePresets.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 628a82201..50a22c7f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,11 @@ on: required: false type: string default: 'build' + cmake-preset: + description: Specify CMake preset to use + required: false + type: string + default: '' is-sanitized: description: Should sanitizers be compiled into the build required: false @@ -63,6 +68,8 @@ jobs: runs-on: ubuntu-latest container: image: ${{ inputs.image }} + env: + cmake-preset: '' steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -71,8 +78,11 @@ jobs: with: secret: ${{ secrets.GITHUB_TOKEN }} - run: mkdir build + - name: Set CMake preset + if: ${{ inputs.cmake-preset != '' }} + run: echo "cmake-preset=--preset ${{ inputs.cmake-preset }}" >> $GITHUB_ENV - name: Configure - run: cmake -S . -B build ${{ needs.set-cmake-args.outputs.args }} + run: cmake ${{ inputs.cmake-preset }} -S . -B build ${{ needs.set-cmake-args.outputs.args }} - name: Build run: cmake --build build - name: Tar artifact (keep permissions) diff --git a/.github/workflows/change.yml b/.github/workflows/change.yml index 80509e760..f44f8bfc3 100644 --- a/.github/workflows/change.yml +++ b/.github/workflows/change.yml @@ -15,6 +15,7 @@ jobs: uses: ./.github/workflows/build.yml with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + cmake-preset: coverage install: uses: ./.github/workflows/install.yml diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 87854a702..6e3cf7298 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -8,6 +8,7 @@ jobs: uses: ./.github/workflows/build.yml with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + cmake-preset: clang package: uses: ./.github/workflows/package.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 943d7f693..2ae89addc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,17 +8,19 @@ project("The Compositor Modules" VERSION 0.1.0) set(QT_MIN_VERSION "6.4.0") set(KF6_MIN_VERSION "5.240.0") -set(KDE_COMPILERSETTINGS_LEVEL "5.84") set(KDE_PLASMA_VERSION "5.27") set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0 - -DQT_NO_KEYWORDS - -DQT_USE_QSTRINGBUILDER +add_definitions( -DQT_NO_URL_CAST_FROM_STRING + -DQT_USE_QSTRINGBUILDER + -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT + -DQT_NO_KEYWORDS + -DQT_NO_FOREACH + -DQT_STRICT_ITERATORS -DQT_NO_CAST_TO_ASCII ) @@ -58,15 +60,6 @@ endif() include(KDEInstallDirs) include(KDECMakeSettings) -include(KDECompilerSettings NO_POLICY_SCOPE) - -# TODO(romangg): The KDECompilerSettings include adds cast-align warnings. But with wlroots and -# libwayland we have too many C casts like this. For now disable the cast-align warning again. -# Should we instead wrap the calls and disable the warnings with pragma more targeted? -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-align") - -# Produces a lot of warnings with gcc on structs where we default-initialize some fields. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) @@ -309,12 +302,16 @@ 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) -########### configure tests ############### 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) option(COMO_BUILD_PERF "Build internal tools for performance analysis at runtime." ON) +# Default to hidden visibility for symbols +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + set(COMO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(HAVE_PERF ${COMO_BUILD_PERF}) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..1c0d021da --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,89 @@ +{ + "version": 4, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "debug-base", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + }, + "environment": { + "DEBUG_COMMON_FLAGS": "-Wall -Wextra -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef", + "DEBUG_C_FLAGS": "$env{DEBUG_COMMON_FLAGS} -Wmissing-format-attribute -Wwrite-strings -Werror=implicit-function-declaration", + "DEBUG_CXX_FLAGS": "$env{DEBUG_COMMON_FLAGS} -fno-operator-names -Wnon-virtual-dtor -Woverloaded-virtual -Wvla -Wdate-time -pedantic -Wzero-as-null-pointer-constant -Werror=return-type -Werror=init-self -Werror=undef -fdiagnostics-color=always", + "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" + } + }, + { + "name": "clang", + "inherits": "debug-base", + "displayName": "Clang Config", + "description": "Default build using Ninja and Clang", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_C_FLAGS": "$env{DEBUG_C_FLAGS}", + "CMAKE_CXX_FLAGS": "$env{DEBUG_CXX_FLAGS_CLANG}", + "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}" + } + }, + { + "name": "gcc", + "inherits": "debug-base", + "displayName": "GCC Config", + "description": "Build using Ninja and GCC", + "cacheVariables": { + "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", + "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}" + } + }, + { + "name": "sanitizers", + "inherits": "debug-base", + "displayName": "Sanitizers Build", + "description": "Build with common sanitizers", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_C_FLAGS": "$env{DEBUG_C_FLAGS}", + "CMAKE_CXX_FLAGS": "$env{DEBUG_CXX_FLAGS_CLANG}", + "ECM_ENABLE_SANITIZERS": "address;leak;undefined", + "CMAKE_SHARED_LINKER_FLAGS": "$env{DEBUG_SHARED_LINKER_FLAGS}", + "CMAKE_MODULE_LINKER_FLAGS": "$env{DEBUG_MODULE_LINKER_FLAGS}" + } + }, + { + "name": "coverage", + "inherits": "debug-base", + "displayName": "Tests with Coverage", + "description": "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" + } + } + } + ] +} diff --git a/como/base/CMakeLists.txt b/como/base/CMakeLists.txt index 2351afbd1..bcdf81fc3 100644 --- a/como/base/CMakeLists.txt +++ b/como/base/CMakeLists.txt @@ -3,8 +3,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later add_library(base SHARED) -target_compile_options (base PUBLIC -fexceptions) - target_link_libraries(base PUBLIC utils From 02daa8b97399797ebdd997b3a89f590759974575 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 20 Feb 2024 22:26:11 +0100 Subject: [PATCH 02/21] ci: remove set-cmake-args job The arguments are not needed anymore since we set everything through the presets now. --- .github/workflows/build.yml | 48 +------------------------------------ 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50a22c7f1..0df22ec85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,55 +16,9 @@ on: required: false type: string default: '' - is-sanitized: - description: Should sanitizers be compiled into the build - required: false - type: boolean - default: false - ninja: - description: Should Ninja be used as generator - required: false - type: boolean - default: true - cmake-args: - description: Specify CMake arguments manually - required: false - type: string - default: '' jobs: - set-cmake-args: - name: CMake Args - runs-on: ubuntu-latest - env: - cmake-args: '' - outputs: - args: ${{ steps.set-output.outputs.result }} - steps: - - name: Set from manually specified CMake args - if: ${{ inputs.cmake-args != '' }} - run: echo \"cmake-args=${{ inputs.cmake-args }}\" >> $GITHUB_ENV; - - name: Set default CMake args for sanitized build - if: ${{ inputs.cmake-args == '' && inputs.is-sanitized }} - run: echo "cmake-args=-DECM_ENABLE_SANITIZERS='address;leak;undefined'" >> $GITHUB_ENV" - - name: Set default CMake args for coverage build - if: ${{ inputs.cmake-args == '' && !inputs.is-sanitized }} - run: - "echo \"cmake-args=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage\" >> $GITHUB_ENV" - - name: Set clang as compiler - if: ${{ inputs.cmake-args == '' }} - run: - "echo \"cmake-args=-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ - ${{ env.cmake-args }}\" >> $GITHUB_ENV" - - name: Set generator - if: ${{ inputs.cmake-args == '' && inputs.ninja }} - run: echo "cmake-args=-G Ninja ${{ env.cmake-args }}" >> $GITHUB_ENV - - id: set-output - name: Set resulting variable - run: echo "result=${{ env.cmake-args }}" >> "$GITHUB_OUTPUT" build: name: Build - needs: set-cmake-args runs-on: ubuntu-latest container: image: ${{ inputs.image }} @@ -82,7 +36,7 @@ jobs: if: ${{ inputs.cmake-preset != '' }} run: echo "cmake-preset=--preset ${{ inputs.cmake-preset }}" >> $GITHUB_ENV - name: Configure - run: cmake ${{ inputs.cmake-preset }} -S . -B build ${{ needs.set-cmake-args.outputs.args }} + run: cmake ${{ env.cmake-preset }} -S . -B build - name: Build run: cmake --build build - name: Tar artifact (keep permissions) From 42b376c56118ebeca5565c64ecc6b4b88deb15da Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 00:33:43 +0100 Subject: [PATCH 03/21] build: remove KDECMakeSettings include The include comes with a lot of instructions. We don't need most of them, so just do the little we rely on ourselves in a separate include. --- CMakeLists.txt | 6 +-- cmake/modules/CMakeSettings.cmake | 69 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 cmake/modules/CMakeSettings.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ae89addc..63171670e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,12 +54,10 @@ set_package_properties(Qt6Test PROPERTIES TYPE OPTIONAL ) add_feature_info("Qt6Test" Qt6Test_FOUND "Required for building tests") -if (NOT Qt6Test_FOUND) - set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.") -endif() include(KDEInstallDirs) -include(KDECMakeSettings) +include(CMakeSettings) +include(CTest) include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) diff --git a/cmake/modules/CMakeSettings.cmake b/cmake/modules/CMakeSettings.cmake new file mode 100644 index 000000000..b433574b7 --- /dev/null +++ b/cmake/modules/CMakeSettings.cmake @@ -0,0 +1,69 @@ + +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: BSD-3-Clause + +################# RPATH handling ################################## + +# Set the default RPATH to point to useful locations, namely where the +# libraries will be installed and the linker search path. + +# KDE_INSTALL_LIBDIR comes from previous KDEInstallDirs include. +if(NOT KDE_INSTALL_LIBDIR) + message(FATAL_ERROR "KDE_INSTALL_LIBDIR is not set. Setting one is necessary for using the RPATH settings.") +endif() + +set(_abs_LIB_INSTALL_DIR "${KDE_INSTALL_LIBDIR}") + +if (NOT IS_ABSOLUTE "${_abs_LIB_INSTALL_DIR}") + set(_abs_LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${_abs_LIB_INSTALL_DIR}") +endif() + +# add our LIB_INSTALL_DIR to the RPATH (but only when it is not one of +# the standard system link directories - such as /usr/lib) +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemLibDir) +list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemCxxLibDir) +list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemCLibDir) +if("${_isSystemLibDir}" STREQUAL "-1" AND "${_isSystemCxxLibDir}" STREQUAL "-1" AND "${_isSystemCLibDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${_abs_LIB_INSTALL_DIR}") +endif() + +# Append directories in the linker search path (but outside the project) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +################ Build settings ########################### + +# Always include srcdir and builddir in include path +# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} in about every subdir +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# put the include dirs which are in the source or build tree before all other include dirs, so the +# headers in the sources are preferred over the already installed ones +set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) + +# Add the src and build dir to the BUILD_INTERFACE include directories of all targets. Similar to +# CMAKE_INCLUDE_CURRENT_DIR, but transitive. +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) + +# When a shared library changes, but its includes do not, don't relink all dependencies. It is not +# needed. +set(CMAKE_LINK_DEPENDS_NO_SHARED ON) + +# Default to shared libs, if no type is explicitly given to add_library(). +set(BUILD_SHARED_LIBS TRUE CACHE BOOL "If enabled, shared libs will be built by default, otherwise static libs") + +set(CMAKE_AUTOMOC ON) + +# Enable autorcc and in cmake so qrc files get generated.. +set(CMAKE_AUTORCC ON) + +# By default, don't put a prefix on MODULE targets. add_library(MODULE) is basically for plugin +# targets, and in KDE plugins don't have a prefix. +set(CMAKE_SHARED_MODULE_PREFIX "") + +# All executables are built into a toplevel "bin" dir, making it possible to find helper binaries, +# and to find uninstalled plugins (provided that you use kcoreaddons_add_plugin() or set +# LIBRARY_OUTPUT_DIRECTORY as documented on [1]. +# [1] https://community.kde.org/Guidelines_and_HOWTOs/Making_apps_run_uninstalled) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") From 340737bd90802859f0e19b4797139b76cf42a0e8 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 10:34:13 +0100 Subject: [PATCH 04/21] ci: add gcc build Test building with gcc too. --- .github/workflows/build.yml | 4 +++- .github/workflows/change.yml | 18 ++++++++++++++---- .github/workflows/rebuild.yml | 1 + .github/workflows/test.yml | 3 +-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0df22ec85..eee9e07ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: description: Artifact name of build dir required: false type: string - default: 'build' + default: '' cmake-preset: description: Specify CMake preset to use required: false @@ -40,8 +40,10 @@ jobs: - name: Build run: cmake --build build - name: Tar artifact (keep permissions) + if: ${{ inputs.artifact-name != '' }} run: tar -czf build-dir.tar build - name: Upload artifact + if: ${{ inputs.artifact-name != '' }} uses: actions/upload-artifact@v4 with: name: ${{ inputs.artifact-name }} diff --git a/.github/workflows/change.yml b/.github/workflows/change.yml index f44f8bfc3..1d766113c 100644 --- a/.github/workflows/change.yml +++ b/.github/workflows/change.yml @@ -11,23 +11,32 @@ jobs: clang-format: uses: ./.github/workflows/clang-format.yml - build: + clang-build: uses: ./.github/workflows/build.yml with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + artifact-name: clang-build cmake-preset: coverage + gcc-build: + uses: ./.github/workflows/build.yml + with: + image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + cmake-preset: gcc + install: uses: ./.github/workflows/install.yml - needs: build + needs: clang-build with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + artifact-name: clang-build test: uses: ./.github/workflows/test.yml - needs: build + needs: clang-build with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + artifact-name: clang-build ctest-args: "-E 'lockscreen|modifier only shortcut|no crash empty deco|no crash no border\ |scene opengl|opengl shadow|no crash reinit compositor|buffer size change\ @@ -36,7 +45,8 @@ jobs: package: uses: ./.github/workflows/package.yml - needs: build + needs: clang-build with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + artifact-name: clang-build package-name: como diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 6e3cf7298..1ae847ff4 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -8,6 +8,7 @@ jobs: uses: ./.github/workflows/build.yml with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master + artifact-name: build cmake-preset: clang package: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f510311c..0bf91430d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,9 +8,8 @@ on: type: string artifact-name: description: Artifact name of build dir - required: false + required: true type: string - default: 'build' ctest-args: description: Specify additional CTest arguments required: false From eec8cc7c1b59c18f4b1ca5fea7b498fbf9386ed5 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 22:25:22 +0100 Subject: [PATCH 05/21] fix: store composited string as QString Otherwise the composited string might be optimized away on release builds what leads to a crash on nullptr. --- como/render/effect/basic_effect_loader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/como/render/effect/basic_effect_loader.cpp b/como/render/effect/basic_effect_loader.cpp index b3dfa058b..e3871e716 100644 --- a/como/render/effect/basic_effect_loader.cpp +++ b/como/render/effect/basic_effect_loader.cpp @@ -21,7 +21,7 @@ load_effect_flags basic_effect_loader::readConfig(QString const& effectName, Q_ASSERT(m_config); KConfigGroup plugins(m_config, QStringLiteral("Plugins")); - auto const key = effectName + QStringLiteral("Enabled"); + auto const key = QString(effectName + QStringLiteral("Enabled")); // do we have a key for the effect? if (plugins.hasKey(key)) { From 9adf82ac6adc99ac80498221b911ef8b0da583a2 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 10:54:28 +0100 Subject: [PATCH 06/21] fix: use std::as_const instead of deprecated qAsConst Silences a deprecation warning. --- autotests/integration/opengl_shadow.cpp | 6 ++--- autotests/integration/qpainter_shadow.cpp | 2 +- autotests/libkwineffects/window_quad_list.cpp | 8 +++---- como/debug/support_info.h | 6 ++--- .../wayland/global_shortcuts_manager.cpp | 2 +- como/render/effect/integration.h | 2 +- .../render/effect/interface/paint_clipper.cpp | 2 +- como/render/effect/interface/window_quad.cpp | 8 +++---- como/render/effect/screen_impl.h | 2 +- como/render/effects.cpp | 6 ++--- como/render/effects.h | 2 +- como/render/gl/window.h | 6 ++--- como/render/x11/support_properties.h | 2 +- como/script/effect.cpp | 2 +- como/script/platform.cpp | 4 ++-- como/script/platform.h | 2 +- como/script/script.cpp | 4 ++-- como/win/input/gestures.cpp | 12 +++++----- como/win/input/global_shortcut.h | 2 +- como/win/rules/book.cpp | 2 +- como/win/rules/book_settings.cpp | 4 ++-- como/win/tabbox/tabbox.h | 2 +- plugins/effects/cube/cube.cpp | 24 +++++++++---------- plugins/effects/cubeslide/cubeslide.cpp | 20 ++++++++-------- .../highlightwindow/highlightwindow.cpp | 2 +- plugins/effects/mousemark/mousemark.cpp | 8 +++---- plugins/effects/overview/overvieweffect.cpp | 2 +- plugins/effects/private/expolayout.cpp | 12 +++++----- plugins/effects/screenshot/screenshot.cpp | 2 +- plugins/effects/slide/slide.cpp | 4 ++-- plugins/effects/slideback/slideback.cpp | 18 +++++++------- .../effects/thumbnailaside/thumbnailaside.cpp | 10 ++++---- .../effects/windowview/windowvieweffect.cpp | 4 ++-- plugins/idletime/poller.cpp | 2 +- plugins/kdecorations/aurorae/src/aurorae.cpp | 2 +- plugins/qpa/eglhelpers.cpp | 2 +- plugins/qpa/integration.cpp | 2 +- tests/plasma/main_wayland.cpp | 2 +- 38 files changed, 102 insertions(+), 102 deletions(-) diff --git a/autotests/integration/opengl_shadow.cpp b/autotests/integration/opengl_shadow.cpp index b4e54a426..8e4a497a5 100644 --- a/autotests/integration/opengl_shadow.cpp +++ b/autotests/integration/opengl_shadow.cpp @@ -530,7 +530,7 @@ TEST_CASE("opengl shadow", "[render]") } } - for (const auto& v : qAsConst(mask)) { + for (const auto& v : std::as_const(mask)) { if (!v) { FAIL("missed a shadow quad"); } @@ -623,7 +623,7 @@ TEST_CASE("opengl shadow", "[render]") expectedQuads << makeShadowQuad( QRectF(-128, 0, 128, 512), 0.0, 128.0 / 257.0, 128.0 / 257.0, 129.0 / 257.0); // left - for (auto const& expectedQuad : qAsConst(expectedQuads)) { + for (auto const& expectedQuad : std::as_const(expectedQuads)) { auto it = std::find_if( quads.constBegin(), quads.constEnd(), [&expectedQuad](auto const& quad) { return compareQuads(quad, expectedQuad); @@ -711,7 +711,7 @@ TEST_CASE("opengl shadow", "[render]") WindowQuadList const& quads = shadow->shadowQuads(); QCOMPARE(quads.count(), expectedQuads.count()); - for (auto const& expectedQuad : qAsConst(expectedQuads)) { + for (auto const& expectedQuad : std::as_const(expectedQuads)) { auto it = std::find_if( quads.constBegin(), quads.constEnd(), [&expectedQuad](auto const& quad) { return compareQuads(quad, expectedQuad); diff --git a/autotests/integration/qpainter_shadow.cpp b/autotests/integration/qpainter_shadow.cpp index 588b9ff62..0d4027dc5 100644 --- a/autotests/integration/qpainter_shadow.cpp +++ b/autotests/integration/qpainter_shadow.cpp @@ -544,7 +544,7 @@ TEST_CASE("qpainter shadow", "[render]") } } - for (auto const& v : qAsConst(mask)) { + for (auto const& v : std::as_const(mask)) { if (!v) { FAIL("missed a shadow quad"); } diff --git a/autotests/libkwineffects/window_quad_list.cpp b/autotests/libkwineffects/window_quad_list.cpp index b6d1e66f2..198b7ba8e 100644 --- a/autotests/libkwineffects/window_quad_list.cpp +++ b/autotests/libkwineffects/window_quad_list.cpp @@ -83,9 +83,9 @@ TEST_CASE("window quad list", "[effect],[unit]") auto actual = test_data.orig.makeGrid(test_data.quad_size); REQUIRE(actual.count() == test_data.expected_count); - for (auto const& actualQuad : qAsConst(actual)) { + for (auto const& actualQuad : std::as_const(actual)) { bool found = false; - for (auto const& expectedQuad : qAsConst(test_data.expected)) { + for (auto const& expectedQuad : std::as_const(test_data.expected)) { auto vertexTest = [actualQuad, expectedQuad](int index) { auto const& actualVertex = actualQuad[index]; auto const& expectedVertex = expectedQuad[index]; @@ -170,9 +170,9 @@ TEST_CASE("window quad list", "[effect],[unit]") = test_data.orig.makeRegularGrid(test_data.x_subdivisions, test_data.y_subdivisions); REQUIRE(actual.count() == test_data.expected_count); - for (auto const& actualQuad : qAsConst(actual)) { + for (auto const& actualQuad : std::as_const(actual)) { bool found = false; - for (auto const& expectedQuad : qAsConst(test_data.expected)) { + for (auto const& expectedQuad : std::as_const(test_data.expected)) { auto vertexTest = [actualQuad, expectedQuad](int index) { auto const& actualVertex = actualQuad[index]; auto const& expectedVertex = expectedQuad[index]; diff --git a/como/debug/support_info.h b/como/debug/support_info.h index 42b50a589..a0d398d9f 100644 --- a/como/debug/support_info.h +++ b/como/debug/support_info.h @@ -230,18 +230,18 @@ QString get_support_info(Space const& space) support.append(QStringLiteral("\nLoaded Effects:\n")); support.append(QStringLiteral("---------------\n")); auto const& loaded_effects = effects->loadedEffects(); - for (auto const& effect : qAsConst(loaded_effects)) { + for (auto const& effect : std::as_const(loaded_effects)) { support.append(effect + QStringLiteral("\n")); } support.append(QStringLiteral("\nCurrently Active Effects:\n")); support.append(QStringLiteral("-------------------------\n")); auto const& active_effects = effects->activeEffects(); - for (auto const& effect : qAsConst(active_effects)) { + for (auto const& effect : std::as_const(active_effects)) { support.append(effect + QStringLiteral("\n")); } support.append(QStringLiteral("\nEffect Settings:\n")); support.append(QStringLiteral("----------------\n")); - for (auto const& effect : qAsConst(loaded_effects)) { + for (auto const& effect : std::as_const(loaded_effects)) { support.append(effects->supportInformation(effect)); support.append(QStringLiteral("\n")); } diff --git a/como/input/wayland/global_shortcuts_manager.cpp b/como/input/wayland/global_shortcuts_manager.cpp index fd8391904..f4a2b5173 100644 --- a/como/input/wayland/global_shortcuts_manager.cpp +++ b/como/input/wayland/global_shortcuts_manager.cpp @@ -94,7 +94,7 @@ void global_shortcuts_manager::objectDeleted(QObject* object) bool global_shortcuts_manager::shortcut_exists(global_shortcut const& sc) { - for (const auto& cs : qAsConst(m_shortcuts)) { + for (const auto& cs : std::as_const(m_shortcuts)) { if (sc.shortcut() == cs.shortcut()) { return false; } diff --git a/como/render/effect/integration.h b/como/render/effect/integration.h index c08bbc8e8..b26a5d32a 100644 --- a/como/render/effect/integration.h +++ b/como/render/effect/integration.h @@ -18,7 +18,7 @@ void setup_effect_screen_geometry_changes(EffectIntegrator& effi) QObject::connect(&effi.effects, &Effects::screenGeometryChanged, &effi.effects, [&] { effi.reset(); auto const& stacking_order = effi.effects.stackingOrder(); - for (auto const& window : qAsConst(stacking_order)) { + for (auto const& window : std::as_const(stacking_order)) { effi.update(*window); } }); diff --git a/como/render/effect/interface/paint_clipper.cpp b/como/render/effect/interface/paint_clipper.cpp index 447d3d15f..3e78361f3 100644 --- a/como/render/effect/interface/paint_clipper.cpp +++ b/como/render/effect/interface/paint_clipper.cpp @@ -58,7 +58,7 @@ QRegion PaintClipper::paintArea() Q_ASSERT(areas != nullptr); // can be called only with clip() == true const QSize& s = effects->virtualScreenSize(); QRegion ret(0, 0, s.width(), s.height()); - for (const QRegion& r : qAsConst(*areas)) { + for (const QRegion& r : std::as_const(*areas)) { ret &= r; } return ret; diff --git a/como/render/effect/interface/window_quad.cpp b/como/render/effect/interface/window_quad.cpp index 4c2426a78..828a696cf 100644 --- a/como/render/effect/interface/window_quad.cpp +++ b/como/render/effect/interface/window_quad.cpp @@ -256,7 +256,7 @@ WindowQuadList WindowQuadList::makeGrid(int maxQuadSize) const double top = first().top(); double bottom = first().bottom(); - for (auto const& quad : qAsConst(*this)) { + for (auto const& quad : std::as_const(*this)) { #if !defined(QT_NO_DEBUG) if (quad.isTransformed()) qFatal("Splitting quads is allowed only in pre-paint calls!"); @@ -455,10 +455,10 @@ void WindowQuadList::makeArrays(float** vertices, WindowQuadList WindowQuadList::select(WindowQuadType type) const { - for (auto const& q : qAsConst(*this)) { + for (auto const& q : std::as_const(*this)) { if (q.type() != type) { // something else than ones to select, make a copy and filter WindowQuadList ret; - for (auto const& q : qAsConst(*this)) { + for (auto const& q : std::as_const(*this)) { if (q.type() == type) ret.append(q); } @@ -473,7 +473,7 @@ WindowQuadList WindowQuadList::filterOut(WindowQuadType type) const for (const WindowQuad& q : *this) { if (q.type() == type) { // something to filter out, make a copy and filter WindowQuadList ret; - for (auto const& q : qAsConst(*this)) { + for (auto const& q : std::as_const(*this)) { if (q.type() != type) ret.append(q); } diff --git a/como/render/effect/screen_impl.h b/como/render/effect/screen_impl.h index 1b760ef5e..cc2d3a1d5 100644 --- a/como/render/effect/screen_impl.h +++ b/como/render/effect/screen_impl.h @@ -87,7 +87,7 @@ template effect_screen_impl* get_effect_screen(Effects const& effects, Output const& output) { auto const& screens = effects.screens(); - for (auto&& eff_screen : qAsConst(screens)) { + for (auto&& eff_screen : std::as_const(screens)) { auto eff_screen_impl = static_cast*>(eff_screen); if (&output == eff_screen_impl->platformOutput()) { return eff_screen_impl; diff --git a/como/render/effects.cpp b/como/render/effects.cpp index 948c46d07..e0654aaa9 100644 --- a/como/render/effects.cpp +++ b/como/render/effects.cpp @@ -34,7 +34,7 @@ effects_handler_wrap::~effects_handler_wrap() void effects_handler_wrap::unloadAllEffects() { - for (const EffectPair& pair : qAsConst(loaded_effects)) { + for (const EffectPair& pair : std::as_const(loaded_effects)) { destroyEffect(pair.second); } @@ -323,7 +323,7 @@ bool effects_handler_wrap::checkInputWindowEvent(QMouseEvent* e) if (m_grabbedMouseEffects.isEmpty()) { return false; } - for (auto const& effect : qAsConst(m_grabbedMouseEffects)) { + for (auto const& effect : std::as_const(m_grabbedMouseEffects)) { effect->windowInputMouseEvent(e); } return true; @@ -334,7 +334,7 @@ bool effects_handler_wrap::checkInputWindowEvent(QWheelEvent* e) if (m_grabbedMouseEffects.isEmpty()) { return false; } - for (auto const& effect : qAsConst(m_grabbedMouseEffects)) { + for (auto const& effect : std::as_const(m_grabbedMouseEffects)) { effect->windowInputMouseEvent(e); } return true; diff --git a/como/render/effects.h b/como/render/effects.h index d5097d06a..178ce3c56 100644 --- a/como/render/effects.h +++ b/como/render/effects.h @@ -830,7 +830,7 @@ class effects_handler_impl : public effects_handler_wrap EffectScreen* findScreen(const QString& name) const override { - for (EffectScreen* screen : qAsConst(m_effectScreens)) { + for (EffectScreen* screen : std::as_const(m_effectScreens)) { if (screen->name() == name) { return screen; } diff --git a/como/render/gl/window.h b/como/render/gl/window.h index 70ac8c463..8169a19fd 100644 --- a/como/render/gl/window.h +++ b/como/render/gl/window.h @@ -114,7 +114,7 @@ class window final : public Scene::window_t auto content_ids = std::vector{last_content_id}; // Split the quads into separate lists for each type - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { switch (quad.type()) { case WindowQuadShadow: quads[ShadowLeaf].append(quad); @@ -147,7 +147,7 @@ class window final : public Scene::window_t quads.resize(quads.size() + 1); auto const& old_content_rect = previous->win_integration->get_contents_rect(); - for (auto const& quad : qAsConst(quads[ContentLeaf])) { + for (auto const& quad : std::as_const(quads[ContentLeaf])) { if (quad.id() != static_cast(this->id())) { // We currently only do this for the main window and not annexed children // that means we can skip from here on. @@ -410,7 +410,7 @@ class window final : public Scene::window_t auto const filterRegion = data.paint.region.translated(-win_pos.x(), -win_pos.y()); // split all quads in bounding rect with the actual rects in the region - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { for (auto const& r : filterRegion) { QRectF const rf(r); QRectF const quadRect(QPointF(quad.left(), quad.top()), diff --git a/como/render/x11/support_properties.h b/como/render/x11/support_properties.h index d3057830d..ff3618515 100644 --- a/como/render/x11/support_properties.h +++ b/como/render/x11/support_properties.h @@ -40,7 +40,7 @@ void delete_unused_support_properties(Compositor& comp) return; } - for (auto const& atom : qAsConst(comp.unused_support_properties)) { + for (auto const& atom : std::as_const(comp.unused_support_properties)) { // remove property from root window xcb_delete_property(con, comp.base.x11_data.root_window, atom); } diff --git a/como/script/effect.cpp b/como/script/effect.cpp index 4df6b61e1..9376d5b54 100644 --- a/como/script/effect.cpp +++ b/como/script/effect.cpp @@ -695,7 +695,7 @@ bool effect::borderActivated(ElectricBorder edge) return false; } - for (auto const& callback : qAsConst(it->second)) { + for (auto const& callback : std::as_const(it->second)) { QJSValue(callback).call(); } return true; diff --git a/como/script/platform.cpp b/como/script/platform.cpp index f8d3defc9..af6502e72 100644 --- a/como/script/platform.cpp +++ b/como/script/platform.cpp @@ -151,7 +151,7 @@ bool platform_wrap::isScriptLoaded(const QString& pluginName) const abstract_script* platform_wrap::findScript(const QString& pluginName) const { QMutexLocker locker(m_scriptsLock.data()); - for (auto const& script : qAsConst(scripts)) { + for (auto const& script : std::as_const(scripts)) { if (script->pluginName() == pluginName) { return script; } @@ -162,7 +162,7 @@ abstract_script* platform_wrap::findScript(const QString& pluginName) const bool platform_wrap::unloadScript(const QString& pluginName) { QMutexLocker locker(m_scriptsLock.data()); - for (auto const& script : qAsConst(scripts)) { + for (auto const& script : std::as_const(scripts)) { if (script->pluginName() == pluginName) { script->deleteLater(); return true; diff --git a/como/script/platform.h b/como/script/platform.h index e1198a23f..692646b92 100644 --- a/como/script/platform.h +++ b/como/script/platform.h @@ -236,7 +236,7 @@ class platform : public platform_wrap assert(window_it != w_wins.cend()); QList actions; - for (auto s : qAsConst(scripts)) { + for (auto s : std::as_const(scripts)) { // TODO: Allow declarative scripts to add their own user actions. if (auto script = qobject_cast(s)) { actions << script->actionsForUserActionMenu(*window_it, parent); diff --git a/como/script/script.cpp b/como/script/script.cpp index 43e870510..f95953de8 100644 --- a/como/script/script.cpp +++ b/como/script/script.cpp @@ -312,7 +312,7 @@ void script::callDBus(const QString& service, QVariantList dbusArguments; dbusArguments.reserve(jsArguments.count()); - for (const QJSValue& jsArgument : qAsConst(jsArguments)) { + for (const QJSValue& jsArgument : std::as_const(jsArguments)) { dbusArguments << jsArgument.toVariant(); } @@ -451,7 +451,7 @@ QList script::actionsForUserActionMenu(window* window, QMenu* parent) QList actions; actions.reserve(m_userActionsMenuCallbacks.count()); - for (QJSValue callback : qAsConst(m_userActionsMenuCallbacks)) { + for (QJSValue callback : std::as_const(m_userActionsMenuCallbacks)) { QJSValue result = callback.call({m_engine->toScriptValue(window)}); if (result.isError()) { continue; diff --git a/como/win/input/gestures.cpp b/como/win/input/gestures.cpp index 1892847f6..57bcefaa8 100644 --- a/como/win/input/gestures.cpp +++ b/como/win/input/gestures.cpp @@ -123,7 +123,7 @@ int gesture_recognizer::startSwipeGesture(uint fingerCount, return 0; } int count = 0; - for (swipe_gesture* gesture : qAsConst(m_swipeGestures)) { + for (swipe_gesture* gesture : std::as_const(m_swipeGestures)) { if (gesture->minimumFingerCountIsRelevant()) { if (gesture->minimumFingerCount() > fingerCount) { continue; @@ -253,10 +253,10 @@ void gesture_recognizer::updateSwipeGesture(const QSizeF& delta) void gesture_recognizer::cancelActiveGestures() { - for (auto g : qAsConst(m_activeSwipeGestures)) { + for (auto g : std::as_const(m_activeSwipeGestures)) { Q_EMIT g->cancelled(); } - for (auto g : qAsConst(m_activePinchGestures)) { + for (auto g : std::as_const(m_activePinchGestures)) { Q_EMIT g->cancelled(); } m_activeSwipeGestures.clear(); @@ -277,7 +277,7 @@ void gesture_recognizer::cancelSwipeGesture() void gesture_recognizer::endSwipeGesture() { const QSizeF delta = m_currentDelta; - for (auto g : qAsConst(m_activeSwipeGestures)) { + for (auto g : std::as_const(m_activeSwipeGestures)) { if (static_cast(g)->minimumDeltaReached(delta)) { Q_EMIT g->triggered(); } else { @@ -297,7 +297,7 @@ int gesture_recognizer::startPinchGesture(uint fingerCount) if (!m_activeSwipeGestures.isEmpty() || !m_activePinchGestures.isEmpty()) { return 0; } - for (pinch_gesture* gesture : qAsConst(m_pinchGestures)) { + for (pinch_gesture* gesture : std::as_const(m_pinchGestures)) { if (gesture->minimumFingerCountIsRelevant()) { if (gesture->minimumFingerCount() > fingerCount) { continue; @@ -364,7 +364,7 @@ void gesture_recognizer::cancelPinchGesture() void gesture_recognizer::endPinchGesture() // because fingers up { - for (auto g : qAsConst(m_activePinchGestures)) { + for (auto g : std::as_const(m_activePinchGestures)) { if (g->minimumScaleDeltaReached(m_currentScale)) { Q_EMIT g->triggered(); } else { diff --git a/como/win/input/global_shortcut.h b/como/win/input/global_shortcut.h index 7ed96a19c..4672defed 100644 --- a/como/win/input/global_shortcut.h +++ b/como/win/input/global_shortcut.h @@ -107,7 +107,7 @@ std::vector get_internal_shortcuts(QList const& std::vector ret; ret.reserve(list.size()); - for (auto&& el : qAsConst(list)) { + for (auto&& el : std::as_const(list)) { auto const keys = el.keys(); auto const seq = keys.empty() ? QKeySequence() : keys.front(); ret.push_back(KeyboardShortcut{.sequence = seq, diff --git a/como/win/rules/book.cpp b/como/win/rules/book.cpp index 7a6a30b45..a9ddd90fb 100644 --- a/como/win/rules/book.cpp +++ b/como/win/rules/book.cpp @@ -67,7 +67,7 @@ void book::save() } std::vector filteredRules; - for (const auto& rule : qAsConst(m_rules)) { + for (const auto& rule : std::as_const(m_rules)) { filteredRules.push_back(rule); } diff --git a/como/win/rules/book_settings.cpp b/como/win/rules/book_settings.cpp index 28436f8eb..48c54c370 100644 --- a/como/win/rules/book_settings.cpp +++ b/como/win/rules/book_settings.cpp @@ -91,7 +91,7 @@ bool book_settings::usrSave() } // Remove deleted groups from config - for (const QString& groupName : qAsConst(m_storedGroups)) { + for (const QString& groupName : std::as_const(m_storedGroups)) { if (sharedConfig()->hasGroup(groupName) && !mRuleGroupList.contains(groupName)) { sharedConfig()->deleteGroup(groupName); } @@ -118,7 +118,7 @@ void book_settings::usrRead() mCount = mRuleGroupList.count(); m_storedGroups = mRuleGroupList; - for (const QString& groupName : qAsConst(mRuleGroupList)) { + for (const QString& groupName : std::as_const(mRuleGroupList)) { m_list.push_back(new settings(sharedConfig(), groupName, this)); } } diff --git a/como/win/tabbox/tabbox.h b/como/win/tabbox/tabbox.h index 18d2133b9..0306651da 100644 --- a/como/win/tabbox/tabbox.h +++ b/como/win/tabbox/tabbox.h @@ -967,7 +967,7 @@ class tabbox borders.clear(); auto list = cfg_group.readEntry(border_config, QStringList()); - for (auto const& s : qAsConst(list)) { + for (auto const& s : std::as_const(list)) { bool ok; auto i = s.toInt(&ok); if (!ok) { diff --git a/plugins/effects/cube/cube.cpp b/plugins/effects/cube/cube.cpp index e500fac8f..35e7fe8b2 100644 --- a/plugins/effects/cube/cube.cpp +++ b/plugins/effects/cube/cube.cpp @@ -124,13 +124,13 @@ bool CubeEffect::supported() void CubeEffect::reconfigure(ReconfigureFlags) { CubeConfig::self()->read(); - for (auto const& border : qAsConst(borderActivate)) { + for (auto const& border : std::as_const(borderActivate)) { effects->unreserveElectricBorder(border, this); } - for (auto const& border : qAsConst(borderActivateCylinder)) { + for (auto const& border : std::as_const(borderActivateCylinder)) { effects->unreserveElectricBorder(border, this); } - for (auto const& border : qAsConst(borderActivateSphere)) { + for (auto const& border : std::as_const(borderActivateSphere)) { effects->unreserveElectricBorder(border, this); } borderActivate.clear(); @@ -139,21 +139,21 @@ void CubeEffect::reconfigure(ReconfigureFlags) QList borderList = QList(); borderList.append(int(ElectricNone)); borderList = CubeConfig::borderActivate(); - for (auto i : qAsConst(borderList)) { + for (auto i : std::as_const(borderList)) { borderActivate.append(ElectricBorder(i)); effects->reserveElectricBorder(ElectricBorder(i), this); } borderList.clear(); borderList.append(int(ElectricNone)); borderList = CubeConfig::borderActivateCylinder(); - for (auto i : qAsConst(borderList)) { + for (auto i : std::as_const(borderList)) { borderActivateCylinder.append(ElectricBorder(i)); effects->reserveElectricBorder(ElectricBorder(i), this); } borderList.clear(); borderList.append(int(ElectricNone)); borderList = CubeConfig::borderActivateSphere(); - for (auto i : qAsConst(borderList)) { + for (auto i : std::as_const(borderList)) { borderActivateSphere.append(ElectricBorder(i)); effects->reserveElectricBorder(ElectricBorder(i), this); } @@ -1278,7 +1278,7 @@ void CubeEffect::paintWindow(effect::window_paint_data& data) && (data.paint.mask & PAINT_WINDOW_TRANSFORMED)) { auto rect = effects->clientArea(FullArea, activeScreen, subspaces.at(prev_desktop)); WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() > rect.width() - data.window.x()) { new_quads.append(quad); } @@ -1291,7 +1291,7 @@ void CubeEffect::paintWindow(effect::window_paint_data& data) && (data.paint.mask & PAINT_WINDOW_TRANSFORMED)) { QRect rect = effects->clientArea(FullArea, activeScreen, subspaces.at(next_desktop)); WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (data.window.x() + quad.right() <= rect.x()) { new_quads.append(quad); } @@ -1333,7 +1333,7 @@ void CubeEffect::paintWindow(effect::window_paint_data& data) if (data.window.isOnDesktop(painting_desktop) && data.window.x() < rect.x()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() > -data.window.x()) { new_quads.append(quad); } @@ -1343,7 +1343,7 @@ void CubeEffect::paintWindow(effect::window_paint_data& data) if (data.window.isOnDesktop(painting_desktop) && data.window.x() + data.window.width() > rect.x() + rect.width()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() <= rect.width() - data.window.x()) { new_quads.append(quad); } @@ -1352,7 +1352,7 @@ void CubeEffect::paintWindow(effect::window_paint_data& data) } if (data.window.y() < rect.y()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.bottom() > -data.window.y()) { new_quads.append(quad); } @@ -1361,7 +1361,7 @@ void CubeEffect::paintWindow(effect::window_paint_data& data) } if (data.window.y() + data.window.height() > rect.y() + rect.height()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.bottom() <= rect.height() - data.window.y()) { new_quads.append(quad); } diff --git a/plugins/effects/cubeslide/cubeslide.cpp b/plugins/effects/cubeslide/cubeslide.cpp index f895270e2..0d1d28c6f 100644 --- a/plugins/effects/cubeslide/cubeslide.cpp +++ b/plugins/effects/cubeslide/cubeslide.cpp @@ -256,7 +256,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) if (data.window.isOnDesktop(painting_desktop)) { if (data.window.x() < rect.x()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() > -data.window.x()) { new_quads.append(quad); } @@ -265,7 +265,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) } if (data.window.x() + data.window.width() > rect.x() + rect.width()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() <= rect.width() - data.window.x()) { new_quads.append(quad); } @@ -274,7 +274,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) } if (data.window.y() < rect.y()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.bottom() > -data.window.y()) { new_quads.append(quad); } @@ -283,7 +283,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) } if (data.window.y() + data.window.height() > rect.y() + rect.height()) { WindowQuadList new_quads; - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.bottom() <= rect.height() - data.window.y()) { new_quads.append(quad); } @@ -299,7 +299,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) if (data.window.x() < rect.x() && (direction == Left || direction == Right)) { WindowQuadList new_quads; data.paint.geo.translation.setX(rect.width()); - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() <= -data.window.x()) { new_quads.append(quad); } @@ -311,7 +311,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) && (direction == Left || direction == Right)) { WindowQuadList new_quads; data.paint.geo.translation.setX(-rect.width()); - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.right() > rect.width() - data.window.x()) { new_quads.append(quad); } @@ -322,7 +322,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) if (data.window.y() < rect.y() && (direction == Upwards || direction == Downwards)) { WindowQuadList new_quads; data.paint.geo.translation.setY(rect.height()); - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.bottom() <= -data.window.y()) { new_quads.append(quad); } @@ -334,7 +334,7 @@ void CubeSlideEffect::paintWindow(effect::window_paint_data& data) && (direction == Upwards || direction == Downwards)) { WindowQuadList new_quads; data.paint.geo.translation.setY(-rect.height()); - for (auto const& quad : qAsConst(data.quads)) { + for (auto const& quad : std::as_const(data.quads)) { if (quad.bottom() > rect.height() - data.window.y()) { new_quads.append(quad); } @@ -408,7 +408,7 @@ void CubeSlideEffect::postPaintScreen() if (slideRotations.empty()) { auto const keys = staticWindows.keys(); - for (EffectWindow* w : qAsConst(keys)) { + for (EffectWindow* w : std::as_const(keys)) { w->setData(WindowForceBlurRole, QVariant()); w->setData(WindowForceBackgroundContrastRole, QVariant()); } @@ -764,7 +764,7 @@ void CubeSlideEffect::slotNumberDesktopsChanged() } auto const keys = staticWindows.keys(); - for (auto w : qAsConst(keys)) { + for (auto w : std::as_const(keys)) { w->setData(WindowForceBlurRole, QVariant()); w->setData(WindowForceBackgroundContrastRole, QVariant()); } diff --git a/plugins/effects/highlightwindow/highlightwindow.cpp b/plugins/effects/highlightwindow/highlightwindow.cpp index 1b52f194e..883da3a12 100644 --- a/plugins/effects/highlightwindow/highlightwindow.cpp +++ b/plugins/effects/highlightwindow/highlightwindow.cpp @@ -75,7 +75,7 @@ void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) return; } // This window was demanded to be highlighted before it appeared on the screen. - for (const WId& id : qAsConst(m_highlightedIds)) { + for (const WId& id : std::as_const(m_highlightedIds)) { if (w == effects->findWindow(id)) { const quint64 animationId = startHighlightAnimation(w); complete(animationId); diff --git a/plugins/effects/mousemark/mousemark.cpp b/plugins/effects/mousemark/mousemark.cpp index 579755344..5832d17f3 100644 --- a/plugins/effects/mousemark/mousemark.cpp +++ b/plugins/effects/mousemark/mousemark.cpp @@ -123,10 +123,10 @@ void MouseMarkEffect::paintScreen(effect::screen_paint_data& data) binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, effect::get_mvp(data)); binder.shader()->setUniform(GLShader::ColorUniform::Color, color); QVector verts; - for (auto const& mark : qAsConst(marks)) { + for (auto const& mark : std::as_const(marks)) { verts.clear(); verts.reserve(mark.size() * 2); - for (auto const& p : qAsConst(mark)) { + for (auto const& p : std::as_const(mark)) { verts.push_back(QVector2D(p.x(), p.y())); } vbo->setVertices(verts); @@ -135,7 +135,7 @@ void MouseMarkEffect::paintScreen(effect::screen_paint_data& data) if (!drawing.isEmpty()) { verts.clear(); verts.reserve(drawing.size() * 2); - for (auto const& p : qAsConst(drawing)) { + for (auto const& p : std::as_const(drawing)) { verts.push_back(QVector2D(p.x(), p.y())); } vbo->setVertices(verts); @@ -153,7 +153,7 @@ void MouseMarkEffect::paintScreen(effect::screen_paint_data& data) QPen pen(color); pen.setWidth(width); painter->setPen(pen); - for (auto const& mark : qAsConst(marks)) { + for (auto const& mark : std::as_const(marks)) { drawMark(painter, mark); } drawMark(painter, drawing); diff --git a/plugins/effects/overview/overvieweffect.cpp b/plugins/effects/overview/overvieweffect.cpp index 649630329..631f9a5f5 100644 --- a/plugins/effects/overview/overvieweffect.cpp +++ b/plugins/effects/overview/overvieweffect.cpp @@ -213,7 +213,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags) setAnimationDuration(animationTime(300)); setFilterWindows(OverviewConfig::filterWindows()); - for (const ElectricBorder& border : qAsConst(m_borderActivate)) { + for (const ElectricBorder& border : std::as_const(m_borderActivate)) { effects->unreserveElectricBorder(border, this); } diff --git a/plugins/effects/private/expolayout.cpp b/plugins/effects/private/expolayout.cpp index a2749b491..49ab3f6e5 100644 --- a/plugins/effects/private/expolayout.cpp +++ b/plugins/effects/private/expolayout.cpp @@ -485,7 +485,7 @@ void ExpoLayout::calculateWindowTransformationsNatural() QHash targets; QHash directions; - for (ExpoCell* cell : qAsConst(m_cells)) { + for (ExpoCell* cell : std::as_const(m_cells)) { const QRect cellRect( cell->naturalX(), cell->naturalY(), cell->naturalWidth(), cell->naturalHeight()); targets[cell] = cellRect; @@ -505,9 +505,9 @@ void ExpoLayout::calculateWindowTransformationsNatural() bool overlap; do { overlap = false; - for (ExpoCell* cell : qAsConst(m_cells)) { + for (ExpoCell* cell : std::as_const(m_cells)) { QRect* target_w = &targets[cell]; - for (ExpoCell* e : qAsConst(m_cells)) { + for (ExpoCell* e : std::as_const(m_cells)) { if (cell == e) { continue; } @@ -617,7 +617,7 @@ void ExpoLayout::calculateWindowTransformationsNatural() bool moved; do { moved = false; - for (ExpoCell* cell : qAsConst(m_cells)) { + 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 @@ -694,7 +694,7 @@ void ExpoLayout::calculateWindowTransformationsNatural() // 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 : qAsConst(m_cells)) { + for (ExpoCell* cell : std::as_const(m_cells)) { QRect* target = &targets[cell]; qreal scale = target->width() / qreal(cell->naturalWidth()); if (scale > 2.0 @@ -708,7 +708,7 @@ void ExpoLayout::calculateWindowTransformationsNatural() } } - for (ExpoCell* cell : qAsConst(m_cells)) { + for (ExpoCell* cell : std::as_const(m_cells)) { const QRect rect = centered(cell, targets.value(cell).marginsRemoved(cell->margins())); cell->setX(rect.x()); diff --git a/plugins/effects/screenshot/screenshot.cpp b/plugins/effects/screenshot/screenshot.cpp index d01325105..1bb080f94 100644 --- a/plugins/effects/screenshot/screenshot.cpp +++ b/plugins/effects/screenshot/screenshot.cpp @@ -139,7 +139,7 @@ QFuture ScreenShotEffect::scheduleScreenShot(const QRect& area, ScreenSh auto devicePixelRatio = 1.; if (flags & ScreenShotNativeResolution) { - for (auto const screen : qAsConst(data.screens)) { + for (auto const screen : std::as_const(data.screens)) { if (screen->devicePixelRatio() > devicePixelRatio) { devicePixelRatio = screen->devicePixelRatio(); } diff --git a/plugins/effects/slide/slide.cpp b/plugins/effects/slide/slide.cpp index ec6ab2555..8507d454f 100644 --- a/plugins/effects/slide/slide.cpp +++ b/plugins/effects/slide/slide.cpp @@ -210,7 +210,7 @@ void SlideEffect::paintWindow(effect::window_paint_data& data) const auto screens = effects->screens(); - for (auto desktop : qAsConst(m_paintCtx.visibleDesktops)) { + for (auto desktop : std::as_const(m_paintCtx.visibleDesktops)) { if (!data.window.isOnDesktop(desktop)) { continue; } @@ -333,7 +333,7 @@ void SlideEffect::finishedSwitching() w->setData(WindowForceBlurRole, QVariant()); } - for (EffectWindow* w : qAsConst(m_elevatedWindows)) { + for (EffectWindow* w : std::as_const(m_elevatedWindows)) { effects->setElevatedWindow(w, false); } diff --git a/plugins/effects/slideback/slideback.cpp b/plugins/effects/slideback/slideback.cpp index 0507c489c..425f37666 100644 --- a/plugins/effects/slideback/slideback.cpp +++ b/plugins/effects/slideback/slideback.cpp @@ -62,7 +62,7 @@ void SlideBackEffect::windowRaised(EffectWindow* w) { // Determine all windows on top of the activated one bool currentFound = false; - for (auto const& tmp : qAsConst(oldStackingOrder)) { + for (auto const& tmp : std::as_const(oldStackingOrder)) { if (!currentFound) { if (tmp == w) { currentFound = true; @@ -82,7 +82,7 @@ void SlideBackEffect::windowRaised(EffectWindow* w) } else { // Does it intersect with a moved (elevated) window and do we have to elevate it // too? - for (auto const& elevatedWindow : qAsConst(elevatedList)) { + for (auto const& elevatedWindow : std::as_const(elevatedList)) { if (tmp->frameGeometry().intersects(elevatedWindow->frameGeometry())) { effects->setElevatedWindow(tmp, true); elevatedList.append(tmp); @@ -100,7 +100,7 @@ void SlideBackEffect::windowRaised(EffectWindow* w) // If a window is minimized it could happen that the panels stay elevated without any windows // sliding. clear all elevation settings if (!motionManager.managingWindows()) { - for (auto const& tmp : qAsConst(elevatedList)) { + for (auto const& tmp : std::as_const(elevatedList)) { effects->setElevatedWindow(tmp, false); } } @@ -182,7 +182,7 @@ void SlideBackEffect::paintWindow(effect::window_paint_data& data) motionManager.apply(data); } - for (auto const& r : qAsConst(clippedRegions)) { + for (auto const& r : std::as_const(clippedRegions)) { data.paint.region = data.paint.region.intersected(r); } @@ -205,7 +205,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) // more except panels if (coveringWindows.contains(w)) { QList tmpList; - for (auto const& tmp : qAsConst(elevatedList)) { + for (auto const& tmp : std::as_const(elevatedList)) { QRect elevatedGeometry = tmp->frameGeometry(); if (motionManager.isManaging(tmp)) { elevatedGeometry @@ -224,7 +224,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) } else { if (!tmp->isDock()) { bool keepElevated = false; - for (auto const& elevatedWindow : qAsConst(tmpList)) { + for (auto const& elevatedWindow : std::as_const(tmpList)) { if (tmp->frameGeometry().intersects( elevatedWindow->frameGeometry())) { keepElevated = true; @@ -261,7 +261,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) coveringWindows.removeAll(w); if (coveringWindows.isEmpty()) { // Restore correct stacking order - for (auto const& tmp : qAsConst(elevatedList)) { + for (auto const& tmp : std::as_const(elevatedList)) { effects->setElevatedWindow(tmp, false); } elevatedList.clear(); @@ -340,7 +340,7 @@ QList SlideBackEffect::usableWindows(QList const& auto isWindowVisible = [](const EffectWindow* window) { return window && effects->virtualScreenGeometry().intersects(window->frameGeometry()); }; - for (auto const& tmp : qAsConst(allWindows)) { + for (auto const& tmp : std::as_const(allWindows)) { if (isWindowUsable(tmp) && isWindowVisible(tmp)) { retList.append(tmp); } @@ -353,7 +353,7 @@ QRect SlideBackEffect::getModalGroupGeometry(EffectWindow* w) QRect modalGroupGeometry = w->frameGeometry(); if (w->isModal()) { auto const& main_windows = w->mainWindows(); - for (auto const& modalWindow : qAsConst(main_windows)) { + for (auto const& modalWindow : std::as_const(main_windows)) { modalGroupGeometry = modalGroupGeometry.united(getModalGroupGeometry(modalWindow)); } } diff --git a/plugins/effects/thumbnailaside/thumbnailaside.cpp b/plugins/effects/thumbnailaside/thumbnailaside.cpp index 37054e357..38a22a054 100644 --- a/plugins/effects/thumbnailaside/thumbnailaside.cpp +++ b/plugins/effects/thumbnailaside/thumbnailaside.cpp @@ -81,7 +81,7 @@ void ThumbnailAsideEffect::paintScreen(effect::screen_paint_data& data) painted = QRegion(); effects->paintScreen(data); - for (auto const& d : qAsConst(windows)) { + for (auto const& d : std::as_const(windows)) { if (painted.intersects(d.rect)) { effect::window_paint_data win_data{ *d.window, @@ -105,7 +105,7 @@ void ThumbnailAsideEffect::paintWindow(effect::window_paint_data& data) void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, QRegion const&) { - for (auto const& d : qAsConst(windows)) { + for (auto const& d : std::as_const(windows)) { if (d.window == w) effects->addRepaint(d.rect); } @@ -113,7 +113,7 @@ void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, QRegion const&) void ThumbnailAsideEffect::slotWindowFrameGeometryChanged(EffectWindow* w, const QRect& old) { - for (auto const& d : qAsConst(windows)) { + for (auto const& d : std::as_const(windows)) { if (d.window == w) { if (w->size() == old.size()) effects->addRepaint(d.rect); @@ -181,7 +181,7 @@ void ThumbnailAsideEffect::arrange() int height = 0; QVector pos(windows.size()); int mwidth = 0; - for (auto const& d : qAsConst(windows)) { + for (auto const& d : std::as_const(windows)) { height += d.window->height(); mwidth = qMax(mwidth, d.window->width()); pos[d.index] = d.window->height(); @@ -212,7 +212,7 @@ void ThumbnailAsideEffect::arrange() void ThumbnailAsideEffect::repaintAll() { - for (auto const& d : qAsConst(windows)) { + for (auto const& d : std::as_const(windows)) { effects->addRepaint(d.rect); } } diff --git a/plugins/effects/windowview/windowvieweffect.cpp b/plugins/effects/windowview/windowvieweffect.cpp index c72c44454..f928f7489 100644 --- a/plugins/effects/windowview/windowvieweffect.cpp +++ b/plugins/effects/windowview/windowvieweffect.cpp @@ -166,10 +166,10 @@ void WindowViewEffect::reconfigure(ReconfigureFlags) setAnimationDuration(animationTime(300)); setLayout(WindowViewConfig::layoutMode()); - for (ElectricBorder border : qAsConst(m_borderActivate)) { + for (ElectricBorder border : std::as_const(m_borderActivate)) { effects->unreserveElectricBorder(border, this); } - for (ElectricBorder border : qAsConst(m_borderActivateAll)) { + for (ElectricBorder border : std::as_const(m_borderActivateAll)) { effects->unreserveElectricBorder(border, this); } diff --git a/plugins/idletime/poller.cpp b/plugins/idletime/poller.cpp index 49ebbb847..a550f0185 100644 --- a/plugins/idletime/poller.cpp +++ b/plugins/idletime/poller.cpp @@ -24,7 +24,7 @@ KWinIdleTimePoller::~KWinIdleTimePoller() void KWinIdleTimePoller::cleanup() { if (auto idle_interface = como::input::singleton_interface::idle_qobject) { - for (auto& listener : qAsConst(m_timeouts)) { + for (auto& listener : std::as_const(m_timeouts)) { idle_interface->unregister_listener(*listener); } if (m_catchResumeTimeout) { diff --git a/plugins/kdecorations/aurorae/src/aurorae.cpp b/plugins/kdecorations/aurorae/src/aurorae.cpp index 93ee10424..d1721f02e 100644 --- a/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -715,7 +715,7 @@ void ThemeProvider::findAllSvgThemes() themeDirectories << dir + themeDir; } } - for (const QString& dir : qAsConst(themeDirectories)) { + for (const QString& dir : std::as_const(themeDirectories)) { auto const entry_list = QDir(dir).entryList(QStringList() << QStringLiteral("metadata.desktop")); for (const QString& file : entry_list) { diff --git a/plugins/qpa/eglhelpers.cpp b/plugins/qpa/eglhelpers.cpp index 047cf250d..28b52314d 100644 --- a/plugins/qpa/eglhelpers.cpp +++ b/plugins/qpa/eglhelpers.cpp @@ -77,7 +77,7 @@ configFromFormat(EGLDisplay display, const QSurfaceFormat& surfaceFormat, EGLint return EGL_NO_CONFIG_KHR; } - for (const EGLConfig& config : qAsConst(configs)) { + for (const EGLConfig& config : std::as_const(configs)) { EGLint redConfig, greenConfig, blueConfig, alphaConfig; eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redConfig); eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenConfig); diff --git a/plugins/qpa/integration.cpp b/plugins/qpa/integration.cpp index e8a647405..903ed0005 100644 --- a/plugins/qpa/integration.cpp +++ b/plugins/qpa/integration.cpp @@ -46,7 +46,7 @@ Integration::Integration() Integration::~Integration() { - for (QPlatformScreen* platformScreen : qAsConst(m_screens)) { + for (QPlatformScreen* platformScreen : std::as_const(m_screens)) { QWindowSystemInterface::handleScreenRemoved(platformScreen); } } diff --git a/tests/plasma/main_wayland.cpp b/tests/plasma/main_wayland.cpp index 37489441e..c6965b59e 100644 --- a/tests/plasma/main_wayland.cpp +++ b/tests/plasma/main_wayland.cpp @@ -303,7 +303,7 @@ int main(int argc, char* argv[]) // start the applications passed to us as command line arguments if (auto apps = parser.positionalArguments(); !apps.isEmpty()) { - for (auto const& app_name : qAsConst(apps)) { + for (auto const& app_name : std::as_const(apps)) { auto arguments = KShell::splitArgs(app_name); if (arguments.isEmpty()) { qWarning("Failed to launch application: %s is an invalid command", From b87616dd7ba2c34d8f7631e11e82d66addc0533f Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 10:55:01 +0100 Subject: [PATCH 07/21] fix: use new event position functions Silences a deprecation warning. --- autotests/integration/internal_window.cpp | 8 ++++---- como/debug/console/wayland/input_filter.h | 4 +++- como/input/filters/fake_tablet.h | 2 +- como/render/effect/interface/offscreen_quick_view.cpp | 8 ++++---- como/render/effect/interface/quick_scene.cpp | 2 +- como/win/deco_input.h | 2 +- como/win/screen_edges.h | 10 +++++----- como/win/tabbox/tabbox.h | 4 ++-- como/win/tabbox/tabbox_handler.cpp | 4 ++-- como/win/tabbox/tabbox_handler.h | 2 +- plugins/kdecorations/aurorae/src/aurorae.cpp | 2 +- 11 files changed, 25 insertions(+), 23 deletions(-) diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp index 81543712e..1f44d1c69 100644 --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -90,20 +90,20 @@ bool HelperWindow::event(QEvent* event) void HelperWindow::mouseMoveEvent(QMouseEvent* event) { - m_latestGlobalMousePos = event->globalPos(); - Q_EMIT mouseMoved(event->globalPos()); + m_latestGlobalMousePos = event->globalPosition().toPoint(); + Q_EMIT mouseMoved(event->globalPosition().toPoint()); } void HelperWindow::mousePressEvent(QMouseEvent* event) { - m_latestGlobalMousePos = event->globalPos(); + m_latestGlobalMousePos = event->globalPosition().toPoint(); m_pressedButtons = event->buttons(); Q_EMIT mousePressed(); } void HelperWindow::mouseReleaseEvent(QMouseEvent* event) { - m_latestGlobalMousePos = event->globalPos(); + m_latestGlobalMousePos = event->globalPosition().toPoint(); m_pressedButtons = event->buttons(); Q_EMIT mouseReleased(); } diff --git a/como/debug/console/wayland/input_filter.h b/como/debug/console/wayland/input_filter.h index cf5b88db9..2d098707e 100644 --- a/como/debug/console/wayland/input_filter.h +++ b/como/debug/console/wayland/input_filter.h @@ -376,7 +376,9 @@ class input_filter : public input::event_spy auto text = QString(s_hr) + QString(s_tableStart) + tableHeaderRow(i18n("Tablet Tool")) + tableRow(i18n("EventType"), typeString) + tableRow(i18n("Position"), - QStringLiteral("%1,%2").arg(event->pos().x()).arg(event->pos().y())) + QStringLiteral("%1,%2") + .arg(event->position().toPoint().x()) + .arg(event->position().toPoint().y())) + tableRow(i18n("Tilt"), QStringLiteral("%1,%2").arg(event->xTilt()).arg(event->yTilt())) + tableRow(i18n("Rotation"), QString::number(event->rotation())) diff --git a/como/input/filters/fake_tablet.h b/como/input/filters/fake_tablet.h index 90795e763..204eed8fd 100644 --- a/como/input/filters/fake_tablet.h +++ b/como/input/filters/fake_tablet.h @@ -36,7 +36,7 @@ class fake_tablet_filter : public event_filter switch (event->type()) { case QEvent::TabletMove: case QEvent::TabletEnterProximity: - this->redirect.pointer->processMotion(event->globalPosF(), event->timestamp()); + this->redirect.pointer->processMotion(event->globalPosition(), event->timestamp()); break; case QEvent::TabletPress: this->redirect.pointer->process_button(get_event(button_state::pressed)); diff --git a/como/render/effect/interface/offscreen_quick_view.cpp b/como/render/effect/interface/offscreen_quick_view.cpp index 510495013..37e1a3415 100644 --- a/como/render/effect/interface/offscreen_quick_view.cpp +++ b/como/render/effect/interface/offscreen_quick_view.cpp @@ -311,9 +311,9 @@ void OffscreenQuickView::forwardMouseEvent(QEvent* e) if (doubleClick) { d->lastMousePressButton = Qt::NoButton; QMouseEvent doubleClickEvent(QEvent::MouseButtonDblClick, - me->localPos(), - me->windowPos(), - me->screenPos(), + me->position().toPoint(), + me->scenePosition().toPoint(), + me->globalPosition(), me->button(), me->buttons(), me->modifiers()); @@ -327,7 +327,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent* e) case QEvent::HoverLeave: case QEvent::HoverMove: { QHoverEvent* he = static_cast(e); - const QPointF widgetPos = d->m_view->mapFromGlobal(he->pos()); + auto const widgetPos = d->m_view->mapFromGlobal(he->position()); const QPointF oldWidgetPos = d->m_view->mapFromGlobal(he->oldPos()); QHoverEvent cloneEvent(he->type(), widgetPos, oldWidgetPos, he->modifiers()); QCoreApplication::sendEvent(d->m_view, &cloneEvent); diff --git a/como/render/effect/interface/quick_scene.cpp b/como/render/effect/interface/quick_scene.cpp index 491534238..ee8fffaec 100644 --- a/como/render/effect/interface/quick_scene.cpp +++ b/como/render/effect/interface/quick_scene.cpp @@ -550,7 +550,7 @@ void QuickSceneEffect::windowInputMouseEvent(QEvent* event) QPoint globalPosition; if (QMouseEvent* mouseEvent = dynamic_cast(event)) { buttons = mouseEvent->buttons(); - globalPosition = mouseEvent->globalPos(); + globalPosition = mouseEvent->globalPosition().toPoint(); } else if (QWheelEvent* wheelEvent = dynamic_cast(event)) { buttons = wheelEvent->buttons(); globalPosition = wheelEvent->globalPosition().toPoint(); diff --git a/como/win/deco_input.h b/como/win/deco_input.h index 131e32a14..e9743bb05 100644 --- a/como/win/deco_input.h +++ b/como/win/deco_input.h @@ -72,7 +72,7 @@ bool process_decoration_button_press(Win* win, QMouseEvent* event, bool ignoreMe // In the new API the decoration may process the menu action to display an inactive tab's menu. // If the event is unhandled then the core will create one for the active window in the group. if (!ignoreMenu || com != mouse_cmd::operations_menu) { - perform_mouse_command(*win, com, event->globalPos()); + perform_mouse_command(*win, com, event->globalPosition().toPoint()); } // Return events that should be passed to the decoration in the new API. diff --git a/como/win/screen_edges.h b/como/win/screen_edges.h index dba55b8af..7ed8a1061 100644 --- a/como/win/screen_edges.h +++ b/como/win/screen_edges.h @@ -1229,11 +1229,11 @@ class screen_edger continue; } - if (edge->approach_geometry.contains(event->globalPos())) { + if (edge->approach_geometry.contains(event->globalPosition().toPoint())) { if (!edge->is_approaching) { edge->startApproaching(); } else { - edge->updateApproaching(event->globalPos()); + edge->updateApproaching(event->globalPosition().toPoint()); } } else { if (edge->is_approaching) { @@ -1241,8 +1241,8 @@ class screen_edger } } - if (edge->geometry.contains(event->globalPos())) { - if (edge->check(event->globalPos(), + if (edge->geometry.contains(event->globalPosition().toPoint())) { + if (edge->check(event->globalPosition().toPoint(), std::chrono::system_clock::time_point( std::chrono::milliseconds(event->timestamp())))) { if (edge->client()) { @@ -1255,7 +1255,7 @@ class screen_edger if (activatedForClient) { for (auto& edge : edges) { if (edge->client()) { - edge->markAsTriggered(event->globalPos(), + edge->markAsTriggered(event->globalPosition().toPoint(), std::chrono::system_clock::time_point( std::chrono::milliseconds(event->timestamp()))); } diff --git a/como/win/tabbox/tabbox.h b/como/win/tabbox/tabbox.h index 0306651da..6fc344e51 100644 --- a/como/win/tabbox/tabbox.h +++ b/como/win/tabbox/tabbox.h @@ -283,7 +283,7 @@ class tabbox } switch (event->type()) { case QEvent::MouseMove: - if (!handler->contains_pos(event->globalPos())) { + if (!handler->contains_pos(event->globalPosition())) { // filter out all events which are not on the TabBox window. // We don't want windows to react on the mouse events return true; @@ -291,7 +291,7 @@ class tabbox return false; case QEvent::MouseButtonPress: if ((!is_natively_shown && is_displayed()) - || !handler->contains_pos(event->globalPos())) { + || !handler->contains_pos(event->globalPosition())) { close(); // click outside closes tab return true; } diff --git a/como/win/tabbox/tabbox_handler.cpp b/como/win/tabbox/tabbox_handler.cpp index 46de96dac..a3e032a92 100644 --- a/como/win/tabbox/tabbox_handler.cpp +++ b/como/win/tabbox/tabbox_handler.cpp @@ -433,14 +433,14 @@ void tabbox_handler::grabbed_key_event(QKeyEvent* event) const QCoreApplication::sendEvent(d->window(), event); } -bool tabbox_handler::contains_pos(const QPoint& pos) const +bool tabbox_handler::contains_pos(QPointF const& pos) const { if (!d->m_main_item) { return false; } QWindow* w = d->window(); if (w) { - return w->geometry().contains(pos); + return w->geometry().contains(pos.toPoint()); } return false; } diff --git a/como/win/tabbox/tabbox_handler.h b/como/win/tabbox/tabbox_handler.h index bccadba45..f330a154a 100644 --- a/como/win/tabbox/tabbox_handler.h +++ b/como/win/tabbox/tabbox_handler.h @@ -257,7 +257,7 @@ class COMO_EXPORT tabbox_handler : public QObject * @param pos The position to be tested in global coordinates * @return True if the view contains the point, otherwise false. */ - bool contains_pos(const QPoint& pos) const; + bool contains_pos(QPointF const& pos) const; /** * @param client The tabbox_client whose index should be returned * @return Returns the ModelIndex of given tabbox_client or an invalid ModelIndex diff --git a/plugins/kdecorations/aurorae/src/aurorae.cpp b/plugins/kdecorations/aurorae/src/aurorae.cpp index d1721f02e..e7d45b4af 100644 --- a/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -545,7 +545,7 @@ void Decoration::hoverMoveEvent(QHoverEvent* event) // turn a hover event into a mouse because we don't follow hovers as we don't think we have // focus QMouseEvent cloneEvent( - QEvent::MouseMove, event->posF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QEvent::MouseMove, event->position(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); event->setAccepted(false); m_view->forwardMouseEvent(&cloneEvent); event->setAccepted(cloneEvent.isAccepted()); From 6dde1da22f800b0e39c24845e1ca7512357382b7 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 11:03:29 +0100 Subject: [PATCH 08/21] fix: use other QHoverEvent ctor Silences a deprecation warning. --- autotests/integration/no_crash_glxgears.cpp | 2 +- como/input/filters/decoration_event.h | 59 ++++++++++--------- como/input/wayland/pointer_redirect.h | 8 +-- .../effect/interface/offscreen_quick_view.cpp | 2 +- como/win/x11/event.h | 11 ++-- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/autotests/integration/no_crash_glxgears.cpp b/autotests/integration/no_crash_glxgears.cpp index 9708e1f6a..be617999b 100644 --- a/autotests/integration/no_crash_glxgears.cpp +++ b/autotests/integration/no_crash_glxgears.cpp @@ -44,7 +44,7 @@ TEST_CASE("no crash glxgears", "[xwl],[win]") // a fake deco for autotests. QPointF pos = decoration->rect().topRight() + QPointF(-decoration->borderTop() / 2, decoration->borderTop() / 2); - QHoverEvent event(QEvent::HoverMove, pos, pos); + QHoverEvent event(QEvent::HoverMove, pos, pos, pos); QCoreApplication::instance()->sendEvent(decoration, &event); // mouse press diff --git a/como/input/filters/decoration_event.h b/como/input/filters/decoration_event.h index 3e191c019..08e61a214 100644 --- a/como/input/filters/decoration_event.h +++ b/como/input/filters/decoration_event.h @@ -89,7 +89,7 @@ class decoration_event_filter : public event_filter auto const global_pos = this->redirect.globalPointer(); auto const local_pos = global_pos - win->geo.pos(); - auto qt_event = QHoverEvent(QEvent::HoverMove, local_pos, local_pos); + auto qt_event = QHoverEvent(QEvent::HoverMove, local_pos, local_pos, local_pos); QCoreApplication::instance()->sendEvent(decoration->decoration(), &qt_event); win::process_decoration_move(win, local_pos.toPoint(), global_pos.toPoint()); return true; @@ -163,29 +163,32 @@ class decoration_event_filter : public event_filter assert(this->redirect.touch->focus.deco.window); - return std::visit( - overload{[&](auto&& win) { - this->redirect.touch->setDecorationPressId(event.id); - m_lastGlobalTouchPos = event.pos; - m_lastLocalTouchPos = event.pos - win->geo.pos(); - - QHoverEvent hoverEvent(QEvent::HoverMove, m_lastLocalTouchPos, m_lastLocalTouchPos); - QCoreApplication::sendEvent(decoration->decoration(), &hoverEvent); - - QMouseEvent e(QEvent::MouseButtonPress, - m_lastLocalTouchPos, - event.pos, - Qt::LeftButton, - Qt::LeftButton, - xkb::get_active_keyboard_modifiers(this->redirect.platform)); - e.setAccepted(false); - QCoreApplication::sendEvent(decoration->decoration(), &e); - if (!e.isAccepted()) { - win::process_decoration_button_press(win, &e, false); - } - return true; - }}, - *this->redirect.touch->focus.deco.window); + return std::visit(overload{[&](auto&& win) { + this->redirect.touch->setDecorationPressId(event.id); + m_lastGlobalTouchPos = event.pos; + m_lastLocalTouchPos = event.pos - win->geo.pos(); + + QHoverEvent hoverEvent(QEvent::HoverMove, + m_lastLocalTouchPos, + m_lastLocalTouchPos, + m_lastLocalTouchPos); + QCoreApplication::sendEvent(decoration->decoration(), &hoverEvent); + + QMouseEvent e( + QEvent::MouseButtonPress, + m_lastLocalTouchPos, + event.pos, + Qt::LeftButton, + Qt::LeftButton, + xkb::get_active_keyboard_modifiers(this->redirect.platform)); + e.setAccepted(false); + QCoreApplication::sendEvent(decoration->decoration(), &e); + if (!e.isAccepted()) { + win::process_decoration_button_press(win, &e, false); + } + return true; + }}, + *this->redirect.touch->focus.deco.window); } bool touch_motion(touch_motion_event const& event) override @@ -210,8 +213,10 @@ class decoration_event_filter : public event_filter m_lastGlobalTouchPos = event.pos; m_lastLocalTouchPos = event.pos - win->geo.pos(); - QHoverEvent e( - QEvent::HoverMove, m_lastLocalTouchPos, m_lastLocalTouchPos); + QHoverEvent e(QEvent::HoverMove, + m_lastLocalTouchPos, + m_lastLocalTouchPos, + m_lastLocalTouchPos); QCoreApplication::instance()->sendEvent(decoration->decoration(), &e); win::process_decoration_move( win, m_lastLocalTouchPos.toPoint(), event.pos.toPoint()); @@ -251,7 +256,7 @@ class decoration_event_filter : public event_filter std::visit(overload{[&](auto&& win) { win::process_decoration_button_release(win, &e); }}, *this->redirect.touch->focus.deco.window); - QHoverEvent leaveEvent(QEvent::HoverLeave, QPointF(), QPointF()); + QHoverEvent leaveEvent(QEvent::HoverLeave, QPointF(), QPointF(), QPointF()); QCoreApplication::sendEvent(decoration->decoration(), &leaveEvent); m_lastGlobalTouchPos = QPointF(); diff --git a/como/input/wayland/pointer_redirect.h b/como/input/wayland/pointer_redirect.h index ab8693f5c..b0d7b995a 100644 --- a/como/input/wayland/pointer_redirect.h +++ b/como/input/wayland/pointer_redirect.h @@ -585,7 +585,7 @@ class pointer_redirect redirect->space.focusMousePos = position().toPoint(); // send leave event to decoration - QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF()); + QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF(), QPointF()); QCoreApplication::instance()->sendEvent(focus.deco.client->decoration(), &event); focus.deco = {}; @@ -600,7 +600,7 @@ class pointer_redirect redirect->platform.base.server->seat()->pointers().set_focused_surface(nullptr); auto pos = m_pos - now.client()->geo.pos(); - QHoverEvent event(QEvent::HoverEnter, pos, pos); + QHoverEvent event(QEvent::HoverEnter, pos, pos, pos); QCoreApplication::instance()->sendEvent(now.decoration(), &event); win::process_decoration_move(now.client(), pos.toPoint(), m_pos.toPoint()); @@ -637,7 +637,7 @@ class pointer_redirect // position of window did not change, we need to send // HoverMotion manually QPointF const p = m_pos - win->geo.pos(); - QHoverEvent event(QEvent::HoverMove, p, p); + QHoverEvent event(QEvent::HoverMove, p, p, p); QCoreApplication::instance()->sendEvent(deco->decoration(), &event); }}, *focus.deco.window); @@ -814,7 +814,7 @@ class pointer_redirect device_redirect_set_internal_window(this, nullptr); } if (focus.deco.client) { - QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF()); + QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF(), QPointF()); QCoreApplication::instance()->sendEvent(focus.deco.client->decoration(), &event); device_redirect_unset_deco(this); } diff --git a/como/render/effect/interface/offscreen_quick_view.cpp b/como/render/effect/interface/offscreen_quick_view.cpp index 37e1a3415..dd8dc9ca1 100644 --- a/como/render/effect/interface/offscreen_quick_view.cpp +++ b/como/render/effect/interface/offscreen_quick_view.cpp @@ -329,7 +329,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent* e) QHoverEvent* he = static_cast(e); auto const widgetPos = d->m_view->mapFromGlobal(he->position()); const QPointF oldWidgetPos = d->m_view->mapFromGlobal(he->oldPos()); - QHoverEvent cloneEvent(he->type(), widgetPos, oldWidgetPos, he->modifiers()); + QHoverEvent cloneEvent(he->type(), widgetPos, widgetPos, oldWidgetPos, he->modifiers()); QCoreApplication::sendEvent(d->m_view, &cloneEvent); e->setAccepted(cloneEvent.isAccepted()); return; diff --git a/como/win/x11/event.h b/como/win/x11/event.h index 0b9fc4006..e835a105e 100644 --- a/como/win/x11/event.h +++ b/como/win/x11/event.h @@ -383,8 +383,11 @@ void leave_notify_event(Win* win, xcb_leave_notify_event_t* e) if (auto deco = win::decoration(win)) { // sending a move instead of a leave. With leave we need to send proper coords, with // move it's handled internally - QHoverEvent leaveEvent( - QEvent::HoverMove, QPointF(-1, -1), QPointF(-1, -1), Qt::NoModifier); + QHoverEvent leaveEvent(QEvent::HoverMove, + QPointF(-1, -1), + QPointF(-1, -1), + QPointF(-1, -1), + Qt::NoModifier); QCoreApplication::sendEvent(deco, &leaveEvent); } } @@ -613,7 +616,7 @@ bool motion_notify_event(Win* win, xcb_window_t w, int state, int x, int y, int { if (w == win->frameId() && win::decoration(win) && !win->control->minimized) { // TODO Mouse move event dependent on state - QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y)); + QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y), QPointF(x, y)); QCoreApplication::instance()->sendEvent(win::decoration(win), &event); } if (w != win->frameId() && w != win->xcb_windows.input && w != win->xcb_windows.grab) { @@ -626,7 +629,7 @@ bool motion_notify_event(Win* win, xcb_window_t w, int state, int x, int y, int int y = y_root - win->geo.frame.y(); // + padding_top; if (win::decoration(win)) { - QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y)); + QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y), QPointF(x, y)); QCoreApplication::instance()->sendEvent(win::decoration(win), &event); } } From 34036a4aa2110f3c430c43395b333feb4e596389 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 11:07:22 +0100 Subject: [PATCH 09/21] fix: use other QMouseEvent ctor Silences a deprecation warning. --- plugins/kdecorations/aurorae/src/aurorae.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/kdecorations/aurorae/src/aurorae.cpp b/plugins/kdecorations/aurorae/src/aurorae.cpp index e7d45b4af..786880d65 100644 --- a/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -544,8 +544,12 @@ void Decoration::hoverMoveEvent(QHoverEvent* event) if (m_view) { // turn a hover event into a mouse because we don't follow hovers as we don't think we have // focus - QMouseEvent cloneEvent( - QEvent::MouseMove, event->position(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QMouseEvent cloneEvent(QEvent::MouseMove, + event->position(), + event->position(), + Qt::NoButton, + Qt::NoButton, + Qt::NoModifier); event->setAccepted(false); m_view->forwardMouseEvent(&cloneEvent); event->setAccepted(cloneEvent.isAccepted()); From 287da2363a3ca942e4cfe8e2fedb7fc7f54a63b7 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 11:09:42 +0100 Subject: [PATCH 10/21] fix: replace usage of QVariant::type Silences a deprecation warning. --- autotests/integration/subspace.cpp | 4 ++-- como/debug/console/console.cpp | 2 +- como/debug/support_info.h | 2 +- plugins/kdecorations/aurorae/src/aurorae.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/autotests/integration/subspace.cpp b/autotests/integration/subspace.cpp index 173825e12..24a14850d 100644 --- a/autotests/integration/subspace.cpp +++ b/autotests/integration/subspace.cpp @@ -207,8 +207,8 @@ TEST_CASE("subspace", "[win]") if (!spy.isEmpty()) { auto arguments = spy.takeFirst(); QCOMPARE(arguments.count(), 2); - QCOMPARE(arguments.at(0).type(), QVariant::UInt); - QCOMPARE(arguments.at(1).type(), QVariant::UInt); + QCOMPARE(arguments.at(0).typeId(), QMetaType::UInt); + QCOMPARE(arguments.at(1).typeId(), QMetaType::UInt); QCOMPARE(arguments.at(0).toUInt(), count_init_value); QCOMPARE(arguments.at(1).toUInt(), test_data.result); } diff --git a/como/debug/console/console.cpp b/como/debug/console/console.cpp index 6a7df9545..023e54ccc 100644 --- a/como/debug/console/console.cpp +++ b/como/debug/console/console.cpp @@ -33,7 +33,7 @@ console_delegate::~console_delegate() = default; QString console_delegate::displayText(const QVariant& value, const QLocale& locale) const { // See Qt docs. Return value of QVariant::type() should be interpreted as QMetaType. - switch (static_cast(value.type())) { + switch (value.typeId()) { case QMetaType::QPoint: { const QPoint p = value.toPoint(); return QStringLiteral("%1,%2").arg(p.x()).arg(p.y()); diff --git a/como/debug/support_info.h b/como/debug/support_info.h index a0d398d9f..80d598d4f 100644 --- a/como/debug/support_info.h +++ b/como/debug/support_info.h @@ -94,7 +94,7 @@ QString get_support_info(Space const& space) auto const metaOptions = space.base.mod.script->options->metaObject(); auto printProperty = [](const QVariant& variant) { - if (variant.type() == QVariant::Size) { + if (variant.typeId() == QMetaType::QSize) { const QSize& s = variant.toSize(); return QStringLiteral("%1x%2") .arg(QString::number(s.width())) diff --git a/plugins/kdecorations/aurorae/src/aurorae.cpp b/plugins/kdecorations/aurorae/src/aurorae.cpp index 786880d65..5e0a2bf30 100644 --- a/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -637,7 +637,7 @@ void Decoration::updateBlur() mask = QRect(0, 0, m_item->width(), m_item->height()); } else { const QVariant maskProperty = m_item->property("decorationMask"); - if (static_cast(maskProperty.type()) == QMetaType::QRegion) { + if (maskProperty.typeId() == QMetaType::QRegion) { mask = maskProperty.value(); if (!mask.isNull()) { From e0e4c375ef14194464f4c6cfa1c058de750ba1f4 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 16:12:05 +0100 Subject: [PATCH 11/21] fix: silence keyword-macro warning In two particular cases it is necessary when including C files. In the test we don't require the keyword redefine actually. --- autotests/integration/scripting/screen_edge.cpp | 5 +---- como/base/x11/xcb/extensions.cpp | 3 +++ como/input/x11/xkb.h | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/autotests/integration/scripting/screen_edge.cpp b/autotests/integration/scripting/screen_edge.cpp index c0d2cb2f1..4c05f5311 100644 --- a/autotests/integration/scripting/screen_edge.cpp +++ b/autotests/integration/scripting/screen_edge.cpp @@ -11,11 +11,8 @@ SPDX-License-Identifier: GPL-2.0-or-later #include "como/render/effect_loader.h" #include "como/script/platform.h" #include "como/script/script.h" -#include "como/win/space_reconfigure.h" - -#define private public #include "como/win/screen_edges.h" -#undef private +#include "como/win/space_reconfigure.h" #include #include diff --git a/como/base/x11/xcb/extensions.cpp b/como/base/x11/xcb/extensions.cpp index fee7be1c7..0726a47c7 100644 --- a/como/base/x11/xcb/extensions.cpp +++ b/como/base/x11/xcb/extensions.cpp @@ -19,7 +19,10 @@ #include #include +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" #define explicit cpp_explicit_compat +#pragma clang diagnostic pop #include #undef explicit diff --git a/como/input/x11/xkb.h b/como/input/x11/xkb.h index 704f88518..cd016bfe0 100644 --- a/como/input/x11/xkb.h +++ b/como/input/x11/xkb.h @@ -9,7 +9,10 @@ #include #include +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" #define explicit cpp_explicit_compat +#pragma clang diagnostic pop #include #undef explicit #include From 6e2e5bdf4c7feeae8164c0a5f11824ccfe8a0359 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 13:49:19 +0100 Subject: [PATCH 12/21] fix: use nullptr Silences a warning. --- autotests/integration/lockscreen.cpp | 2 +- autotests/integration/plasma_surface.cpp | 10 ++++++---- autotests/integration/transient_placement.cpp | 10 ++++++---- como/base/x11/xcb/wrapper.h | 2 +- .../backend/wlroots/wlr_non_owning_data_buffer.h | 4 ++-- como/script/window_thumbnail_item.cpp | 4 ++-- como/script/window_thumbnail_item.h | 2 +- como/win/screen_edges.h | 2 +- como/win/wayland/xdg_activation.h | 2 +- plugins/effects/snaphelper/snaphelper.cpp | 6 +++--- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp index 2fbb26438..d2a837770 100644 --- a/autotests/integration/lockscreen.cpp +++ b/autotests/integration/lockscreen.cpp @@ -37,7 +37,7 @@ void unlock() QMetaObject::invokeMethod(*it, "requestUnlock"); return; } - Q_ASSERT("Did not find 'requestUnlock' method in KSldApp. This should not happen!" == 0); + Q_ASSERT("Did not find 'requestUnlock' method in KSldApp. This should not happen!" == nullptr); } } diff --git a/autotests/integration/plasma_surface.cpp b/autotests/integration/plasma_surface.cpp index 25e5003e7..3ba5fcd3b 100644 --- a/autotests/integration/plasma_surface.cpp +++ b/autotests/integration/plasma_surface.cpp @@ -195,8 +195,9 @@ TEST_CASE("plasma surface", "[win]") QVERIFY(win::is_dock(panel)); QCOMPARE(panel->geo.frame, test_data.panel_geo); QCOMPARE(panel->hasStrut(), false); - QCOMPARE(win::space_window_area(*setup.base->mod.space, win::area_option::maximize, 0, 0), - QRect(0, 0, 1280, 1024)); + QCOMPARE( + win::space_window_area(*setup.base->mod.space, win::area_option::maximize, nullptr, 0), + QRect(0, 0, 1280, 1024)); QCOMPARE(win::get_layer(*panel), win::layer::above); // create a Window @@ -342,8 +343,9 @@ TEST_CASE("plasma surface", "[win]") QVERIFY(win::is_dock(c)); QCOMPARE(c->geo.frame, QRect(0, 0, 100, 50)); REQUIRE(c->hasStrut() == test_data.expected_strut); - REQUIRE(win::space_window_area(*setup.base->mod.space, win::area_option::maximize, 0, 0) - == test_data.expected_max_area); + REQUIRE( + win::space_window_area(*setup.base->mod.space, win::area_option::maximize, nullptr, 0) + == test_data.expected_max_area); REQUIRE(win::get_layer(*c) == test_data.expected_layer); } diff --git a/autotests/integration/transient_placement.cpp b/autotests/integration/transient_placement.cpp index df592907d..93ae4c183 100644 --- a/autotests/integration/transient_placement.cpp +++ b/autotests/integration/transient_placement.cpp @@ -498,8 +498,9 @@ TEST_CASE("transient placement", "[win]") // Placement area still full screen. QVERIFY( - win::space_window_area(*setup.base->mod.space, win::area_option::placement, 0, 1) - == win::space_window_area(*setup.base->mod.space, win::area_option::fullscreen, 0, 1)); + win::space_window_area(*setup.base->mod.space, win::area_option::placement, nullptr, 1) + == win::space_window_area( + *setup.base->mod.space, win::area_option::fullscreen, nullptr, 1)); // Now map the panel and placement area is reduced. auto dock = render_and_wait_for_shown(surface, QSize(1280, 50), Qt::blue); @@ -509,8 +510,9 @@ TEST_CASE("transient placement", "[win]") QCOMPARE(dock->geo.frame, QRect(0, get_output(0)->geometry().height() - 50, 1280, 50)); QCOMPARE(dock->hasStrut(), true); QVERIFY( - win::space_window_area(*setup.base->mod.space, win::area_option::placement, 0, 1) - != win::space_window_area(*setup.base->mod.space, win::area_option::fullscreen, 0, 1)); + win::space_window_area(*setup.base->mod.space, win::area_option::placement, nullptr, 1) + != win::space_window_area( + *setup.base->mod.space, win::area_option::fullscreen, nullptr, 1)); // Create parent auto parentSurface = create_surface(); diff --git a/como/base/x11/xcb/wrapper.h b/como/base/x11/xcb/wrapper.h index 394174642..fded4af15 100644 --- a/como/base/x11/xcb/wrapper.h +++ b/como/base/x11/xcb/wrapper.h @@ -232,7 +232,7 @@ class abstract_wrapper inline bool is_null() const { const_cast(this)->get_reply(); - return m_reply == NULL; + return m_reply == nullptr; } inline operator bool() { diff --git a/como/render/backend/wlroots/wlr_non_owning_data_buffer.h b/como/render/backend/wlroots/wlr_non_owning_data_buffer.h index 5478c3cdd..e2eca9946 100644 --- a/como/render/backend/wlroots/wlr_non_owning_data_buffer.h +++ b/como/render/backend/wlroots/wlr_non_owning_data_buffer.h @@ -59,8 +59,8 @@ static inline wlr_non_owning_data_buffer* wlr_non_owning_data_buffer_create(uint auto buffer = static_cast(calloc(1, sizeof(wlr_non_owning_data_buffer))); - if (buffer == NULL) { - return NULL; + if (!buffer) { + return nullptr; } wlr_buffer_init(&buffer->base, &wlr_non_owning_data_buffer_impl, width, height); diff --git a/como/script/window_thumbnail_item.cpp b/como/script/window_thumbnail_item.cpp index 4c8c66756..c09d1e26a 100644 --- a/como/script/window_thumbnail_item.cpp +++ b/como/script/window_thumbnail_item.cpp @@ -200,7 +200,7 @@ void window_thumbnail_item::destroyOffscreenTexture() if (m_acquireFence) { glDeleteSync(m_acquireFence); - m_acquireFence = 0; + m_acquireFence = nullptr; } effects->doneOpenGLContextCurrent(); } @@ -216,7 +216,7 @@ QSGNode* window_thumbnail_item::updatePaintNode(QSGNode* oldNode, QQuickItem::Up if (m_acquireFence) { glClientWaitSync(m_acquireFence, GL_SYNC_FLUSH_COMMANDS_BIT, 5000); glDeleteSync(m_acquireFence); - m_acquireFence = 0; + m_acquireFence = nullptr; } if (!m_provider) { diff --git a/como/script/window_thumbnail_item.h b/como/script/window_thumbnail_item.h index 2e1fb54de..d962ca962 100644 --- a/como/script/window_thumbnail_item.h +++ b/como/script/window_thumbnail_item.h @@ -76,7 +76,7 @@ class COMO_EXPORT window_thumbnail_item : public QQuickItem mutable ThumbnailTextureProvider* m_provider = nullptr; QSharedPointer m_offscreenTexture; QScopedPointer m_offscreenTarget; - GLsync m_acquireFence = 0; + GLsync m_acquireFence{nullptr}; qreal m_devicePixelRatio = 1; QMetaObject::Connection render_notifier; diff --git a/como/win/screen_edges.h b/como/win/screen_edges.h index 7ed8a1061..b1894d8e2 100644 --- a/como/win/screen_edges.h +++ b/como/win/screen_edges.h @@ -1727,7 +1727,7 @@ class screen_edger auto const& outputs = space.base.outputs; auto const geo = window->geo.frame; - auto const fullArea = space_window_area(space, area_option::full, 0, 1); + auto const fullArea = space_window_area(space, area_option::full, nullptr, 1); base::output* foundOutput = nullptr; for (auto output : outputs) { diff --git a/como/win/wayland/xdg_activation.h b/como/win/wayland/xdg_activation.h index 9624999cb..7e1d59ccd 100644 --- a/como/win/wayland/xdg_activation.h +++ b/como/win/wayland/xdg_activation.h @@ -32,7 +32,7 @@ inline constexpr size_t token_strlen{33}; inline bool generate_token(char out[token_strlen]) { - static FILE* urandom = NULL; + static FILE* urandom = nullptr; uint64_t data[2]; if (!urandom) { diff --git a/plugins/effects/snaphelper/snaphelper.cpp b/plugins/effects/snaphelper/snaphelper.cpp index 8a20f2c22..077216f96 100644 --- a/plugins/effects/snaphelper/snaphelper.cpp +++ b/plugins/effects/snaphelper/snaphelper.cpp @@ -30,7 +30,7 @@ static QRegion computeDirtyRegion(const QRect& windowRect) const QList screens = effects->screens(); for (EffectScreen* screen : screens) { - const QRect screenRect = effects->clientArea(ScreenArea, screen, 0); + auto const screenRect = effects->clientArea(ScreenArea, screen, nullptr); QRect screenWindowRect = windowRect; screenWindowRect.moveCenter(screenRect.center()); @@ -113,7 +113,7 @@ void SnapHelperEffect::paintScreen(effect::screen_paint_data& data) QVector verts; verts.reserve(screens.size() * 24); for (EffectScreen* screen : screens) { - const QRect rect = effects->clientArea(ScreenArea, screen, 0); + auto const rect = effects->clientArea(ScreenArea, screen, nullptr); const int midX = rect.x() + rect.width() / 2; const int midY = rect.y() + rect.height() / 2; const int halfWidth = m_geometry.width() / 2; @@ -160,7 +160,7 @@ void SnapHelperEffect::paintScreen(effect::screen_paint_data& data) painter->setBrush(Qt::NoBrush); for (EffectScreen* screen : screens) { - const QRect rect = effects->clientArea(ScreenArea, screen, 0); + auto const rect = effects->clientArea(ScreenArea, screen, nullptr); // Center lines. painter->drawLine( rect.center().x(), rect.y(), rect.center().x(), rect.y() + rect.height()); From ec582f76337a5c051f1332ae38dee3d6b1bf38b3 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 14:14:06 +0100 Subject: [PATCH 13/21] fix: use QKeyCombination instead of int cast Silences a warning. --- autotests/integration/move_resize_window.cpp | 2 +- como/input/filters/move_resize.h | 26 +++++++++++--------- como/input/filters/tabbox.h | 8 ++++-- como/input/wayland/platform.h | 2 +- como/input/x11/platform.h | 2 +- como/win/tabbox/tabbox.h | 8 +++--- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/autotests/integration/move_resize_window.cpp b/autotests/integration/move_resize_window.cpp index 23322ab78..7838d0695 100644 --- a/autotests/integration/move_resize_window.cpp +++ b/autotests/integration/move_resize_window.cpp @@ -135,7 +135,7 @@ TEST_CASE("move resize window", "[win]") QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); QCOMPARE(windowStepUserMovedResizedSpy.count(), 1); - win::key_press_event(c, Qt::Key_Down | Qt::ALT); + win::key_press_event(c, QKeyCombination(Qt::Key_Down | Qt::ALT).toCombined()); win::update_move_resize(c, cursor()->pos()); QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); QCOMPARE(windowStepUserMovedResizedSpy.count(), 2); diff --git a/como/input/filters/move_resize.h b/como/input/filters/move_resize.h index f7d438236..e58816bd9 100644 --- a/como/input/filters/move_resize.h +++ b/como/input/filters/move_resize.h @@ -59,18 +59,20 @@ class move_resize_filter : public event_filter void process_key_press(typename Redirect::window_t window, key_event const& event) { - std::visit(overload{[&](auto&& win) { - win::key_press_event( - win, - key_to_qt_key(event.keycode, event.base.dev->xkb.get()) - | xkb::get_active_keyboard_modifiers(this->redirect.platform)); - - if (win::is_move(win) || win::is_resize(win)) { - // Only update if mode didn't end. - win::update_move_resize(win, this->redirect.globalPointer()); - } - }}, - window); + std::visit( + overload{[&](auto&& win) { + win::key_press_event( + win, + QKeyCombination(xkb::get_active_keyboard_modifiers(this->redirect.platform), + key_to_qt_key(event.keycode, event.base.dev->xkb.get())) + .toCombined()); + + if (win::is_move(win) || win::is_resize(win)) { + // Only update if mode didn't end. + win::update_move_resize(win, this->redirect.globalPointer()); + } + }}, + window); } bool key(key_event const& event) override diff --git a/como/input/filters/tabbox.h b/como/input/filters/tabbox.h index dfc5fa680..3c2cf4c1e 100644 --- a/como/input/filters/tabbox.h +++ b/como/input/filters/tabbox.h @@ -71,7 +71,9 @@ class tabbox_filter : public event_filter if (event.state == key_state::pressed) { auto mods = xkb::get_active_keyboard_modifiers(this->redirect.platform); - tabbox->key_press(mods | key_to_qt_key(event.keycode, event.base.dev->xkb.get())); + tabbox->key_press( + QKeyCombination(mods, key_to_qt_key(event.keycode, event.base.dev->xkb.get())) + .toCombined()); } else if (xkb::get_active_keyboard_modifiers_relevant_for_global_shortcuts( this->redirect.platform) == Qt::NoModifier) { @@ -89,7 +91,9 @@ class tabbox_filter : public event_filter } auto mods = xkb::get_active_keyboard_modifiers(this->redirect.platform); - tabbox->key_press(mods | key_to_qt_key(event.keycode, event.base.dev->xkb.get())); + tabbox->key_press( + QKeyCombination(mods, key_to_qt_key(event.keycode, event.base.dev->xkb.get())) + .toCombined()); return true; } diff --git a/como/input/wayland/platform.h b/como/input/wayland/platform.h index 2577b08ed..2908c63f9 100644 --- a/como/input/wayland/platform.h +++ b/como/input/wayland/platform.h @@ -151,7 +151,7 @@ class platform bool are_mod_keys_depressed(QKeySequence const& seq) const { - const int mod = seq[seq.count() - 1] & Qt::KeyboardModifierMask; + auto const mod = seq[seq.count() - 1].toCombined() & Qt::KeyboardModifierMask; auto const mods = xkb::get_active_keyboard_modifiers_relevant_for_global_shortcuts(*this); if ((mod & Qt::SHIFT) && mods.testFlag(Qt::ShiftModifier)) { diff --git a/como/input/x11/platform.h b/como/input/x11/platform.h index 7fcf3ff5c..b8b89a138 100644 --- a/como/input/x11/platform.h +++ b/como/input/x11/platform.h @@ -106,7 +106,7 @@ class platform { uint rgKeySyms[10]; int nKeySyms = 0; - int mod = seq[seq.count() - 1] & Qt::KeyboardModifierMask; + auto mod = seq[seq.count() - 1].toCombined() & Qt::KeyboardModifierMask; if (mod & Qt::SHIFT) { rgKeySyms[nKeySyms++] = XK_Shift_L; diff --git a/como/win/tabbox/tabbox.h b/como/win/tabbox/tabbox.h index 6fc344e51..69a278dd7 100644 --- a/como/win/tabbox/tabbox.h +++ b/como/win/tabbox/tabbox.h @@ -417,7 +417,7 @@ class tabbox auto contains = [](QKeySequence const& shortcut, int key) -> bool { for (int i = 0; i < shortcut.count(); ++i) { - if (shortcut[i] == key) { + if (shortcut[i].toCombined() == key) { return true; } } @@ -440,10 +440,12 @@ class tabbox | Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier; mods &= keyQt; if ((keyQt & ~mods) == Qt::Key_Tab) { - if (contains(forward, mods | Qt::Key_Backtab)) + if (contains(forward, QKeyCombination(mods, Qt::Key_Backtab).toCombined())) { return Forward; - if (contains(backward, mods | Qt::Key_Backtab)) + } + if (contains(backward, QKeyCombination(mods, Qt::Key_Backtab).toCombined())) { return Backward; + } } // if the shortcuts do not match, try matching again after filtering the shift key from From 7dcf518cc0156f50c0087178cf81c69f4e515a9e Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 15:28:51 +0100 Subject: [PATCH 14/21] test: omit embedding directive within GENERATE macro This is undefined behavior. Silences a warning. --- autotests/integration/global_shortcuts.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/autotests/integration/global_shortcuts.cpp b/autotests/integration/global_shortcuts.cpp index b5f2eb6fa..a774bb1e9 100644 --- a/autotests/integration/global_shortcuts.cpp +++ b/autotests/integration/global_shortcuts.cpp @@ -54,19 +54,24 @@ TEST_CASE("global shortcuts", "[input]") mod_data{KEY_LEFTSHIFT, Qt::SHIFT}, mod_data{KEY_LEFTMETA, Qt::META}); + // TODO(romangg): grave key is still not working with Qt6. + // More common case with any Latin1 symbol keys, including punctuation, + // should work also. "`" key has a "ё" letter on Russian layout. + // FIXME: QTBUG-90611 +#if 1 auto key_test_data = GENERATE( // Tab is example of a key usually the same on different layouts, check it first. key_data{KEY_TAB, Qt::Key_Tab}, -#if 1 // Then check a key with a Latin letter. The symbol will probably be differ on non-Latin // layout. On Russian layout, "w" key has a cyrillic letter "ц". key_data{KEY_W, Qt::Key_W}); #else + auto key_test_data = GENERATE( + // Tab is example of a key usually the same on different layouts, check it first. + key_data{KEY_TAB, Qt::Key_Tab}, + // Then check a key with a Latin letter. The symbol will probably be differ on non-Latin + // layout. On Russian layout, "w" key has a cyrillic letter "ц". key_data{KEY_W, Qt::Key_W}, - // TODO(romangg): grave key is still not working with Qt6. - // More common case with any Latin1 symbol keys, including punctuation, - // should work also. "`" key has a "ё" letter on Russian layout. - // FIXME: QTBUG-90611 key_data{KEY_GRAVE, Qt::Key_QuoteLeft}); #endif From 11d62d5436e2a2e7eda2590e6ee8008d9a4773e4 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 15:39:48 +0100 Subject: [PATCH 15/21] fix: use std::unique_ptr instead of QScopedPointer Silences a warning on the deprecated take function. --- como/render/effect/interface/offscreen_quick_view.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/como/render/effect/interface/offscreen_quick_view.cpp b/como/render/effect/interface/offscreen_quick_view.cpp index dd8dc9ca1..23eac93af 100644 --- a/como/render/effect/interface/offscreen_quick_view.cpp +++ b/como/render/effect/interface/offscreen_quick_view.cpp @@ -611,16 +611,16 @@ void OffscreenQuickScene::setSource(const QUrl& source, const QVariantMap& initi d->quickItem.reset(); - QScopedPointer qmlObject( + auto qmlObject = std::make_unique( d->qmlComponent->createWithInitialProperties(initialProperties)); - QQuickItem* item = qobject_cast(qmlObject.data()); + auto item = qobject_cast(qmlObject.get()); if (!item) { qCWarning(KWIN_CORE) << "Root object of effect quick view" << source << "is not a QQuickItem"; return; } - qmlObject.take(); + qmlObject.release(); d->quickItem.reset(item); item->setParentItem(contentItem()); From 4858981f99463155fd1d52680636fcb032255131 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 15:49:01 +0100 Subject: [PATCH 16/21] build: disable cast-align warnings on clang With wlroots and libwayland we have too many C casts like this. For now disable the cast-align warning again. Should we instead wrap the calls and disable the warnings with pragma more targeted? --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 1c0d021da..725e25831 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -20,7 +20,7 @@ "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" + "DEBUG_CXX_FLAGS_CLANG": "$env{DEBUG_CXX_FLAGS} -fno-operator-names -Wno-gnu-zero-variadic-macro-arguments -Wno-cast-align" } }, { From e4d0b9104527c2ba6d7694804a004bc928879466 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 15:57:04 +0100 Subject: [PATCH 17/21] fix: replace QIcon::actualSize The function with QWindow argument has been deprecated. Use the new one instead, that just omits the argument. --- como/script/window_thumbnail_item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/como/script/window_thumbnail_item.cpp b/como/script/window_thumbnail_item.cpp index c09d1e26a..1ab9c6449 100644 --- a/como/script/window_thumbnail_item.cpp +++ b/como/script/window_thumbnail_item.cpp @@ -337,7 +337,7 @@ void window_thumbnail_item::updateImplicitSize() QImage window_thumbnail_item::fallbackImage() const { if (m_client) { - return m_client->icon().pixmap(window(), boundingRect().size().toSize()).toImage(); + return m_client->icon().pixmap(boundingRect().size().toSize()).toImage(); } return QImage(); } @@ -356,7 +356,7 @@ QRectF window_thumbnail_item::paintedRect() const return QRectF(); } if (!m_offscreenTexture) { - auto const iconSize = m_client->icon().actualSize(window(), boundingRect().size().toSize()); + auto const iconSize = m_client->icon().actualSize(boundingRect().size().toSize()); return centeredSize(boundingRect(), iconSize); } From d9d789bc5a69c44934ef1b10cf55725e18c4b227 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 16:25:54 +0100 Subject: [PATCH 18/21] build: compile clang presets with -Werror To improve robustness now compile with clang with warnings as errors. We only make two exceptions: - Wdeprecated-declarations because this can change often depending on upstream and using deprecated functionality is non-criticial - Wunused-lambda-capture because there seems to be a bug in clang producing many false-positives in our code [1] [1] https://github.com/llvm/llvm-project/issues/81243 --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 725e25831..819a09293 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -20,7 +20,7 @@ "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" + "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" } }, { From 2355562c3acebf0953ac174e5c649e48cfb8853d Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 17:43:35 +0100 Subject: [PATCH 19/21] build: add release preset This can be used to simply build the libraries without any tests and warnings. We build in the CI this preset as well and use it for our weekly rebuilds. The preset actually sets the build type to "RelWithDebInfo" to produce better backtraces. --- .github/workflows/change.yml | 7 +++++-- .github/workflows/rebuild.yml | 2 +- CMakePresets.json | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/change.yml b/.github/workflows/change.yml index 1d766113c..d6130afe2 100644 --- a/.github/workflows/change.yml +++ b/.github/workflows/change.yml @@ -18,11 +18,14 @@ jobs: artifact-name: clang-build cmake-preset: coverage - gcc-build: + secondary-builds: + strategy: + matrix: + preset: [gcc, release] uses: ./.github/workflows/build.yml with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master - cmake-preset: gcc + cmake-preset: ${{ matrix.preset }} install: uses: ./.github/workflows/install.yml diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 1ae847ff4..9a6e84909 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -9,7 +9,7 @@ jobs: with: image: registry.gitlab.com/kwinft/ci-images/archlinux/kwinft-base-master artifact-name: build - cmake-preset: clang + cmake-preset: release package: uses: ./.github/workflows/package.yml diff --git a/CMakePresets.json b/CMakePresets.json index 819a09293..b61da1339 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -84,6 +84,21 @@ "value": "ON" } } + }, + { + "name": "release", + "displayName": "Release build", + "description": "Build without any checks as release with debug symbols", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "BUILD_TESTING": { + "type": "BOOL", + "value": "OFF" + } + } } ] } From 550c3eb6325c360f261f8f59edd56d2322a1eac6 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 20:29:41 +0100 Subject: [PATCH 20/21] build: compile gcc preset with -Werror For increased robustness ensure that the gcc preset compiles with warnings as errors. We make the following exceptions: - Wcast-align is not warned, because it produces a lot of noise on structs we only want to partly initialize. - Wunknown-pragmas is not warned as error, because it will false-positive on clang pragmas. - Wdeprecated-declarations is not warned as error, for same reason as with clang, because it's non-critical and we might want to keep deprecated code for some time. - Wmissing-include-dirs provides false-positives on Qt code generation. --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index b61da1339..254c8b18a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -46,7 +46,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", + "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_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}" } From 58cada567994b6c62b4cde8b6f13e13e982ec135 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 21 Feb 2024 21:00:30 +0100 Subject: [PATCH 21/21] docs: instruct how to compile with presets Add the information on the presets. At the same time the separate chapter about development is not necessary in the README.md. It should be clear that this part is described in the CONTRIBUTING.md document. --- README.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1bc61a541..06e18e283 100644 --- a/README.md +++ b/README.md @@ -108,11 +108,19 @@ Well defined and transparent decision processes enable expert knowledge to proli and new contributors to easily find help on their first steps. # Installation -The Compositor Modules can be compiled from source. -If you do that manually you have to check for your specific distribution -how to best get the required dependencies. - -You can also make use of the FDBuild tool to automate that process as described +The Compositor Modules can be compiled from source easily through CMake presets. +To use the preset for a release configuration building into a subdirectory `build`, +issue from the source directory: + +``` +cmake --preset release -B build +cmake --build build +``` + +Since The Compositor Module's master branch regularly only builds +against the development versions of KDE Plasma libraries, +you might want to build these dependencies from source too. +You can make use of the FDBuild tool to automate this process as described [here](CONTRIBUTING.md#compiling). # Usage @@ -122,13 +130,6 @@ and then create their central platform types from your main function to launch t [Minico](tests/minico) as a minimal example and the [Plasma test binaries](tests/plasma) as a more complex one demonstrate this in a straightforward way. -# Development -The [CONTRIBUTING.md](CONTRIBUTING.md) document contains all information -on how to get started with: -* providing useful debug information, -* building The Compositor Modules -* and doing your first code submission to the project. - # 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).