[kstyle] Port to KWindowSystem shadows API
AcceptedPublic

Authored by zzag on Mon, Jan 6, 7:48 PM.

Details

Reviewers
mart
Group Reviewers
KWin
Plasma
Maniphest Tasks
T12496: Shadows API in KWindowSystem
Summary

The primary task of a compositor is to take a bunch of buffers from
different clients and present them on the screen. However, the compositor
may need to present its own stuff on the screen as well.

On X11, internal clients (the ones created by KWin) are backed by real
windows. This looks a bit clumsy since KWin uses X11 to communicate with
itself.

On Wayland, we use our own QPA that talks to KWin directly. Given that
internal clients with the custom QPA are no longer backed by wayland
surfaces or x11 windows, things like blur, background contrast, and
shadows must be set through KWindowSystem APIs so KWin can catch the
relevant API calls and handle them accordingly.

The good thing is that we get rid of a good portion of platform-specific
code. The bad thing is that we still need to be cautious about QPAs that
destroy the underlying platform resources upon a window becoming hidden.

Diff Detail

Repository
R31 Breeze
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 21197
Build 21215: arc lint + arc unit
zzag created this revision.Mon, Jan 6, 7:48 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMon, Jan 6, 7:48 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
zzag requested review of this revision.Mon, Jan 6, 7:48 PM
mart accepted this revision as: Plasma, mart.Tue, Jan 7, 9:31 AM
mart added a subscriber: mart.

on the breeze-style side, this looks good

This revision is now accepted and ready to land.Tue, Jan 7, 9:31 AM
zzag updated this revision to Diff 73349.EditedSun, Jan 12, 6:54 PM

Re-write the entire port :/

In case of server-side drop-shadows, we don't want to destroy KWindowShadow
when QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed is emitted, otherwise
the associated window will be shadow-less when it's being animated by the
compositor.

In general, we need to clean up KWindowShadow internals when QWindow sends
QPlatformSurfaceEvent::SurfaceDestroyed or something, but unfortunately Qt
has no such event. :(

I would say that this use-case is pretty weird (I mean the intentional
resource leak). On the other hand, having release() or something that says
"I want to leak resource blah-blah" is also weird.

It would be great to have the following event filter

bool ShadowHelper::eventFilter(QObject *watched, QEvent *event)
{
    if (event->type() == QEvent::PlatformSurface) {
        QWidget *widget = static_cast<QWidget *>(watched);
        QPlatformSurfaceEvent *surfaceEvent = static_cast<QPlatformSurfaceEvent *>(event);
        switch (surfaceEvent->surfaceEventType()) {
        case QPlatformSurfaceEvent::SurfaceCreated:
            installShadows(widget);
            break;
        case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
            // Don't care.
            break;
        case QPlatformSurfaceEvent::SurfaceDestroyed:
            uninstallShadows(widget); // will do nothing but cleanup
            break;
        }
    }
    return false;
}
zzag updated this revision to Diff 73643.Wed, Jan 15, 6:36 PM
  • Drop sub-surface test
  • Don't use obsolete QWidget::isTopLevel()