Skip to content

Fix DTK titlebar minimize/close buttons disabled on Wayland (winId truncation)#647

Open
svan71 wants to merge 1 commit into
linuxdeepin:masterfrom
svan71:fix-motif-winid-wayland
Open

Fix DTK titlebar minimize/close buttons disabled on Wayland (winId truncation)#647
svan71 wants to merge 1 commit into
linuxdeepin:masterfrom
svan71:fix-motif-winid-wayland

Conversation

@svan71

@svan71 svan71 commented Jul 11, 2026

Copy link
Copy Markdown

Problem

On Wayland, DTK client-side titlebars (e.g. dde-control-center) render their minimize and close buttons permanently disabled — grayed out, no hover, no action. Only the menu/hamburger button works. The same binaries work correctly on X11 and worked on older Qt.

WindowButtonGroup.qml enables minimize/maximize/close only when D.DWindow.motifFunctions includes the corresponding FUNC_* bit. A runtime probe (a minimal DTK ApplicationWindow) shows motifFunctions stuck at 0x0 for the window's entire lifetime under a Wayland session.

Root cause

DQuickWindowAttachedPrivate::_q_onWindowMotifHintsChanged(quint32 winId) guards on window identity:

if (q->window()->winId() != winId)
    return;

The winId argument is a quint32 — both callers deliver it truncated to 32 bits: the SurfaceCreated path in eventFilter casts static_cast<quint32>(window->winId()), and the DWindowManagerHelper::windowMotifWMHintsChanged(quint32) signal is 32-bit by definition. But the guard compares it against QWindow::winId(), which returns the full-width WId (quintptr).

  • On X11, WId is a 32-bit XID, so the comparison holds.
  • On Wayland with Qt 6.11, WId is a pointer-derived value greater than 32 bits, so full64 != truncated32 is always true. The slot returns early, DWindowManagerHelper::getMotifFunctions() is never called, and motifFunctions is never updated from its 0 default — leaving all window buttons disabled.

This is why the regression appears "version-less": the DTK sources are unchanged; it is the Qt QtWayland winId assignment that shifted, exposing the latent width mismatch.

Fix

Compare the low 32 bits on both sides, matching the width the codebase already delivers. No public API/ABI change (windowMotifWMHintsChanged(quint32) is unchanged).

if (static_cast<quint32>(q->window()->winId()) != winId)
    return;

Verification

Minimal reproducer — a DTK ApplicationWindow that logs D.DWindow.motifFunctions on each poll, run inside a Treeland/Wayland session:

  • Before: motifFunctions = 0 (0x0) for the whole run; minimize/close disabled.
  • After: motifFunctions = 62 (0x3e) (FUNC_RESIZE|MOVE|MINIMIZE|MAXIMIZE|CLOSE); minimize/close enabled. dde-control-center titlebar buttons hover and work again.

The slot receives winId as quint32 (eventFilter and the DWindowManagerHelper
windowMotifWMHintsChanged signal both deliver it truncated to 32 bits), but the
identity guard compared it against the full-width WId from QWindow::winId().
On X11 WId is a 32-bit XID so it worked; on Wayland/Qt6.11 WId is a 64-bit
pointer (>4GiB), so the guard is always true and the slot returns before
fetching Motif functions, leaving motifFunctions at 0 and disabling the
minimize/close buttons on DTK client titlebars (e.g. dde-control-center).

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @svan71, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: svan71

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

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Hi @svan71. Thanks for your PR. 😃

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Hi @svan71. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants