[effects] Rewrite the Dialog Parent effect
AbandonedPublic

Authored by zzag on Jun 30 2018, 12:17 PM.

Details

Reviewers
None
Group Reviewers
KWin
Plasma
VDG
Summary

Q: Why the hell did you rewrite this effect in C++ anyway?
A: In order to cooperate with effects that animate the disappearing of
windows(e.g. the Glide effect), the rewritten Dialog Parent effect
imposes special rules on animations that can't be implemented in JavaScript.

The main motivation for rewriting this effect was to fix flickering with
alternative effects that animate the disappearing of windows(e.g. the Glide
effect, the Fall Apart effect, etc).

With only the Fade effect being used, there is no flickering of parent
windows because duration of the "Out" animation in the Fade effect is
greater than duration of the "Out" animation in the Dialog Parent effect.

The flickering problem is fixed by "freezing" current state of parent
window and dimming it [the parent window] as long as the effect that
animates its disappearing needs it.

The rewritten Dialog Parent effect also gained a new behaviour: if there
is an active full screen effect, dimmed parent windows start smoothly
brightening. That fixes parent windows being too much dark in Present Windows
and also rapid brightening when sliding between virtual desktops.

Test Plan

Diff Detail

Repository
R108 KWin
Branch
rewrite-dialogparent-effect
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 634
Build 646: arc lint + arc unit
zzag created this revision.Jun 30 2018, 12:17 PM
Restricted Application added a project: KWin. · View Herald TranscriptJun 30 2018, 12:17 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
zzag requested review of this revision.Jun 30 2018, 12:17 PM
zzag edited the summary of this revision. (Show Details)Jun 30 2018, 12:17 PM
zzag edited the test plan for this revision. (Show Details)

Interesting! In your "after" video, I notice that the dialog still somewhat awkwardly moves behind its parent window for a moment after you click on the Discard button. Is there any way to improve upon that too?

zzag added a comment.Jun 30 2018, 2:34 PM

Interesting! In your "after" video, I notice that the dialog still somewhat awkwardly moves behind its parent window for a moment after you click on the Discard button. Is there any way to improve upon that too?

I'm aware of this problem.

When a modal/dialog is closed, focus goes to the parent window. So, technically, that's correct. The Dialog Parent effect has nothing to do with this.

that can't be implemented in JavaScript.

What specifically?

I think it is a bad idea to go back to c++. From maintainability and hackability the switch to JavaScript was the most important change I ever did in KWin.

zzag added a comment.Jul 1 2018, 7:12 AM

What specifically?

If a parent window has been closed, "freeze" its current state and force it till Fade/Glide/Fall apart is finished. I think it would be wrong to continue animation in this case because the parent window can't receive focus anymore. Also, as far as I know, that's not possible to "passively" animate windows in js.

I think it is a bad idea to go back to c++.

Well, maybe. One can implement very limited subset of effects with scripted api. For example, Glide effect is just a rotation and a translation, but one can't implement it in js. Even if he/she could, projection matrices should be somehow adjusted at each animation step, otherwise animations will be distorted too much on multiple monitor setups. I think that's not possible to correctly implement dialog parent effect in js.

I don't insist on rewriting this effect in C++, if you think it should stay in JavaScript, I'm okay to abandon this change. But I urge you [KWin folks] to fix this bug. If I recall correctly a bug report, this problem is well-known since 2014 and no one seems to be trying to fix it.

From maintainability and hackability the switch to JavaScript was the most important change I ever did in KWin.

mart added a subscriber: mart.Jul 2 2018, 9:29 AM

to me, if effects are complicated, there is nothing wrong with going c++ with them
of course one should try to use c++ as little as possible, but when it's way more complicated than a window fading, may be better to have it in c++

zzag updated this revision to Diff 37234.Jul 6 2018, 8:45 AM

Rework active full screen effect handling code.

zzag abandoned this revision.Jul 22 2018, 3:09 PM

I abandon this revision because porting some scripted effects back to C++ is probably a no go.

Scripted effects are usually smaller, simpler and easier to maintain. Yet, they are also limited in what they can do. One can't implement the Glide effect (as I said earlier), or the Magic lamp effect (which is quite straightforward to implement), or the Desktop cube effect. So, I don't understand what's the point of keeping API that is good only for some certain effects. Probably, one things just should stay in C++.

Please note that I'm not saying scripting should be killed in KWin.

Anyway, my vision of KWin effects is "slightly" different from the rest so I back off, my goal is to improve KDE Plasma, not to start the C++ vs JavaScript holy war.

At this point, I still urge you to fix bugs that had been introduced after porting some effects to JavaScript because

(a) those bugs have been known for 5 years and no one seems have tried to fix them;
(b) they can be fixed by rewriting those effects back in C++.

Also, I ask you to reconsider whether having scripted effects worth it.

Yet, they are also limited in what they can do.

Scripts don't have to be limited. It's not a problem of language, it's just a problem of our own exposing wrappers.
You're right that it's an area that clearly needs work. I have porting from QScriptEngine to QJSEngine on my TODO anyway, which will greatly simplify the whole thing.

Anyway, my vision of KWin effects is "slightly" different from the rest so I back off, my goal is to improve KDE Plasma, not to start the C++ vs JavaScript holy war.

Ack. You're doing a fantastic job, and I fully understand that you're doing it with the best intentions and for the right reasons. It's not something I want to have an argument over either.

I'll give the fullScreenEffect problem from the fade patch and this issue a go before the next release, then we'll see where we end up.

zzag added a comment.Jul 22 2018, 6:36 PM

Scripts don't have to be limited. It's not a problem of language, it's just a problem of our own exposing wrappers.

Well, in some part that's language-related too. For example, if someone wants to implement the Fall Apart effect in JavaScript, he/she needs to update window quads in each frame. IIRC, the Fall Apart subdivides the window grid by 40x40. So, the scripted effect has to loop over at least 1600 window quads in each frame. Sure, at some point the code will be jit-ed. The only way to achieve max performance is to use WebAssembly, but I'm not sure whether Qt supports it and if it does, one logical question pops up "Why didn't you write this effect in C++ anyway?".

IMHO, if one can't implement all effects(starting from the background contrast and ending at the zoom) in JavaScript, there is huge problem with scripted API.

I totally understand that it's not really fun to maintain big number of C++ effects that somehow work(also, the rest of KWin, and other libs) and listen to rude comments on the Bugzilla(like, '<slow clap>'), but, if we push for scripted effects, then scripted effects API have to be complete, it should not hurt performance* and there have to be good reason for having that.

Users should not suffer because of JavaScript preference.


* I know that currently scripted effects don't have problems with performance because they only setup anim data.

FWIW, as I said earlier, I'm okay to maintain effects that I rewrote.