Commit 2d01ba64 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[scenes/qpainter] Draw decoration shadows

Summary:
QPainter doesn't render decoration shadows. It renders only
shadows provided through ShadowInterface.

With this change, painting of shadows is done in similar way OpenGL backend is
currently doing.

Before

{F5734867, layout=center, size=full}

After

{F5734870, layout=center, size=full}

Depends on D10811 (dummy decoration with shadows in autotests)

Test Plan:
* start kwin with QPainter backend enabled:

```
KWIN_COMPOSE=Q kwin_wayland --xwayland --windowed
```

* open konsole and kate:

```
DISPLAY=:1 konsole
DISPLAY=:1 kate
```

Reviewers: #kwin, graesslin, davidedmundson

Reviewed By: davidedmundson

Subscribers: abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D10943
parent 7637cfc2
......@@ -72,6 +72,7 @@ if (XCB_ICCCM_FOUND)
integrationTest(NAME testQuickTiling SRCS quick_tiling_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testGlobalShortcuts SRCS globalshortcuts_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testSceneQPainter SRCS scene_qpainter_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testSceneQPainterShadow SRCS scene_qpainter_shadow_test.cpp LIBS XCB::ICCCM)
if (KWIN_BUILD_ACTIVITIES)
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM)
......
......@@ -38,6 +38,7 @@ class PlasmaWindowManagement;
class PointerConstraints;
class Seat;
class ServerSideDecorationManager;
class ShadowManager;
class Shell;
class ShellSurface;
class ShmPool;
......@@ -85,7 +86,8 @@ enum class AdditionalWaylandInterface {
WindowManagement = 1 << 3,
PointerConstraints = 1 << 4,
IdleInhibition = 1 << 5,
AppMenu = 1 << 6
AppMenu = 1 << 6,
ShadowManager = 1 << 7
};
Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface)
/**
......@@ -106,6 +108,7 @@ void destroyWaylandConnection();
KWayland::Client::ConnectionThread *waylandConnection();
KWayland::Client::Compositor *waylandCompositor();
KWayland::Client::ShadowManager *waylandShadowManager();
KWayland::Client::Shell *waylandShell();
KWayland::Client::ShmPool *waylandShmPool();
KWayland::Client::Seat *waylandSeat();
......
This diff is collapsed.
......@@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Client/pointerconstraints.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/shadow.h>
#include <KWayland/Client/shell.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/output.h>
......@@ -62,6 +63,7 @@ static struct {
EventQueue *queue = nullptr;
Compositor *compositor = nullptr;
ServerSideDecorationManager *decoration = nullptr;
ShadowManager *shadowManager = nullptr;
Shell *shell = nullptr;
XdgShell *xdgShellV5 = nullptr;
XdgShell *xdgShellV6 = nullptr;
......@@ -163,6 +165,13 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags)
return false;
}
}
if (flags.testFlag(AdditionalWaylandInterface::ShadowManager)) {
s_waylandConnection.shadowManager = registry->createShadowManager(registry->interface(Registry::Interface::Shadow).name,
registry->interface(Registry::Interface::Shadow).version);
if (!s_waylandConnection.shadowManager->isValid()) {
return false;
}
}
if (flags.testFlag(AdditionalWaylandInterface::Decoration)) {
s_waylandConnection.decoration = registry->createServerSideDecorationManager(registry->interface(Registry::Interface::ServerSideDecorationManager).name,
registry->interface(Registry::Interface::ServerSideDecorationManager).version);
......@@ -230,6 +239,8 @@ void destroyWaylandConnection()
s_waylandConnection.xdgShellV6 = nullptr;
delete s_waylandConnection.shell;
s_waylandConnection.shell = nullptr;
delete s_waylandConnection.shadowManager;
s_waylandConnection.shadowManager = nullptr;
delete s_waylandConnection.idleInhibit;
s_waylandConnection.idleInhibit = nullptr;
delete s_waylandConnection.shm;
......@@ -264,6 +275,11 @@ Compositor *waylandCompositor()
return s_waylandConnection.compositor;
}
ShadowManager *waylandShadowManager()
{
return s_waylandConnection.shadowManager;
}
Shell *waylandShell()
{
return s_waylandConnection.shell;
......
This diff is collapsed.
......@@ -123,23 +123,17 @@ class SceneQPainterShadow : public Shadow
public:
SceneQPainterShadow(Toplevel* toplevel);
virtual ~SceneQPainterShadow();
using Shadow::ShadowElements;
using Shadow::ShadowElementTop;
using Shadow::ShadowElementTopRight;
using Shadow::ShadowElementRight;
using Shadow::ShadowElementBottomRight;
using Shadow::ShadowElementBottom;
using Shadow::ShadowElementBottomLeft;
using Shadow::ShadowElementLeft;
using Shadow::ShadowElementTopLeft;
using Shadow::ShadowElementsCount;
using Shadow::shadowPixmap;
using Shadow::topOffset;
using Shadow::leftOffset;
using Shadow::rightOffset;
using Shadow::bottomOffset;
QImage &shadowTexture() {
return m_texture;
}
protected:
virtual void buildQuads() override;
virtual bool prepareBackend() override;
private:
QImage m_texture;
};
class SceneQPainterDecorationRenderer : public Decoration::Renderer
......
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