fix: Refactor X11 screenshot handling for Qt6 compatibility#778
Merged
deepin-bot[bot] merged 1 commit intoDec 11, 2025
Conversation
- Introduced a new function to initialize Qt6 XCB environment checks, enhancing the detection of X11 environments. - Updated the ScreenGrabber class to utilize the new environment check for enabling XGetImage workaround. - Removed deprecated preprocessor directives and streamlined high DPI scaling logic based on the environment. - Improved logging for clarity during screenshot operations in X11 environments. This update ensures better compatibility and reliability for screenshot functionality in Qt6 on X11.
deepin pr auto review我来对这段代码进行审查:
具体改进建议:
static bool initQt6XcbEnv()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool result = false;
if (QGuiApplication::instance()) {
const QString platformName = QGuiApplication::platformName();
if (!platformName.isEmpty()) {
result = platformName.toLower() == QLatin1String("xcb");
}
} else {
const QString platformEnv = qEnvironmentVariable("QT_QPA_PLATFORM");
if (!platformEnv.isEmpty()) {
result = platformEnv.toLower().contains(QLatin1String("xcb"));
}
}
return result;
#endif
return false;
}
// Indicates if the application is running in Qt6 with XCB platform
static bool isQt6XcbEnv;
static bool initQt6XcbEnv()
{
static bool cached = false;
static bool result = false;
if (!cached) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// ... detection logic ...
#endif
cached = true;
}
return result;
}这些改动可以进一步提高代码的健壮性和可维护性。总体来说,这是一个很好的重构,使代码更加灵活和可维护。 |
lzwind
approved these changes
Dec 11, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Member
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
80c7d5f
into
linuxdeepin:develop/snipe
7 of 9 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This update ensures better compatibility and reliability for screenshot functionality in Qt6 on X11.