Skip to content

Commit

Permalink
Merge branch 'quickshell-mirror:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nydragon authored Nov 24, 2024
2 parents d328fc3 + c5319e3 commit c84b7ab
Show file tree
Hide file tree
Showing 121 changed files with 2,729 additions and 1,340 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Checks: >
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-forward-declararion-namespace,
-bugprone-forward-declararion-namespace,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-owning-memory,
Expand Down Expand Up @@ -42,6 +43,7 @@ Checks: >
-readability-else-after-return,
-readability-container-data-pointer,
-readability-implicit-bool-conversion,
-readability-avoid-nested-conditional-operator,
tidyfox-*,
CheckOptions:
performance-for-range-copy.WarnOnAllAutoCopies: true
Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ indent_style = tab
[*.nix]
indent_style = space
indent_size = 2

[*.{yml,yaml}]
indent_style = space
indent_size = 2
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build
on: [push, pull_request]

jobs:
nix:
name: Nix
strategy:
matrix:
qtver: [qt6.8.0, qt6.7.3, qt6.7.2, qt6.7.1, qt6.7.0, qt6.6.3, qt6.6.2, qt6.6.1, qt6.6.0]
compiler: [clang, gcc]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Use cachix action over detsys for testing with act.
# - uses: cachix/install-nix-action@v27
- uses: DeterminateSystems/nix-installer-action@main

- name: Download Dependencies
run: nix-build --no-out-link --expr '((import ./ci/matrix.nix) { qtver = "${{ matrix.qtver }}"; compiler = "${{ matrix.compiler }}"; }).inputDerivation'

- name: Build
run: nix-build --no-out-link --expr '(import ./ci/matrix.nix) { qtver = "${{ matrix.qtver }}"; compiler = "${{ matrix.compiler }}"; }'

archlinux:
name: Archlinux
runs-on: ubuntu-latest
container: archlinux
steps:
- uses: actions/checkout@v4

- name: Download Dependencies
run: |
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy \
base-devel \
cmake \
ninja \
pkgconf \
qt6-base \
qt6-declarative \
qt6-svg \
qt6-wayland \
qt6-shadertools \
wayland-protocols \
wayland \
libxcb \
libpipewire \
cli11 \
jemalloc
- name: Build
# breakpad is annoying to build in ci due to makepkg not running as root
run: |
cmake -GNinja -B build -DCRASH_REPORTER=OFF
cmake --build build
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint
on: [push, pull_request]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Use cachix action over detsys for testing with act.
# - uses: cachix/install-nix-action@v27
- uses: DeterminateSystems/nix-installer-action@main
- uses: nicknovitski/nix-develop@v1

- name: Check formatting
run: clang-format -Werror --dry-run src/**/*.{cpp,hpp}

# required for lint
- name: Build
run: |
just configure debug -DNO_PCH=ON -DBUILD_TESTING=ON
just build
- name: Run lints
run: just lint
10 changes: 9 additions & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@ Quickshell has a set of base dependencies you will always need, names vary by di
- `cmake`
- `qt6base`
- `qt6declarative`
- `pkg-config`
- `qtshadertools` (build-time only)
- `spirv-tools` (build-time only)
- `pkg-config` (build-time only)
- `cli11`

On some distros, private Qt headers are in separate packages which you may have to install.
We currently require private headers for the following libraries:

- `qt6declarative`
- `qt6wayland`

We recommend an implicit dependency on `qt6svg`. If it is not installed, svg images and
svg icons will not work, including system ones.

Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ include(cmake/util.cmake)

add_compile_options(-Wall -Wextra)

# pipewire defines this, breaking PCH
add_compile_definitions(_REENTRANT)

if (FRAME_POINTERS)
add_compile_options(-fno-omit-frame-pointer)
endif()
Expand All @@ -90,7 +93,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()

set(QT_FPDEPS Gui Qml Quick QuickControls2 Widgets)
set(QT_FPDEPS Gui Qml Quick QuickControls2 Widgets ShaderTools)

include(cmake/pch.cmake)

