Replace foreach loops and improve code style in composite
ClosedPublic

Authored by romangg on Aug 7 2019, 8:34 PM.

Details

Summary

Replaces foreach loops with modern for loops and improve code style overall.

Test Plan

Auto tests pass as before and manually in X and Wayland sessions.

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.
romangg created this revision.Aug 7 2019, 8:34 PM
Restricted Application added a project: KWin. · View Herald TranscriptAug 7 2019, 8:34 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
romangg requested review of this revision.Aug 7 2019, 8:34 PM
zzag added a subscriber: zzag.Aug 8 2019, 11:03 AM
zzag added inline comments.
composite.cpp
272–273 ↗(On Diff #63316)

Personal opinion: I don't like that the ternary operator is minding its own business somewhere far right.

A better approach imho

CompositingType compositingType = m_scene->compositingType();

if (compositingType & OpenGLCompositing) {
    compositingType = OpenGLCompositing;
}

// ... one day
// if (compositingType & VulkanCompositing) {
//     compositingType = VulkanCompositing;
// }

kwinApp()->platform()->setSelectedCompositor(compositingType);
309 ↗(On Diff #63316)

No short names.

334

Why did you remove auto?

350 ↗(On Diff #63316)

If you want to follow the frameworks coding style 100%, then it should be ShellClient *client.

698–699 ↗(On Diff #63316)

That's unusual line breaking.

A bit better imho

kwinApp()->platform()->createOpenGLSafePoint(
    Platform::OpenGLSafePoint::PostLastGuardedFrame);
948 ↗(On Diff #63316)

Indent only with 4 spaces.

zzag added a comment.Aug 8 2019, 11:04 AM

Looks good otherwise.

composite.cpp
350 ↗(On Diff #63316)

typo: Client *client

zzag added inline comments.Aug 8 2019, 11:13 AM
composite.cpp
334

typo: auto -> const

Thank you for feedback.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 8 2019, 12:44 PM
This revision was automatically updated to reflect the committed changes.
zzag added a comment.Aug 8 2019, 1:34 PM

You forgot to address my comment about short names.

Short names go against the frameworks coding style.

"con" needs to become "connection"
"win" needs to become "window"

I know that old code is full of short names but let's at least follow the coding style in "new" code.