Bug 445457

Summary: Showing a window before disabling resizing (GTK4 dialogs) results in incorrect title bar buttons
Product: [Plasma] kwin Reporter: nyanpasu64 <nyanpasu64>
Component: decorationsAssignee: KWin default assignee <kwin-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: kdedev, nate
Priority: NOR Keywords: X11-only
Version First Reported In: 5.23.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: The bug in gtk4-demo
The bug in a Qt Widgets app

Description nyanpasu64 2021-11-14 03:33:25 UTC
Created attachment 143527 [details]
The bug in gtk4-demo

SUMMARY
In X11 apps which first map a window, *then* call XSetWMNormalHints or send WM_NORMAL_HINTS to disable resizing (which hides kwin_x11's Maximize button), KWin fails to recompute the title bar layout and right-align the buttons.

STEPS TO REPRODUCE
1. Run gtk4-demo.
2. Scroll down to Dialogs and click Run.

OBSERVED RESULT
The title bar contains a minimize button, close button, and a blank space to the right (where the close button would be, if a maximize button was present).

EXPECTED RESULT
The title bar is properly right-aligned.

I don't know if GTK4 is wrong for mapping a window before disabling resize, or if KWin is wrong for rendering the title bar incorrectly when resizability is toggled after a window is mapped, or both.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.3
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.14.16-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 15.5 GiB of RAM
Graphics Processor: NVIDIA GeForce GT 730/PCIe/SSE2

ADDITIONAL INFORMATION
First reported in https://bugs.kde.org/show_bug.cgi?id=439137#c1. I investigated the root cause at https://gitlab.gnome.org/GNOME/gtk/-/issues/4090#note_1309466. I decided to split it out since it's a different issue.

This happens by default in GTK4 dialogs, but I was also able to reproduce this effect in a Qt app by calling `dialog->layout()->setSizeConstraint(QLayout::SetFixedSize)` (which disables resizing) after the dialog is shown.
Comment 1 nyanpasu64 2021-11-14 03:33:50 UTC
Created attachment 143528 [details]
The bug in a Qt Widgets app