Expand Down
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fmt:
find src -type f \( -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i

lint:
find src -type f -name "*.cpp" -print0 | parallel -q0 --eta clang-tidy --load={{ env_var("TIDYFOX") }}
find src -type f -name "*.cpp" -print0 | parallel -q0 --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}

lint-changed:
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel --eta clang-tidy --load={{ env_var("TIDYFOX") }}
Expand Down
8 changes: 8 additions & 0 deletions ci/matrix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
qtver,
compiler,
}: let
nixpkgs = (import ./nix-checkouts.nix).${builtins.replaceStrings ["."] ["_"] qtver};
compilerOverride = (nixpkgs.callPackage ./variations.nix {}).${compiler};
pkg = (nixpkgs.callPackage ../default.nix {}).override compilerOverride;
in pkg
58 changes: 58 additions & 0 deletions ci/nix-checkouts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
let
byCommit = {
commit,
sha256,
}: import (builtins.fetchTarball {
name = "nixpkgs-${commit}";
url = "https://github.com/nixos/nixpkgs/archive/${commit}.tar.gz";
inherit sha256;
}) {};
in {
# For old qt versions, grab the commit before the version bump that has all the patches
# instead of the bumped version.

qt6_8_0 = byCommit {
commit = "23e89b7da85c3640bbc2173fe04f4bd114342367";
sha256 = "1b2v6y3bja4br5ribh9lj6xzz2k81dggz708b2mib83rwb509wyb";
};

qt6_7_3 = byCommit {
commit = "273673e839189c26130d48993d849a84199523e6";
sha256 = "0aca369hdxb8j0vx9791anyzy4m65zckx0lriicqhp95kv9q6m7z";
};

qt6_7_2 = byCommit {
commit = "841f166ff96fc2f3ecd1c0cc08072633033d41bf";
sha256 = "0d7p0cp7zjiadhpa6sdafxvrpw4lnmb1h673w17q615vm1yaasvy";
};

qt6_7_1 = byCommit {
commit = "69bee9866a4e2708b3153fdb61c1425e7857d6b8";
sha256 = "1an4sha4jsa29dvc4n9mqxbq8jjwg7frl0rhy085g73m7l1yx0lj";
};

qt6_7_0 = byCommit {
commit = "4fbbc17ccf11bc80002b19b31387c9c80276f076";
sha256 = "09lhgdqlx8j9a7vpdcf8sddlhbzjq0s208spfmxfjdn14fvx8k0j";
};

qt6_6_3 = byCommit {
commit = "8f1a3fbaa92f1d59b09f2d24af6a607b5a280071";
sha256 = "0322zwxvmg8v2wkm03xpk6mqmmbfjgrhc9prcx0zd36vjl6jmi18";
};

qt6_6_2 = byCommit {
commit = "0bb9cfbd69459488576a0ef3c0e0477bedc3a29e";
sha256 = "172ww486jm1mczk9id78s32p7ps9m9qgisml286flc8jffb6yad8";
};

qt6_6_1 = byCommit {
commit = "8eecc3342103c38eea666309a7c0d90d403a039a";
sha256 = "1lakc0immsgrpz3basaysdvd0sx01r0mcbyymx6id12fk0404z5r";
};

qt6_6_0 = byCommit {
commit = "1ded005f95a43953112ffc54b39593ea2f16409f";
sha256 = "1xvyd3lj81hak9j53mrhdsqx78x5v2ppv8m2s54qa2099anqgm0f";
};
}
7 changes: 7 additions & 0 deletions ci/variations.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
clangStdenv,
gccStdenv,
}: {
clang = { buildStdenv = clangStdenv; };
gcc = { buildStdenv = gccStdenv; };
}
9 changes: 9 additions & 0 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Adds a dependency hint to the link order, but does not block build on the dependency.
function (qs_add_link_dependencies target)
set_property(
TARGET ${target}
APPEND PROPERTY INTERFACE_LINK_LIBRARIES
${ARGN}
)
endfunction()

function (qs_append_qmldir target text)
get_property(qmldir_content TARGET ${target} PROPERTY _qt_internal_qmldir_content)

Expand Down
5 changes: 4 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
nix-gitignore,
pkgs,
keepDebugInfo,
buildStdenv ? pkgs.clang17Stdenv,
buildStdenv ? pkgs.clangStdenv,

