Emphasize minimization in MinimizeAll script
ClosedPublic

Authored by smerkov on Sep 18 2019, 8:31 AM.

Details

Summary

MinimizeAll should work as follows:

As long as there's something to minimize, do that.
Otherwise unminimize only the windows we minimized
on last invocation.

Quote above is from Comment 11 by Thomas Lübking of BUG: 356161.

But current code does not fulfill these duties. Try next case: run minimizeall on some windows, then click on one of windows, then run minimizeall again. All windows would be unminimized!

I have tried to make small changes to original code of main.js, but i can't because i don't understand it.

Thats why i wrote my own version. Then i changed my version to version of zzag, because his code is more simple. I have tested both versions.

BUG: 356161

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
smerkov created this revision.Sep 18 2019, 8:31 AM
Restricted Application added a project: KWin. · View Herald TranscriptSep 18 2019, 8:31 AM
Restricted Application added a subscriber: kwin. · View Herald Transcript
smerkov requested review of this revision.Sep 18 2019, 8:31 AM
zzag added a reviewer: KWin.Sep 18 2019, 11:00 AM
zzag added a subscriber: zzag.

What about simplifying it a bit as well? e.g.

function minimizeAllWindows() {
    var allClients = workspace.clientList();
    var relevantClients = [];
    var minimize = false;

    for (var i = 0; i < allClients.length; ++i) {
        if (!isRelevant(allClients[i])) {
            continue;
        }
        if (!allClients[i].minimized) {
            minimize = true;
        }
        relevantClients.push(allClients[i]);
    }

    for (var i = 0; i < relevantClients.length; ++i) {
        var wasMinimizedByScript = relevantClients[i].minimizedByScript;
        delete relevantClients[i].minimizedByScript;

        if (minimize) {
            if (relevantClients[i].minimized) {
                continue;
            }
            relevantClients[i].minimized = true;
            relevantClients[i].minimizedByScript = true;
        } else {
            if (!wasMinimizedByScript) {
                continue;
            }
            relevantClients[i].minimized = false;
        }
    }
}

(I didn't test this script though)

Please more verbose summary.

smerkov updated this revision to Diff 66386.Sep 18 2019, 2:40 PM
smerkov edited the summary of this revision. (Show Details)

I changed my version to version of zzag, because his code is more simple. I have tested both versions.

zzag accepted this revision.Sep 18 2019, 2:45 PM

Do you have commit access?

This revision is now accepted and ready to land.Sep 18 2019, 2:45 PM
zzag added a comment.Sep 18 2019, 2:50 PM

Nitpick: please use imperative mood in the subject line.

In D24044#533973, @zzag wrote:

Do you have commit access?

Sorry but i don't know how to do it. Can you commit?

ngraham edited the summary of this revision. (Show Details)Sep 18 2019, 3:00 PM
zzag added a comment.Sep 18 2019, 3:03 PM

Sorry but i don't know how to do it. Can you commit?

Can you provide your real name and email address for commit authorship information?

In D24044#534012, @zzag wrote:

Sorry but i don't know how to do it. Can you commit?

Can you provide your real name and email address for commit authorship information?

Anton Smerkov
blago37@mail.ru

smerkov retitled this revision from MinimizeAll wrong behaviour to Emphasize minimization in MinimizeAll script.Sep 18 2019, 3:07 PM
This revision was automatically updated to reflect the committed changes.