From 3fd32aaf1c1254ea39486f283650cd3040e06e0d Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 6 Sep 2026 09:24:05 -0400 Subject: [PATCH] ci(Linux): switch desktop to plasma --- .github/workflows/ci.yml | 2 -- tests/screenshot_utils.cpp | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1638d6d9..556dd58a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,8 +105,6 @@ jobs: - name: Setup virtual desktop if: runner.os == 'Linux' uses: LizardByte/actions/actions/virtual_desktop@188c8ccad593e0f68bcf6aacb6bf84f10359d26f # v2026.905.43751 - with: - environment: mate - name: Setup Dependencies macOS if: runner.os == 'macOS' diff --git a/tests/screenshot_utils.cpp b/tests/screenshot_utils.cpp index 6c1e3c09..56b180e0 100644 --- a/tests/screenshot_utils.cpp +++ b/tests/screenshot_utils.cpp @@ -68,6 +68,24 @@ namespace { } return true; } + + bool crop_to_bottom_right_quadrant(const std::filesystem::path &file) { + const QString imagePath = QString::fromUtf8(file.u8string().c_str()); + const QImage image(imagePath); + if (image.isNull() || image.width() < 2 || image.height() < 2) { + std::cerr << "Screenshot dimensions invalid" << std::endl; + return false; + } + + const int width = image.width() / 2; + const int height = image.height() / 2; + const QImage quadrant = image.copy(image.width() - width, image.height() - height, width, height); + if (!quadrant.save(imagePath, "PNG")) { + std::cerr << "Failed to crop " << file << std::endl; + return false; + } + return true; + } #endif #ifdef _WIN32 @@ -151,20 +169,20 @@ namespace screenshot { if (std::system("which import > /dev/null 2>&1") == 0) { std::string cmd = "import -window root " + target; if (std::system(cmd.c_str()) == 0) { - return capture_full_screen() || crop_to_top_right_quadrant(file); + return capture_full_screen() || crop_to_bottom_right_quadrant(file); } } if (std::system("which spectacle > /dev/null 2>&1") == 0) { std::string cmd = "spectacle -f -b -n -o " + target; if (std::system(cmd.c_str()) == 0) { - return capture_full_screen() || crop_to_top_right_quadrant(file); + return capture_full_screen() || crop_to_bottom_right_quadrant(file); } } std::string cmd = "gnome-screenshot -f " + target; if (std::system(cmd.c_str()) != 0) { return false; } - return capture_full_screen() || crop_to_top_right_quadrant(file); + return capture_full_screen() || crop_to_bottom_right_quadrant(file); } #endif