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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
24 changes: 21 additions & 3 deletions tests/screenshot_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down