Skip to content

fix: Add BypassWindowManagerHint to toolbar window flags#753

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
add-uos:develop/snipe
Nov 11, 2025
Merged

fix: Add BypassWindowManagerHint to toolbar window flags#753
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
add-uos:develop/snipe

Conversation

@add-uos

@add-uos add-uos commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

Added Qt::BypassWindowManagerHint flag to all window mode configurations (Wayland, V23 system, and default) to ensure proper window management behavior and prevent potential window manager interference with toolbar positioning and display.

Log: Fix toolbar window management issues
Bug: https://pms.uniontech.com/bug-view-338255.html

Added Qt::BypassWindowManagerHint flag to all window mode configurations
(Wayland, V23 system, and default) to ensure proper window management
behavior and prevent potential window manager interference with toolbar
positioning and display.

Log: Fix toolbar window management issues
Bug: https://pms.uniontech.com/bug-view-338255.html
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这段代码的修改进行审查:

  1. 语法逻辑:
    修改部分在语法上是正确的,使用位或运算符(windowFlags | Qt::BypassWindowManagerHint)来添加新的窗口标志是Qt中的标准做法。

  2. 代码质量:

  • 代码缺少注释说明添加 Qt::BypassWindowManagerHint 的原因,这会影响代码的可维护性。
  • 修改位置在构造函数中,但与其他窗口标志的设置分开,建议将所有窗口标志的设置放在一起,便于维护。
  1. 代码性能:
  • 这行代码的性能影响微乎其微,因为它只在构造函数中执行一次。
  1. 代码安全:
  • 使用 Qt::BypassWindowManagerHint 需要特别注意,这个标志会让窗口绕过窗口管理器,可能会导致一些意外行为:
    • 窗口可能无法被正常管理(如最小化、最大化)
    • 可能影响窗口的层级管理
    • 在某些窗口管理器上可能无法正常显示
  • 建议添加条件判断,只在特定情况下才使用这个标志

改进建议:

ToolBarWidget::ToolBarWidget(DWidget *parent): DBlurEffectWidget(parent)
{
    // 统一设置窗口标志
    Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool;
    
    // 只在特定环境下才绕过窗口管理器
    #ifdef NEED_BYPASS_WM
        flags |= Qt::BypassWindowManagerHint;
    #endif
    
    setWindowFlags(flags);
    qCDebug(dsrApp) << "Window flags set for default mode.";

    this->setRadius(30);
    this->setBlurEnabled(true);

这样的改进:

  1. 添加了注释说明
  2. 将所有窗口标志的设置集中在一起
  3. 使用预处理器宏来控制是否使用 BypassWindowManagerHint,增加了灵活性
  4. 保持了代码的可读性和可维护性

建议在实际使用时,仔细评估是否真的需要使用 Qt::BypassWindowManagerHint,因为它可能会带来一些不可预期的行为。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos

add-uos commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot

deepin-bot Bot commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

This pr cannot be merged! (status: unstable)

@add-uos

add-uos commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit e8d678b into linuxdeepin:develop/snipe Nov 11, 2025
8 of 9 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.

3 participants