cmake,
ninja,
qt6,
spirv-tools,
cli11,
breakpad,
jemalloc,
Expand Down Expand Up @@ -46,6 +47,8 @@
nativeBuildInputs = with pkgs; [
cmake
ninja
qt6.qtshadertools
spirv-tools
qt6.wrapQtAppsHook
pkg-config
] ++ (lib.optionals withWayland [
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ in pkgs.mkShell.override { stdenv = quickshell.stdenv; } {

nativeBuildInputs = with pkgs; [
just
clang-tools_17
clang-tools
parallel
makeWrapper
];
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ qt_add_executable(quickshell main.cpp)

install(TARGETS quickshell RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

add_subdirectory(launch)
add_subdirectory(build)
add_subdirectory(launch)
add_subdirectory(core)
add_subdirectory(debug)
add_subdirectory(ipc)
add_subdirectory(window)
add_subdirectory(io)
Expand Down
3 changes: 2 additions & 1 deletion src/core/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <qqmlintegration.h>
#include <qtimer.h>
#include <qtmetamacros.h>
#include <qtypes.h>

#include "util.hpp"

Expand All @@ -27,7 +28,7 @@ class SystemClock: public QObject {

public:
// must be named enum until docgen is ready to handle member enums better
enum Enum {
enum Enum : quint8 {
Hours = 1,
Minutes = 2,
Seconds = 3,
Expand Down
17 changes: 11 additions & 6 deletions src/core/generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "reload.hpp"
#include "scan.hpp"

static QHash<QQmlEngine*, EngineGeneration*> g_generations; // NOLINT
static QHash<const QQmlEngine*, EngineGeneration*> g_generations; // NOLINT

EngineGeneration::EngineGeneration(const QDir& rootPath, QmlScanner scanner)
: rootPath(rootPath)
Expand All @@ -42,7 +42,7 @@ EngineGeneration::EngineGeneration(const QDir& rootPath, QmlScanner scanner)
this->engine->addImageProvider("qsimage", new QsImageProvider());
this->engine->addImageProvider("qspixmap", new QsPixmapProvider());

QuickshellPlugin::runConstructGeneration(*this);
QsEnginePlugin::runConstructGeneration(*this);
}

EngineGeneration::~EngineGeneration() {
Expand Down Expand Up @@ -124,7 +124,10 @@ void EngineGeneration::onReload(EngineGeneration* old) {
QObject::connect(this->engine, &QQmlEngine::quit, this, &EngineGeneration::quit);
QObject::connect(this->engine, &QQmlEngine::exit, this, &EngineGeneration::exit);

this->root->reload(old == nullptr ? nullptr : old->root);
if (auto* reloadable = qobject_cast<Reloadable*>(this->root)) {
reloadable->reload(old ? old->root : nullptr);
}

this->singletonRegistry.onReload(old == nullptr ? nullptr : &old->singletonRegistry);
this->reloadComplete = true;
emit this->reloadFinished();
Expand All @@ -141,7 +144,7 @@ void EngineGeneration::postReload() {
// This can be called on a generation during its destruction.
if (this->engine == nullptr || this->root == nullptr) return;

QuickshellPlugin::runOnReload();
QsEnginePlugin::runOnReload();
PostReloadHook::postReloadTree(this->root);
this->singletonRegistry.onPostReload();
}
Expand Down Expand Up @@ -326,11 +329,13 @@ EngineGeneration* EngineGeneration::currentGeneration() {
} else return nullptr;
}

EngineGeneration* EngineGeneration::findEngineGeneration(QQmlEngine* engine) {
EngineGeneration* EngineGeneration::findEngineGeneration(const QQmlEngine* engine) {
return g_generations.value(engine);
}

EngineGeneration* EngineGeneration::findObjectGeneration(QObject* object) {
EngineGeneration* EngineGeneration::findObjectGeneration(const QObject* object) {
if (g_generations.size() == 1) return EngineGeneration::currentGeneration();

while (object != nullptr) {
auto* context = QQmlEngine::contextForObject(object);

Expand Down
Loading

0 comments on commit c84b7ab

Please sign in to comment.