fix(shortcut): support brightness keys on Wayland#104
Conversation
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
0b28a74 to
50651d7
Compare
Use the Treeland output-manager protocol to read and adjust output brightness when Display1 is unavailable on Wayland. Serialize cross-process read-modify-write operations with a runtime lock so repeated shortcut processes do not lose updates, wait for compositor commit results before showing the OSD, and keep ambient auto-brightness enabled when an adjustment fails. Preserve the existing Display1 path on X11. 在 Wayland 下 Display1 不可用时,通过 Treeland output-manager 协议读取并调整输出亮度。使用运行时进程锁串行化跨进程的读取、修改和写入操作,避免快捷键重复触发时丢失亮度更新;等待合成器提交结果后再显示 OSD,并在调节失败时保持环境光自动亮度设置不变。X11 下继续使用原有 Display1 路径。 Log: support brightness keys on Wayland Change-Id: Ib70f62de7fbcb7f93f23bf3c550fbacf7eb2e4ea
50651d7 to
edd656f
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // displaycontroller.cpp
bool DisplayController::changeBrightness(bool raised)
{
if (!m_isWayland && (!m_displayInterface || !m_displayInterface->isValid())) {
qWarning() << "Display interface not available";
return false;
}
auto *powerConfig = DConfig::create("org.deepin.dde.daemon", "org.deepin.dde.daemon.power", "", this);
if (!powerConfig->isValid()) {
qWarning() << "daemon power config is not valid";
powerConfig->deleteLater();
return false;
}
const bool autoAdjustEnabled =
powerConfig->value("ambientLightAdjustBrightness").toBool();
// 在调节亮度前禁用环境光自动调节,避免调节被覆盖
if (autoAdjustEnabled) {
powerConfig->setValue("ambientLightAdjustBrightness", false);
qDebug() << "Disabled ambient light auto brightness adjustment";
}
bool success = false;
if (m_isWayland) {
TreelandBrightnessController controller;
success = controller.changeBrightness(raised);
} else {
QDBusReply<void> reply = m_displayInterface->call("ChangeBrightness", raised);
if (!reply.isValid()) {
qWarning() << "Failed to change brightness:" << reply.error().message();
} else {
success = true;
}
}
if (!success) {
// 如果失败,恢复之前的自动调节状态
if (autoAdjustEnabled) {
powerConfig->setValue("ambientLightAdjustBrightness", true);
}
powerConfig->deleteLater();
return false;
}
powerConfig->deleteLater();
qDebug() << "Changed brightness:" << (raised ? "up" : "down");
showOSD(raised ? "BrightnessUp" : "BrightnessDown");
return true;
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Summary
Test plan
dde-shortcut-tool.