Commit d3bdb8d6 authored by Marco Martin's avatar Marco Martin

workaround for correct wayland positioning

Summary:
as showEvent is too soon, create the plasma surface on
:Expose event, and reposition the surface

Test Plan: krunner is correctly positioned with correct blur and shadows

Reviewers: #plasma, #plasma_on_wayland, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: hein, davidedmundson, graesslin, plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D5748
parent 475e3ec3
......@@ -53,8 +53,7 @@ View::View(QWindow *)
: PlasmaQuick::Dialog(),
m_offset(.5),
m_floating(false),
m_plasmaShell(nullptr),
m_plasmaShellSurface(nullptr)
m_plasmaShell(nullptr)
{
initWayland();
setClearBeforeRendering(true);
......@@ -229,27 +228,26 @@ bool View::event(QEvent *event)
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
}
if (m_plasmaShell && event->type() == QEvent::PlatformSurface) {
if (auto e = dynamic_cast<QPlatformSurfaceEvent*>(event)) {
using namespace KWayland::Client;
switch (e->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated: {
Surface *s = Surface::fromWindow(this);
if (!s) {
return false;
}
m_plasmaShellSurface = m_plasmaShell->createSurface(s, this);
m_plasmaShellSurface->setRole(PlasmaShellSurface::Role::Panel);
m_plasmaShellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsGoBelow);
m_plasmaShellSurface->setPanelTakesFocus(true);
break;
}
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
delete m_plasmaShellSurface;
m_plasmaShellSurface = nullptr;
break;
if (m_plasmaShell && event->type() == QEvent::Expose) {
using namespace KWayland::Client;
if (!m_plasmaShellSurface) {
Surface *s = Surface::fromWindow(this);
if (!s) {
return retval;
}
m_plasmaShellSurface = m_plasmaShell->createSurface(s, this);
m_plasmaShellSurface->setRole(PlasmaShellSurface::Role::Panel);
m_plasmaShellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsGoBelow);
m_plasmaShellSurface->setPanelTakesFocus(true);
//this should be on showEvent, but it was too soon so none of those had any effect
KWindowSystem::setOnAllDesktops(winId(), true);
positionOnScreen();
requestActivate();
//positionOnScreen tried to position it in the position it already had, so no moveevent happens and we need to manually posiyion the surface
m_plasmaShellSurface->setPosition(position());
}
} else if (event->type() == QEvent::Hide) {
delete m_plasmaShellSurface;
} else if (m_plasmaShellSurface && event->type() == QEvent::Move) {
QMoveEvent *me = static_cast<QMoveEvent *>(event);
m_plasmaShellSurface->setPosition(me->pos());
......
......@@ -19,10 +19,13 @@
#ifndef VIEW_H
#define VIEW_H
#include <QPointer>
#include <QtQuick/QQuickView>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KWayland/Client/plasmashell.h>
#include "dialog.h"
namespace KDeclarative {
......@@ -95,7 +98,7 @@ private:
bool m_floating : 1;
QStringList m_history;
KWayland::Client::PlasmaShell *m_plasmaShell;
KWayland::Client::PlasmaShellSurface *m_plasmaShellSurface;
QPointer <KWayland::Client::PlasmaShellSurface> m_plasmaShellSurface;
};
......
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