[style] Reparent window shadows to widgets

Authored by zzag on May 21 2020, 10:56 AM.

Description

[style] Reparent window shadows to widgets

We would like to destroy a shadow after the decorated window has gotten
unmapped or destroyed. To do that, we install an event filter on the widget
and make the shadow a child of the underlying window.

Unfortunately, the underlying window and the widget have different life
times. To counter for that, we clean up _shadows after the shadow got
destroyed. This turned out to be a really bad idea because when someone
does qDeleteAll(_shadows), QMap iterators will become invalid.

Since KWindowShadow handles the case where it becomes orphaned gracefully,
we can make shadows children of widgets to work around the crash.

Still, it would be nice to call KWindowShadow::destroy() after the native
resources for the window get destroyed.