https://bugs.kde.org/show_bug.cgi?id=485069

--- Comment #14 from Daniel <[email protected]> ---
 I reproduced stale window dimensions when hiding Yakuake on one output and
reopening it on another with different dimensions. Waiting for Plasma's
availableScreenRect before showing the window, as proposed in MR !166, was
 insufficient on this system. An additional one-shot geometry reapplication
when the QWindow first becomes exposed fixes repeated switching in both
directions in my manual test.

 This is a proposed follow-up for review, not a claim of a fully
regression-tested or upstream-approved fix.

 ENVIRONMENT

 CachyOS Linux, Wayland session.
 Installed Yakuake: 26.08.2.
 Plasma and KWin: 6.8.0.
 Qt: 6.12.0.

 Test builds: upstream master at 0e5cad14994ef315b0c030fb88fc64583ae13074, plus
MR !166, then the additional Expose change described below.

 Laptop output eDP-1: geometry (0,0,1920,1200), scale 1; available area
1920x1200.
 External output HDMI-A-1: geometry (1920,0,2560,1080), scale 1; available area
2560x1032 due to the panel.

 Window width: 100%; automatic output selection. No KWin rule forces the size.

 REPRODUCTION

 1. Open Yakuake with F12 on the external output.
 2. Hide it with F12.
 3. Move to the laptop output and open it with F12.
 4. Repeat in the opposite direction.

 Actual: the window moves to the correct output but retains the previous
output's dimensions. Adjusting its height using Alt+Shift+Up/Down immediately
corrects its dimensions.

 Expected: dimensions should be recalculated and retained for the destination
output without manual resizing.

 MEASUREMENTS

 With height 57%, opening on the laptop after the external display produced:

 QWidget.geometry: (0,0,2560,588).
 QWidget.childrenRect: (0,0,2560,684).
 Expected: (0,0,1920,684).

 The height was subsequently changed to 77% using the resize shortcuts. With MR
!166 applied, the bug still occurred:

 QWidget.geometry: (0,0,2560,794).
 QWidget.childrenRect: (0,0,2560,924).
 Expected: (0,0,1920,924).

 794 is the truncated result of 1032 * 77 / 100: the previous output's
available height.

 EVENT SEQUENCE WITH MR !166

 Temporary logging captured the following sequence when opening on the laptop:

 availableScreenRect reply: eDP-1 -> QRect(0,0 1920x1200)
 setGeometry requested and applied: QRect(0,0 1920x924)
 Resize, spontaneous=false: QRect(0,0 1920x924)
 Show: QRect(0,0 1920x924)
 Resize, spontaneous=true: QRect(0,0 2560x794)

 Thus the correct geometry is applied before Show, but a later spontaneous
resize restores the previous dimensions. This is consistent with the initial
Wayland configure overriding a size requested while hidden. The trace alone
 does not establish whether Qt or KWin is ultimately responsible for retaining
that size.

 PROPOSED ADDITIONAL CHANGE

 On top of MR !166:

 1. Before showing on Wayland, install an event filter on the QWindow and arm a
per-opening flag.
 2. On the first QEvent::Expose for which the window is exposed and visible,
clear the flag and call applyWindowGeometry().
 3. Clear the flag before hiding, so a cancelled opening cannot cause a later
unintended resize.

 Clearing the flag before reapplying avoids repeated application. The filter
does not intentionally override later manual resizes. No fixed-delay timer,
periodic polling, global KWin rule or synchronous D-Bus call is
 introduced. X11 does not arm this path.

 The additional code belongs in MainWindow::eventFilter(),
sharedPreOpenWindow(), sharedPreHideWindow(), and two declarations in
mainwindow.h.

 RESULTS

 The instrumented follow-up build successfully adapted in both directions:

 eDP-1: window and content geometry both 1920x924.
 HDMI-A-1: geometry 2560x794.

 I confirmed the visible result. Logs show the stale spontaneous resize
followed by the first Expose and successful reapplication of the correct
geometry.

 The cleaned build, with diagnostic logging removed and the same fix retained,
also compiles successfully; it has been installed locally for subsequent use,
but that cleaned executable has not yet been runtime-tested.

 Pending regression checks include fullscreen, manual resizing, rapid F12
toggling, fixed-output selection, output hotplug, unavailable Plasma D-Bus
service, and X11. Long-term compatibility across Qt/Plasma updates has not
 been established.

 PATCHES AND ATTRIBUTION

 expose-followup.patch: only the additional change, to apply after MR !166.

 wayland-geometry-combined.patch: MR !166 plus the additional change, against
the master commit above.

 upstream-mr166.diff: the original downloaded MR diff, retained locally for
reproducibility.

 The asynchronous geometry request, pending-toggle cancellation and
stale-response handling come from MR !166 by Florian Savouré (posix), not from
this follow-up. The additional Expose handling was developed with AI coding
 assistance and validated through local manual testing. Please preserve the
original MR author's attribution if integrating the combined patch.

 The patches contain no diagnostic logging. They are provided for review and
can be improved or replaced by a more appropriate Qt/KWin-level fix if
maintainers identify the underlying cause.

 APPLYING AND BUILDING

 For the combined patch:

 git clone https://invent.kde.org/utilities/yakuake.git
 cd yakuake
 git checkout 0e5cad14994ef315b0c030fb88fc64583ae13074
 git apply /path/to/wayland-geometry-combined.patch
 cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
 cmake --build build --parallel 4

 Alternatively apply upstream-mr166.diff and then expose-followup.patch to that
base. Required build dependencies must be installed first.

 Run build/bin/yakuake only after saving terminal work and exiting the existing
instance, since Yakuake is a single-instance application. Installing over the
distribution package is not necessary for testing.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to