Commit d4940fe6 authored by Marco Martin's avatar Marco Martin

make shadows work on wayland

Summary:
since from Qt 5.8 QtWayland destroys its surfaces every time
a window gets hidden and recreates them again when is shown
(that's how the protocol is defined) install the shadows
every time the window is shown, using a map to keep track of surfaces, in order to delete them on window hide and avoid leaks

Test Plan: popup menus have correct shadows on wayland now

Reviewers: #plasma, hpereiradacosta

Subscribers: anthonyfieroni, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5910
parent 610b6f13
......@@ -171,16 +171,40 @@ namespace Breeze
//_______________________________________________________
bool ShadowHelper::eventFilter( QObject* object, QEvent* event )
{
if( Helper::isWayland() )
{
QWidget* widget( static_cast<QWidget*>( object ) );
if( event->type() == QEvent::Paint )
{
auto iter = _widgetSurfaces.constFind( widget );
if( iter == _widgetSurfaces.constEnd() )
{
// install shadows and update winId
installShadows( widget );
}
}
else if( event->type() == QEvent::Hide )
{
auto iter = _widgetSurfaces.find( widget );
if( iter != _widgetSurfaces.end() )
{
delete iter.value();
_widgetSurfaces.erase( iter );
}
}
}
else if( Helper::isX11() )
{
// check event type
if( event->type() != QEvent::WinIdChange ) return false;
// check event type
if( event->type() != QEvent::WinIdChange ) return false;
// cast widget
QWidget* widget( static_cast<QWidget*>( object ) );
// cast widget
QWidget* widget( static_cast<QWidget*>( object ) );
// install shadows and update winId
if( installShadows( widget ) )
{ _widgets.insert( widget, widget->winId() ); }
// install shadows and update winId
if( installShadows( widget ) )
{ _widgets.insert( widget, widget->winId() ); }
}
return false;
......@@ -464,6 +488,7 @@ namespace Breeze
shadow->setOffsets( shadowMargins( widget ) );
shadow->commit();
s->commit( Surface::CommitFlag::None );
_widgetSurfaces.insert(widget, s);
return true;
#else
......
......@@ -38,6 +38,7 @@ namespace Client
{
class ShadowManager;
class ShmPool;
class Surface;
}
}
#endif
......@@ -157,6 +158,9 @@ namespace Breeze
//* registered widgets
QMap<QWidget*, WId> _widgets;
//* registered widgets to wayland surface mappings
QMap<QWidget*, KWayland::Client::Surface *> _widgetSurfaces;
//* tileset
TileSet _shadowTiles;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment