Bug 500976 - Window size not restored correctly after exiting full screen.
Summary: Window size not restored correctly after exiting full screen.
Status: CONFIRMED
Alias: None
Product: Oxygen
Classification: Plasma
Component: win deco (other bugs)
Version First Reported In: 6.3.2
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords: regression
: 501070 501707 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-03-02 23:16 UTC by Darryl
Modified: 2025-07-05 20:48 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Window is larger than the screen (20.94 KB, image/png)
2025-03-02 23:16 UTC, Darryl
Details
kwin debug console affected by this bug (405.50 KB, image/png)
2025-03-05 11:28 UTC, nope1000000
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Darryl 2025-03-02 23:16:03 UTC
Created attachment 179052 [details]
Window is larger than the screen

SUMMARY
When a window is maximised and then selecting full screen, when exiting full screen the previous window size is not restored. 

STEPS TO REPRODUCE
1. Watch video, view images, view webpages in full screen from various applications such as web browsers Chrome-based & Firefox, Gwenview, Qmplay2 
2. Exit fullscreen



OBSERVED RESULT
The window will be too big, see attachments

EXPECTED RESULT
The size should be restored.

SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux 
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.13.5-1-MANJARO (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 9700X 8-Core Processor
Memory: 123.5 GiB of RAM
Graphics Processor 1: NVIDIA GeForce RTX 4070 Ti SUPER


ADDITIONAL INFORMATION
It's possible it's been happening since at least Plasma 6.3.1 but I thought it would have been fixed since it seems so obvious. 

Pretty sure this bug is the same as #493401
Comment 1 nope1000000 2025-03-05 10:34:42 UTC
I'm also experiencing this bug. This is happening since 6.3.0. 

One problem associated to this bug is that it doesn't happen every time a window is restored from fullscreen. So it's a bit difficult to properly reproduce. However it happens from time to time. And I experienced it on every computer (4) I have running KDE Plasma. I think however this is not the same as #493401.
Comment 2 nope1000000 2025-03-05 11:26:55 UTC
So I did a bit of further investigation.

For reproducing the bug a 100% of times, you need to use the theme Oxygen. This bug seems exclusive of the Oxygen kwin theme. And, you need to maximize the window you want to turn fullscreen before . The bug won't happen on non maximized windows that directly turn fullscreen. So, these are the steps.

1. Use Oxygen kwin theme
2. Maximize the window you want to turn fullscreen
3. Turn that window fullscreen, and then restore.

This affects both X11 and Wayland.

A curious thing is that if you switch the kwin theme to any other thing when a window is affected by this bug, it will recover it's normal appeareance. However, if you turn it back to oxygen, it will appear again as seen in the attachment. It may be the effect of an underlying kwin issue?

Also, the kwin debug console appears always affected with this bug, with the buttons almost out of margin. Another effect of this bug is that the buttons in this state are almost unusable.
Comment 3 nope1000000 2025-03-05 11:28:21 UTC
Created attachment 179137 [details]
kwin debug console affected by this bug
Comment 4 nope1000000 2025-03-05 11:43:02 UTC
It seems the bug https://bugs.kde.org/show_bug.cgi?id=499222 it's pretty related to this one, and the commit applied to oxygen for solving it https://invent.kde.org/plasma/oxygen/-/merge_requests/66 is what it's causing this bug.
Comment 5 Potomac 2025-03-05 19:42:36 UTC
I confirm the bug, it happens always with oxygen theme and Plasma 6.3.2.
Comment 6 John Kizer 2025-05-22 00:02:30 UTC
*** Bug 501707 has been marked as a duplicate of this bug. ***
Comment 7 John Kizer 2025-05-22 00:03:10 UTC
*** Bug 501070 has been marked as a duplicate of this bug. ***
Comment 8 Lukáš Turek 2025-05-27 06:57:38 UTC
(In reply to nope1000000 from comment #4)
> It seems the bug https://bugs.kde.org/show_bug.cgi?id=499222 it's pretty
> related to this one, and the commit applied to oxygen for solving it
> https://invent.kde.org/plasma/oxygen/-/merge_requests/66 is what it's
> causing this bug.

I tried reverting this commit and it didn't fix the bug. In my case the simplest way to reproduce the bug is to switch window decoration to Breeze and back to Oxygen. Every window that was opened before the switch will then be affected.
Comment 9 Lukáš Turek 2025-05-27 19:37:34 UTC
Actually, the window size is correct, only the placement of buttons is wrong (window title is positioned correctly). So the problem is somewhere in Decoration::updateButtonsGeometry(). It seems that captionHeight() sometimes returns a wrong value. This patch is a quick workaround, but the real cause is likely somewhere outside Oxygen decoration. Breeze is not affected, because it doesn't use captionHeight() to calculate the position of buttons.

--- a/kdecoration/oxygendecoration.cpp
+++ b/kdecoration/oxygendecoration.cpp
@@ -350,9 +350,9 @@ void Decoration::updateButtonsGeometry()
     auto s = settings();

     // adjust button position
-    const int bHeight = captionHeight() + (isMaximized() ? s->smallSpacing() * Metrics::TitleBar_TopMargin : 0);
+    const int bHeight = buttonHeight() + (isMaximized() ? s->smallSpacing() * Metrics::TitleBar_TopMargin : 0);
     const int bWidth = buttonHeight();
-    const int verticalOffset = (isMaximized() ? s->smallSpacing() * Metrics::TitleBar_TopMargin : 0) + (captionHeight() - buttonHeight()) / 2;
+    const int verticalOffset = (isMaximized() ? s->smallSpacing() * Metrics::TitleBar_TopMargin : 0);

     const QVector<KDecoration3::DecorationButton *> leftButtons = m_leftButtons->buttons();
     const QVector<KDecoration3::DecorationButton *> rightButtons = m_rightButtons->buttons();
Comment 10 kolAflash 2025-05-31 03:43:03 UTC
(In reply to Lukáš Turek from comment #9)
> Actually, the window size is correct, only the placement of buttons is wrong
> (window title is positioned correctly). So the problem is somewhere in
> Decoration::updateButtonsGeometry(). It seems that captionHeight() sometimes
> returns a wrong value. This patch is a quick workaround, but the real cause
> is likely somewhere outside Oxygen decoration. [...]

Thanks for the workaround! Successfully workarounds the issue on Debian-13 (KDE-Plasma-6.3.4).

For finding the real cause:
Kubuntu-24.10 with KDE-Plasma-6.1.5 seems good (working fine).
https://cdimage.ubuntu.com/kubuntu/releases/24.10/release/kubuntu-24.10-desktop-amd64.iso
Kubuntu-25.10 with KDE-Plasma-6.3.4 is broken.
https://cdimage.ubuntu.com/kubuntu/releases/25.04/release/kubuntu-25.04-desktop-amd64.iso
Comment 11 Paul McAuley 2025-07-05 20:48:09 UTC
It's a change introduced with Plasma 6.3. I fixed it in Klassy ( https://github.com/paulmcauley/klassy/commit/8cd4a519a9639bcfd8eba590af2a8aab8e58ebe7 ) by using borderTop when directly painting the value, and nextState->borders().top() at all other times before calling update() or setTitleBar(). Likewise, for borderLeft() and borderRight(). 

CaptionHeight() indirectly uses borderTop(). From updateButtonsGeometry() it needs to use nextState->borders().top()