QPainter's auto-scaling is prone to off-by-one rounding errors and draws on
fractional coordinates. With this change, we paint on a 1x DPR QPainter and
scale the shadow offset and strength manually based on DPR.
This resolves an issue with resulting in seams on the right and bottom
edges of a menu due to shadow boundaries being off-by-one.
BUG: 418166
v2: remove unrelated formatting changes
v3:
- move the DPR helper to ShadowHelper
- retrieve the DPR from the widget instead of the global QGuiApplication
- added BUG reference
The order in which the underlying window and the shadow are destroyed is
undefined. In most cases, the shadow is destroyed after the window, but
in rare cases it may be vice versa, for example it's the case with popup
menus in Dolphin. If the shadow is destroyed before the window, then
the window will be shadowless when the compositor animates it.
The only way to guarantee that the shadow is destroyed after the window
is to create a parent-child relationship between two.
Given that the widget and the window have different lifetimes, we have
to be extra careful with keeping dangling pointers out of _shadows.
(cherry picked from commit 5f62d1c74e)
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.
Reviewers: #kwin, #plasma, mart
Reviewed By: #plasma, mart
Subscribers: mart, plasma-devel
Tags: #plasma
Maniphest Tasks: T12496
Differential Revision: https://phabricator.kde.org/D26475
- removed useless "virtual" specifications
- removed useless destructors
- cleanup variable initializations
- moved protected methods as private when possible for better encapsulation
Summary:
Refine shadows in order to match decoration shadows. See D11069
The refined KStyle shadows(from Small to Very Large)
{F5754393, layout=center, size=full}
Desktop experience with the refined shadows
{F5754394, layout=center, size=full}
Depends on D11198
Reviewers: #breeze, #vdg, hpereiradacosta
Reviewed By: hpereiradacosta
Subscribers: abetts, ngraham, plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D11175
Summary:
KWin has a problem that breeze crashes it on tear down if the shadow was
created. This is due to breeze destroying the Wayland connection after
KWin destroyed it which triggers a crash in libwayland.
D6571 addresses this problem by deleting the ConnectionThread created by
plugins prior to destroying the Wayland server.
By changing the ownership of the registry and the interfaces to be
children and grandchildren of the ConnectionThread we can ensure that
KWin can clean up this area properly. For non KWin cases this doesn't
change anything, everything is still deleted as a child of ShadowHelper.
Test Plan: Ensured that the Registry gets deleted before KWin's own connection
Reviewers: #kwin, #plasma
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6572
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
Summary:
This is a change mostly for KWin (the Wayland compositor). The internal
Wayland connection is created after the QStyle is created in the case of
KWin. But both are created before the event dispatcher is run for the
first time. So delaying by one cycle makes it work for KWin and also all
other Wayland applications.
BUG: 372001
FIXED-IN: 5.8.4
Reviewers: #plasma, broulik, hpereiradacosta
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D3239
Integrate with Wayland and create a ShadowManager if available.
With the ShadowManager it's possible to create a Shadow for a Surface.
The Wayland shadow is very similar to the X11 based one, so a lot of
code can be shared. The code is slightly refactored to share the common
code paths to create and destroy the shadow.
REVIEW: 127352
Breeze checks if shadows are supported by checking for a property on the
root window. This is set by kwin at some point after startup.
This leaves a gap for apps/plasmashell to start, determine shadows are
not supported and then never render them for the lifespan of that app.
It also can't handle window managers being replaced.
Not checking solves all the issues with limited drawback
REVIEW: 123284
- move all metrics shadowhelper
- handle light source from option
- make actual shadow size and offsets adjustable
- calculate 'effective' shadow size, and overlap, accordingly.