Bug 489463 - Scripting: Undocumented breaking change in Maximized windows behaviour
Summary: Scripting: Undocumented breaking change in Maximized windows behaviour
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: Quick Tiling (show other bugs)
Version: 6.1.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Alik Aslanyan
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2024-06-29 23:13 UTC by Alik Aslanyan
Modified: 2024-07-15 08:08 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alik Aslanyan 2024-06-29 23:13:48 UTC
SUMMARY


STEPS TO REPRODUCE
1. Install KWin 6.1.1 and Polonium 6 (515f6990c848d935c56de5e12cec74ca4aab1baf)
2. Open Plasma (Wayland) session
3. Open two windows, so they are tiling on the same monitor
4. Try to maximize the Window

OBSERVED RESULT

Window is maximized for one frame, than teleported back to the tile.

EXPECTED RESULT

Window is behaving as on KWin 6.05 (maximizes).

SOFTWARE/OS VERSIONS


Linux/KDE Plasma: Arch Linux KDE Plasma 6.1
(available in About System)
KDE Plasma Version: 6.10
KDE Frameworks Version: 6.30 
Qt Version: 6.7.1

ADDITIONAL INFORMATION

Manually bisecting this issue points to commit

commit 52b92904dead8dedd8134d532f507e6f5bc78958 (HEAD -> bad-commit)
Author: Marco Martin <notmart@gmail.com>
Date:   Mon Apr 15 12:18:09 2024 +0000

    Quick tiling double buffereing
    
    The quicktileMode member now is just for the requested tile mode, base the "real" mode only on m_tile.
    
    The requested tile mode is used for double buffering, to look and behave just like requestedMAximizeMode() which is updated immediately, but needs to acknowledge the configure request and render for quickTileMode() (and the right tile() instanced to be associated) to be updated accordingly

 autotests/integration/move_resize_window_test.cpp |  27 ++++++++++---
 autotests/integration/quick_tiling_test.cpp       | 125 +++++++++++++++++++++++++++++++++++++++--------------------
 src/placementtracker.cpp                          |   4 +-
 src/tiles/quicktile.cpp                           |   4 ++
 src/tiles/tile.cpp                                |   6 ++-
 src/tiles/tilemanager.cpp                         |   6 +++
 src/tiles/tilemanager.h                           |   3 ++
 src/window.cpp                                    |  91 ++++++++++++++++++++++++++++++-------------
 src/window.h                                      |  15 +++----
 src/x11window.cpp                                 |  10 ++++-
 src/x11window.h                                   |   1 +
 src/xdgshellwindow.cpp                            |  35 ++++++++++++-----
 12 files changed, 228 insertions(+), 99 deletions(-)


It seems that test that prevents this issue was removed here https://invent.kde.org/plasma/kwin/-/merge_requests/5532/diffs#b511e90f6b6d5af94f4af5fcac5d7e2497a3c15a_203_211

What happens in Polonium as is follows.

1) User maximizes the Window
2) Polonium receives TileChanged Signal non null tile and decides to rebuild it's layout

Previously it was as this
1) User maximizes the Window
2) Polonium receives TileChanged with NULL
Comment 1 Alik Aslanyan 2024-06-29 23:28:52 UTC
Correction, last comment about Polonium internals seems to be incorrect
Comment 2 Alik Aslanyan 2024-06-29 23:37:34 UTC
For some reason link from invent.kde.org isn't working. I meant this change in unit testing.

    // window is now set to maximised
    QCOMPARE(maximizeChangedSpy.count(), 1);
    QCOMPARE(window->maximizeMode(), MaximizeFull);
-    QCOMPARE(window->tile(), nullptr);
Comment 3 Alik Aslanyan 2024-06-30 00:01:07 UTC
Result of original PR bisection

af7f52e38bb09adab9c0bf572c996a11589a6a25 is the first bad commit
commit af7f52e38bb09adab9c0bf572c996a11589a6a25
Author: Marco Martin <notmart@gmail.com>
Date:   Tue Mar 26 17:02:41 2024 +0100

    prototype of double buffered quick tile mode

 autotests/integration/kwin_wayland_test.h   | 15 ++++++++++++++-
 autotests/integration/quick_tiling_test.cpp | 52 ++++++++++++++++++++++++++++++++++++++++------------
 autotests/integration/test_helpers.cpp      | 12 ++++++++++++
 src/tiles/quicktile.cpp                     |  4 ++++
 src/window.cpp                              | 39 +++++++++++++++++++++++++++------------
 src/window.h                                |  2 ++
 src/xdgshellwindow.cpp                      | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 7 files changed, 149 insertions(+), 34 deletions(-)
Comment 4 Alik Aslanyan 2024-06-30 00:20:15 UTC
What happens in Polonium as is follows.

1) User maximizes the Window
2) Polonium while receiving maximizedChanged untilies the window, by removing it from the tile
3) KWin ignores removed tile and reinserts it somewhere in the code.
4) Polonium receives TileChanged with non-NULL and freaks out

Previously it was as this
1) User maximizes the Window
2) Polonium while receiving maximizedChanged untilies the window, by removing it from the tile
3) Polonium receives TileChanged with NULL

This is more correct description of the logic issue here. When script decides to remove window from tile, script shouldn't put it again
Comment 5 Nate Graham 2024-07-02 19:52:47 UTC
Will be fixed by https://invent.kde.org/plasma/kwin/-/merge_requests/6023, if that's merged.
Comment 6 Vlad Zahorodnii 2024-07-09 17:32:36 UTC
Git commit 3b34e9309b166072f73898017b88208a2f04b947 by Vlad Zahorodnii, on behalf of Alik Aslanyan.
Committed on 09/07/2024 at 17:24.
Pushed by vladz into branch 'master'.

tiling: Don't put maximized windows in tile

After !5532 existing behavior in public scripting API was changed for maximized Windows.
Maximized Windows didn't have a tile on purpose.
This behaviour was changed, as after refactoring separate members for storing QuickTileMode in Window and tile itself were unified
Previously QuickTileMode::Maximize was only set in the Window itself in m_quickTileMode, while tile itself was removed (by setTile(nullptr)).

Current QuickTileMod for current Window isn't part of public scripting API, so it's okay to break it.

This restores compatability with scripts created for KWin 6.0.5 and earlier

Signed-off-by: Alik Aslanyan <inline0@pm.me>

M  +15   -3    autotests/integration/move_resize_window_test.cpp
M  +47   -19   autotests/integration/quick_tiling_test.cpp
M  +1    -5    src/x11window.cpp
M  +1    -9    src/xdgshellwindow.cpp

https://invent.kde.org/plasma/kwin/-/commit/3b34e9309b166072f73898017b88208a2f04b947
Comment 7 Vlad Zahorodnii 2024-07-15 08:08:53 UTC
Git commit 634e8be469c94763940f938fa446daee552b0cdf by Vlad Zahorodnii.
Committed on 15/07/2024 at 07:55.
Pushed by vladz into branch 'Plasma/6.1'.

tiling: Don't put maximized windows in tile

After !5532 existing behavior in public scripting API was changed for maximized Windows.
Maximized Windows didn't have a tile on purpose.
This behaviour was changed, as after refactoring separate members for storing QuickTileMode in Window and tile itself were unified
Previously QuickTileMode::Maximize was only set in the Window itself in m_quickTileMode, while tile itself was removed (by setTile(nullptr)).

Current QuickTileMod for current Window isn't part of public scripting API, so it's okay to break it.

This restores compatability with scripts created for KWin 6.0.5 and earlier

Signed-off-by: Alik Aslanyan <inline0@pm.me>


(cherry picked from commit 3b34e9309b166072f73898017b88208a2f04b947)

Co-authored-by: Alik Aslanyan <inline0@pm.me>

M  +15   -3    autotests/integration/move_resize_window_test.cpp
M  +47   -19   autotests/integration/quick_tiling_test.cpp
M  +1    -5    src/x11window.cpp
M  +1    -9    src/xdgshellwindow.cpp

https://invent.kde.org/plasma/kwin/-/commit/634e8be469c94763940f938fa446daee552b0cdf