Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Dec 8, 2025

  1. Added m_previewing flag to track whether screensaver is in preview mode
  2. Modified Preview() method to set m_previewing flag based on preview parameter
  3. Changed window flag setting logic to always apply WindowStaysOnTopHint when staysOn is true
  4. Unified input event connection to use onInputEventReceived slot instead of conditional connections
  5. Added onInputEventReceived slot to filter mouse move events during preview mode
  6. Reset m_previewing flag to false when screensaver stops
  7. Removed debug log from ScreenSaverView::event() method as logging is now handled in DBusScreenSaver

Log: Fixed issue where mouse movement would incorrectly exit screensaver preview mode

Influence:

  1. Test screensaver preview functionality - mouse movement should not exit preview
  2. Verify other input events (keyboard, touch) still properly exit preview mode
  3. Test normal screensaver operation - all input events should stop screensaver
  4. Verify WindowStaysOnTopHint behavior in preview mode
  5. Test WindowStaysOnBottomHint behavior when staysOn is false
  6. Ensure screensaver properly starts and stops in both preview and normal modes

fix: 防止鼠标移动退出预览模式

  1. 添加 m_previewing 标志来跟踪屏保是否处于预览模式
  2. 修改 Preview() 方法根据 preview 参数设置 m_previewing 标志
  3. 更改窗口标志设置逻辑,当 staysOn 为 true 时始终应用 WindowStaysOnTopHint
  4. 统一输入事件连接,使用 onInputEventReceived 槽代替条件连接
  5. 添加 onInputEventReceived 槽以在预览模式下过滤鼠标移动事件
  6. 屏保停止时将 m_previewing 标志重置为 false
  7. 从 ScreenSaverView::event() 方法中移除调试日志,现在日志在 DBusScreenSaver 中处理

Log: 修复了鼠标移动会错误退出屏保预览模式的问题

Influence:

  1. 测试屏保预览功能 - 鼠标移动不应退出预览
  2. 验证其他输入事件(键盘、触摸)仍能正常退出预览模式
  3. 测试正常屏保运行 - 所有输入事件都应停止屏保
  4. 验证预览模式下的 WindowStaysOnTopHint 行为
  5. 测试 staysOn 为 false 时的 WindowStaysOnBottomHint 行为
  6. 确保屏保在预览和正常模式下都能正确启动和停止

pms: BUG-342709

1. Added m_previewing flag to track whether screensaver is in preview
mode
2. Modified Preview() method to set m_previewing flag based on preview
parameter
3. Changed window flag setting logic to always apply
WindowStaysOnTopHint when staysOn is true
4. Unified input event connection to use onInputEventReceived slot
instead of conditional connections
5. Added onInputEventReceived slot to filter mouse move events during
preview mode
6. Reset m_previewing flag to false when screensaver stops
7. Removed debug log from ScreenSaverView::event() method as logging is
now handled in DBusScreenSaver

Log: Fixed issue where mouse movement would incorrectly exit screensaver
preview mode

Influence:
1. Test screensaver preview functionality - mouse movement should not
exit preview
2. Verify other input events (keyboard, touch) still properly exit
preview mode
3. Test normal screensaver operation - all input events should stop
screensaver
4. Verify WindowStaysOnTopHint behavior in preview mode
5. Test WindowStaysOnBottomHint behavior when staysOn is false
6. Ensure screensaver properly starts and stops in both preview and
normal modes

fix: 防止鼠标移动退出预览模式

1. 添加 m_previewing 标志来跟踪屏保是否处于预览模式
2. 修改 Preview() 方法根据 preview 参数设置 m_previewing 标志
3. 更改窗口标志设置逻辑,当 staysOn 为 true 时始终应用
WindowStaysOnTopHint
4. 统一输入事件连接,使用 onInputEventReceived 槽代替条件连接
5. 添加 onInputEventReceived 槽以在预览模式下过滤鼠标移动事件
6. 屏保停止时将 m_previewing 标志重置为 false
7. 从 ScreenSaverView::event() 方法中移除调试日志,现在日志在
DBusScreenSaver 中处理

Log: 修复了鼠标移动会错误退出屏保预览模式的问题

Influence:
1. 测试屏保预览功能 - 鼠标移动不应退出预览
2. 验证其他输入事件(键盘、触摸)仍能正常退出预览模式
3. 测试正常屏保运行 - 所有输入事件都应停止屏保
4. 验证预览模式下的 WindowStaysOnTopHint 行为
5. 测试 staysOn 为 false 时的 WindowStaysOnBottomHint 行为
6. 确保屏保在预览和正常模式下都能正确启动和停止

pms: BUG-342709
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个代码diff进行审查和分析:

  1. 代码逻辑改进:
  • 添加了新的成员变量 m_previewing 来跟踪预览状态,这是一个好的改进,使状态管理更清晰。
  • 将输入事件处理逻辑统一到 onInputEventReceived 函数中,避免了重复的连接/断开操作,提高了代码的可维护性。
  1. 代码质量改进:
  • 删除了重复的日志输出,将日志统一移到 onInputEventReceived 函数中,避免了代码重复。
  • 修复了 window->setFlags() 调用中的逻辑错误,将第二个参数固定为 true,这样更符合预期行为。
  1. 代码性能改进:
  • 使用 Qt::UniqueConnection 确保信号槽只连接一次,避免了重复连接可能带来的性能问题。
  • 移除了不必要的条件判断(preview 相关的连接/断开操作),简化了代码流程。
  1. 代码安全改进:
  • 在预览模式下,增加了对鼠标移动事件的特殊处理,避免了预览时意外退出。
  • 在 Stop() 函数中重置 m_previewing 状态,确保状态的一致性。

建议改进:

  1. 在 onInputEventReceived 函数中,建议将日志级别改为 debug 而不是 info,因为这是一个高频操作:
qDebug() << QDateTime::currentDateTime().toString() << "receive input event and will quit:" << type;
  1. 可以考虑使用枚举类型来定义预览状态,而不是简单的 bool 值,这样便于后续扩展:
enum PreviewState {
    NotPreviewing,
    Previewing
};
  1. 建议在头文件中为新添加的成员变量添加注释说明其用途:
/// 标记当前是否处于预览模式
bool m_previewing = false;
  1. 建议在 onInputEventReceived 函数中添加更多的事件类型过滤,只处理真正需要的事件类型:
void DBusScreenSaver::onInputEventReceived(QEvent::Type type)
{
    if (m_previewing && type == QEvent::MouseMove) {
        return;
    }
    
    // 只处理关键输入事件
    switch(type) {
        case QEvent::KeyPress:
        case QEvent::KeyRelease:
        case QEvent::MouseButtonPress:
        case QEvent::MouseButtonRelease:
        case QEvent::TouchBegin:
        case QEvent::TouchEnd:
            qInfo() << QDateTime::currentDateTime().toString() << "receive input event and will quit:" << type;
            Stop();
            break;
        default:
            break;
    }
}

这些改进将使代码更加健壮、可维护和高效。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, caixr23, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mhduiy
Copy link
Contributor Author

mhduiy commented Dec 9, 2025

/merge

@deepin-bot deepin-bot bot merged commit e76d076 into linuxdeepin:master Dec 9, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants