Bug 496966 - maximized window state tracking is broken
Summary: maximized window state tracking is broken
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: X11 Integration (other bugs)
Version First Reported In: 6.2.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-02 23:03 UTC by Rémi Bernon
Modified: 2024-12-03 23:56 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rémi Bernon 2024-12-02 23:03:11 UTC
SUMMARY

KWin loses track of maximized windows if a configure request is sent to a window with the maximized _NET_WM_STATE bits set. This makes it very difficult, if not impossible, for Wine to support maximized windows with KWin.

STEPS TO REPRODUCE
1. Create and map a window.
2. Send _NET_WM_STATE change request with _NET_WM_STATE_MAXIMIZED_VERT and _NET_WM_STATE_MAXIMIZED_HORZ atoms added.
3. Send window config request with XReconfigureWMWindow
4. Send _NET_WM_STATE change request with _NET_WM_STATE_MAXIMIZED_VERT and _NET_WM_STATE_MAXIMIZED_HORZ atoms removed.

OBSERVED RESULT

No _NET_WM_STATE PropertyNotify event is received after 4, window ends up in a broken maximized state.

EXPECTED RESULT

Application receives a _NET_WM_STATE PropertyNotify with maximized atoms removed, window is restored to its original size (or newly configured sized, up to KWin).

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: v6.2.4

ADDITIONAL INFORMATION

Bogus line is https://invent.kde.org/plasma/kwin/-/blob/v6.2.4/src/x11window.cpp?ref_type=tags#L4065, still present in master. It changes `max_mode` without updating other maximized state information, and doesn't send _NET_WM_STATE updates to the client either. Not that it should, because it would otherwise unmaximize windows as soon as a config request is received, which isn't right either. It probably shouldn't touch max_mode.

The reason why this cause a problem later on is because when _NET_WM_STATE is later changed by the client to restore the window, the check at https://invent.kde.org/plasma/kwin/-/blob/v6.2.4/src/x11window.cpp?ref_type=tags#L4518 decides that there's nothing to do. The function returns without changing the _NET_WM_STATE property, and the client never receives an answer to its request. An alternative fix to removing the max_mode update described above, is to call info->setState with the right bits before returning, so that the client receives a notification about the actual KWin internal maximized state.
Comment 1 Bug Janitor Service 2024-12-02 23:14:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6854
Comment 2 Vlad Zahorodnii 2024-12-03 23:56:54 UTC
Git commit 53c89ebf20af9cd460b3ae3de8ab68e43f872d1a by Vlad Zahorodnii, on behalf of Rémi Bernon.
Committed on 03/12/2024 at 23:47.
Pushed by vladz into branch 'master'.

Don't change max_mode in configureRequest.

Window may still be maximized and should be considered as such until
maximized state is actually changed through ::maximize calls for other
side effects to take action.

M  +0    -1    src/x11window.cpp

https://invent.kde.org/plasma/kwin/-/commit/53c89ebf20af9cd460b3ae3de8ab68e43f872d1a