Use lambdas for queued invocation of composition suspending
ClosedPublic

Authored by davidedmundson on Sep 26 2019, 2:30 PM.

Details

Summary

Qt's metaobject is rather sensitive with scope resolution.

Foo::Bar and Bar don't always match to a Qt metaobject, even if they
refer to the same thing to a compiler. Here we register
X11Compositor::SuspendReason but Q_ARG uses SuspendReason and they don't
match. This leads to a runtime failure where the method isn't invoked.

Rather than fixing metaobject usage, port the whole thing to lambdas
which does better compile time checking and is generally nicer to read.

BUG: 412353

Test Plan

Ran xprop to block compositing. Compositing was blocked.
Grepped source code for Q_ARG use

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.
davidedmundson created this revision.Sep 26 2019, 2:30 PM
Restricted Application added a project: KWin. · View Herald TranscriptSep 26 2019, 2:30 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
davidedmundson requested review of this revision.Sep 26 2019, 2:30 PM
zzag accepted this revision.Sep 26 2019, 2:46 PM
zzag added a subscriber: zzag.
zzag added inline comments.
composite.cpp
1016–1019

It'll be more compact with QTimer::singleShot.

QTimer::singleShot(0, this, [this]() { suspend(BlockRuleSuspend); });

I don't have strong opinion about this though.

This revision is now accepted and ready to land.Sep 26 2019, 2:46 PM
davidedmundson added inline comments.Sep 26 2019, 3:08 PM
composite.cpp
1016–1019

Yeah, I typically use QTimer out of habit, though I've seen comments saying to use QMetaObject for semantic reasons.

They end up being exactly the same thing, I don't think either is better or worse.

This revision was automatically updated to reflect the committed changes.