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
wilder-5.14
Marco Martin 9 years ago
parent 475e3ec31a
commit d3bdb8d657
  1. 40
      krunner/view.cpp
  2. 5
      krunner/view.h

@ -53,8 +53,7 @@ View::View(QWindow *)
: PlasmaQuick::Dialog(), : PlasmaQuick::Dialog(),
m_offset(.5), m_offset(.5),
m_floating(false), m_floating(false),
m_plasmaShell(nullptr), m_plasmaShell(nullptr)
m_plasmaShellSurface(nullptr)
{ {
initWayland(); initWayland();
setClearBeforeRendering(true); setClearBeforeRendering(true);
@ -229,27 +228,26 @@ bool View::event(QEvent *event)
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager); KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
} }
if (m_plasmaShell && event->type() == QEvent::PlatformSurface) { if (m_plasmaShell && event->type() == QEvent::Expose) {
if (auto e = dynamic_cast<QPlatformSurfaceEvent*>(event)) { using namespace KWayland::Client;
using namespace KWayland::Client; if (!m_plasmaShellSurface) {
switch (e->surfaceEventType()) { Surface *s = Surface::fromWindow(this);
case QPlatformSurfaceEvent::SurfaceCreated: { if (!s) {
Surface *s = Surface::fromWindow(this); return retval;
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;
} }
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) { } else if (m_plasmaShellSurface && event->type() == QEvent::Move) {
QMoveEvent *me = static_cast<QMoveEvent *>(event); QMoveEvent *me = static_cast<QMoveEvent *>(event);
m_plasmaShellSurface->setPosition(me->pos()); m_plasmaShellSurface->setPosition(me->pos());

@ -19,10 +19,13 @@
#ifndef VIEW_H #ifndef VIEW_H
#define VIEW_H #define VIEW_H
#include <QPointer>
#include <QtQuick/QQuickView> #include <QtQuick/QQuickView>
#include <KConfigGroup> #include <KConfigGroup>
#include <KSharedConfig> #include <KSharedConfig>
#include <KWayland/Client/plasmashell.h>
#include "dialog.h" #include "dialog.h"
namespace KDeclarative { namespace KDeclarative {
@ -95,7 +98,7 @@ private:
bool m_floating : 1; bool m_floating : 1;
QStringList m_history; QStringList m_history;
KWayland::Client::PlasmaShell *m_plasmaShell; KWayland::Client::PlasmaShell *m_plasmaShell;
KWayland::Client::PlasmaShellSurface *m_plasmaShellSurface; QPointer <KWayland::Client::PlasmaShellSurface> m_plasmaShellSurface;
}; };

Loading…
Cancel
Save