Bug 380836

Summary: Horizontal and Vertical maximized states are reversed in signal parameters
Product: [Plasma] kwin Reporter: Chris Holland <zrenfire>
Component: scriptingAssignee: kde.org
Status: RESOLVED FIXED    
Severity: normal CC: kde.org, nate
Priority: NOR    
Version: 5.9.5   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: kwin console log output

Description Chris Holland 2017-06-04 19:36:21 UTC
Created attachment 105916 [details]
kwin console log output

I only noticed this when I was skimming the code. Going to write something

https://github.com/KDE/kde-workspace/blob/master/kwin/netinfo.cpp#L259

    if ((mask & NET::Max) == NET::Max)
        m_client->setMaximize(state & NET::MaxVert, state & NET::MaxHoriz);
    else if (mask & NET::MaxVert)
        m_client->setMaximize(state & NET::MaxVert, m_client->maximizeMode() & Client::MaximizeHorizontal);
    else if (mask & NET::MaxHoriz)
        m_client->setMaximize(m_client->maximizeMode() & Client::MaximizeVertical, state & NET::MaxHoriz);

https://github.com/KDE/kwin/blob/master/geometry.cpp#L2163

    void AbstractClient::setMaximize(bool vertically, bool horizontally) {
        ...
        emit clientMaximizedStateChanged(this, newMode);
        emit clientMaximizedStateChanged(this, vertically, horizontally);

^---
Note how vertically is passed first, while the function is defined with horizontal coming first.
Reversing the variables will probably fix things, though I've no idea what is depending on this code.

https://github.com/KDE/kwin/blob/master/scripting/workspace_wrapper.cpp#L258

    connect(client, static_cast<void (Client::*)(KWin::AbstractClient*, bool, bool)>(&Client::clientMaximizedStateChanged),
            this, &WorkspaceWrapper::clientMaximizeSet);

https://github.com/KDE/kwin/blob/master/scripting/workspace_wrapper.h#L100

    void clientMaximizeSet(KWin::AbstractClient *client, bool h, bool v);

(KDE 4) https://github.com/KDE/kde-workspace/blob/master/kwin/scripting/workspace_wrapper.h#L98

    void clientMaximizeSet(KWin::Client *client, bool h, bool v);


https://techbase.kde.org/Development/Tutorials/KWin/Scripting/API_4.9#KWin::WorkspaceWrapper

    clientMaximizedStateChanged(KWin::Client *c, bool h, bool v)
Comment 1 kde.org 2021-11-06 19:35:38 UTC
most of the code has been refactored, but I found one location in abstract_client.cpp where the arguments were swapped. I created https://invent.kde.org/plasma/kwin/-/merge_requests/1610 to fix this.
Comment 3 kde.org 2021-11-07 09:10:02 UTC
Thank you for your feedback. I'll have a look the the other files as well and update my merge request to fix this.
Comment 4 Vlad Zahorodnii 2022-05-19 06:33:25 UTC
Git commit f6f4a296f26215d36eb1f12c66d3b485f5b7e825 by Vlad Zahorodnii, on behalf of Guenther Grau.
Committed on 19/05/2022 at 06:33.
Pushed by vladz into branch 'master'.

Fix argument order for clientMaximizedStateChanged

Arguments for clientMaximizedStateChanged were incorrect in window.cpp.
They are correct in xdgshellclient.cpp and window.h

M  +1    -1    src/window.cpp

https://invent.kde.org/plasma/kwin/commit/f6f4a296f26215d36eb1f12c66d3b485f5b7e825