Cleaning up a bit before implementing always visible

pull/1/head
Johan Smith Agudelo Rodriguez 8 years ago
parent 42885005b2
commit a6bcc53aad

@ -29,10 +29,10 @@
#include <list>
#include <QObject>
#include <QPointer>
#include <QRect>
#include <QQuickView>
#include <QWindow>
#include <QDialog>
#include <QRect>
#include <QPointer>
#include <QScreen>
#include <Plasma>
@ -58,11 +58,11 @@ public:
explicit AbstractWindowInterface(QObject *parent = nullptr);
virtual ~AbstractWindowInterface();
virtual void setDockExtraFlags(QQuickWindow &view) = 0;
virtual void setDockStruts(WindowId dockId, const QRect &dockRect
, const QScreen &screen, Plasma::Types::Location location) const = 0;
virtual void setDockExtraFlags(QWindow &view) = 0;
virtual void setDockStruts(QWindow &view, const QRect &dockRect
, Plasma::Types::Location location) = 0;
virtual void removeDockStruts(WindowId dockId) const = 0;
virtual void removeDockStruts(QWindow &view) const = 0;
virtual WindowId activeWindow() const = 0;
virtual WindowInfoWrap requestInfo(WindowId wid) const = 0;
@ -71,8 +71,8 @@ public:
virtual const std::list<WindowId> &windows() const = 0;
virtual void skipTaskBar(const QDialog &dialog) const = 0;
virtual void slideWindow(QQuickWindow &view, Slide location) const = 0;
virtual void enableBlurBehind(QQuickWindow &view) const = 0;
virtual void slideWindow(QWindow &view, Slide location) const = 0;
virtual void enableBlurBehind(QWindow &view) const = 0;
void addDock(WindowId wid);
void removeDock(WindowId wid);

@ -61,8 +61,7 @@ DockCorona::DockCorona(QObject *parent)
m_activityConsumer(new KActivities::Consumer(this)),
m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)),
m_globalSettings(new GlobalSettings(this)),
m_globalShortcuts(new GlobalShortcuts(this)),
m_waylandDockCorona(nullptr)
m_globalShortcuts(new GlobalShortcuts(this))
{
setupWaylandIntegration();
@ -150,25 +149,32 @@ void DockCorona::load()
void DockCorona::setupWaylandIntegration()
{
using namespace KWayland::Client;
if (!KWindowSystem::isPlatformWayland()) {
return;
}
using namespace KWayland::Client;
ConnectionThread *connection = ConnectionThread::fromApplication(this);
auto connection{ConnectionThread::fromApplication(this)};
if (!connection) {
if (!connection)
return;
}
Registry *registry = new Registry(this);
Registry *registry{new Registry(this)};
registry->create(connection);
connect(registry, &Registry::plasmaShellAnnounced, this,
[this, registry](quint32 name, quint32 version) {
qDebug() << "wayland registry ::: " << name << " - " << version;
connect(registry, &Registry::plasmaShellAnnounced, this
, [this, registry](quint32 name, quint32 version) {
m_waylandDockCorona = registry->createPlasmaShell(name, version, this);
}
);
});
connect(qApp, &QCoreApplication::aboutToQuit, this, [this, registry]() {
if (m_waylandDockCorona)
m_waylandDockCorona->release();
registry->release();
});
registry->setup();
}
@ -177,7 +183,6 @@ KWayland::Client::PlasmaShell *DockCorona::waylandDockCoronaInterface() const
return m_waylandDockCorona;
}
void DockCorona::cleanConfig()
{
auto containmentsEntries = config()->group("Containments");

@ -31,12 +31,6 @@
#include <KAboutApplicationDialog>
#include <KDeclarative/QmlObject>
namespace Plasma {
class Corona;
class Containment;
class Types;
}
class ScreenPool;
class GlobalSettings;
class GlobalShortcuts;
@ -45,6 +39,12 @@ namespace KActivities {
class Consumer;
}
namespace Plasma {
class Corona;
class Containment;
class Types;
}
namespace KWayland {
namespace Client {
class PlasmaShell;
@ -153,7 +153,7 @@ private:
GlobalSettings *m_globalSettings{nullptr};
GlobalShortcuts *m_globalShortcuts{nullptr};
KWayland::Client::PlasmaShell *m_waylandDockCorona;
KWayland::Client::PlasmaShell *m_waylandDockCorona{nullptr};
friend class GlobalShortcuts;
};

@ -64,7 +64,6 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
setColor(QColor(Qt::transparent));
setClearBeforeRendering(true);
const auto flags = Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint
| Qt::NoDropShadowWindowHint
@ -222,33 +221,28 @@ void DockView::init()
void DockView::setupWaylandIntegration()
{
if (m_shellSurface) {
// already setup
using namespace KWayland::Client;
if (m_shellSurface)
return;
}
if (DockCorona *c = qobject_cast<DockCorona *>(corona())) {
using namespace KWayland::Client;
PlasmaShell *interface = c->waylandDockCoronaInterface();
PlasmaShell *interface{c->waylandDockCoronaInterface()};
if (!interface) {
if (!interface)
return;
}
Surface *s = Surface::fromWindow(this);
Surface *s{Surface::fromWindow(this)};
if (!s) {
if (!s)
return;
}
m_shellSurface = interface->createSurface(s, this);
qDebug() << "wayland dock window surface was created...";
KWayland::Client::PlasmaShellSurface::PanelBehavior behavior;
behavior = KWayland::Client::PlasmaShellSurface::PanelBehavior::WindowsGoBelow;
m_shellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel);
m_shellSurface->setSkipTaskbar(true);
m_shellSurface->setPanelBehavior(behavior);
m_shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible);
}
}
@ -1262,9 +1256,10 @@ bool DockView::event(QEvent *e)
break;
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
m_shellSurface->release();
delete m_shellSurface;
qDebug() << "wayland dock window surface was deleted...";
m_shellSurface = nullptr;
qDebug() << "wayland dock window surface was deleted...";
PanelShadows::self()->removeWindow(this);
break;
}
@ -1779,7 +1774,6 @@ Plasma::Containment *DockView::containmentById(uint id)
return 0;
}
//!END overriding context menus behavior
//!BEGIN draw panel shadows outside the dock window

@ -288,8 +288,7 @@ private:
Plasma::FrameSvg *m_background{nullptr};
//only for the mask, not to actually paint
Plasma::FrameSvg::EnabledBorders m_enabledBorders = Plasma::FrameSvg::AllBorders;
Plasma::FrameSvg::EnabledBorders m_enabledBorders{Plasma::FrameSvg::AllBorders};
KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};
};

@ -68,7 +68,7 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
VisibilityManagerPrivate::~VisibilityManagerPrivate()
{
qDebug() << "VisibilityManagerPrivate deleting...";
wm->removeDockStruts(view->winId());
wm->removeDockStruts(*view);
wm->removeDock(view->winId());
}
@ -85,7 +85,7 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
}
if (this->mode == Dock::AlwaysVisible) {
wm->removeDockStruts(view->winId());
wm->removeDockStruts(*view);
} else {
connections[3] = connect(wm, &WindowSystem::currentDesktopChanged
, this, [&] {
@ -109,18 +109,18 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
switch (this->mode) {
case Dock::AlwaysVisible: {
if (view->containment() && !view->containment()->isUserConfiguring() && view->screen()) {
wm->setDockStruts(view->winId(), dockGeometry, *view->screen(), view->location());
wm->setDockStruts(*view, dockGeometry, view->location());
}
connections[0] = connect(view->containment(), &Plasma::Containment::locationChanged
, this, [&]() {
if (view->containment()->isUserConfiguring())
wm->removeDockStruts(view->winId());
wm->removeDockStruts(*view);
});
connections[1] = connect(view->containment(), &Plasma::Containment::userConfiguringChanged
, this, [&](bool configuring) {
if (!configuring && view->screen())
wm->setDockStruts(view->winId(), dockGeometry, *view->screen(), view->containment()->location());
wm->setDockStruts(*view, dockGeometry, view->containment()->location());
});
raiseDock(true);
}
@ -323,7 +323,7 @@ inline void VisibilityManagerPrivate::setDockGeometry(const QRect &geometry)
this->dockGeometry = geometry;
if (mode == Dock::AlwaysVisible && !view->containment()->isUserConfiguring() && view->screen()) {
wm->setDockStruts(view->winId(), this->dockGeometry, *view->screen(), view->containment()->location());
wm->setDockStruts(*view, this->dockGeometry, view->containment()->location());
}
}

@ -49,7 +49,7 @@ WaylandInterface::WaylandInterface(QObject *parent)
m_registry = new Registry(this);
m_registry->create(m_connection);
connect(qApp, &QCoreApplication::aboutToQuit, this, [=]() {
connect(qApp, &QCoreApplication::aboutToQuit, this, [&]() {
if (m_wm)
m_wm->release();
@ -99,82 +99,85 @@ void WaylandInterface::init()
{
}
void WaylandInterface::setDockExtraFlags(QQuickWindow &view)
void WaylandInterface::setDockExtraFlags(QWindow &view)
{
auto surface {Surface::fromQtWinId(view.winId())};
if (surface == nullptr) {
qWarning() << "the surface of the Dock can't be created";
return;
}
auto shellSurface {PlasmaShellSurface::get(surface)};
if (shellSurface == nullptr) {
qWarning() << "the shell surface can't be created";
return;
}
shellSurface->setSkipTaskbar(true);
shellSurface->setRole(PlasmaShellSurface::Role::Panel);
shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsGoBelow);
Q_UNUSED(view)
}
void WaylandInterface::setDockStruts(WindowId dockId, const QRect &dockRect
, const QScreen &screen, Plasma::Types::Location location) const
void WaylandInterface::setDockStruts(QWindow &view, const QRect &dockRect
, Plasma::Types::Location location)
{
NETExtendedStrut strut;
const QRect currentScreen {screen.geometry()};
const QRect wholeScreen {{0, 0}, screen.virtualSize()};
switch (location) {
case Plasma::Types::TopEdge: {
const int topOffset {screen.geometry().top()};
strut.top_width = dockRect.height() + topOffset;
strut.top_start = dockRect.x();
strut.top_end = dockRect.x() + dockRect.width() - 1;
break;
}
case Plasma::Types::BottomEdge: {
const int bottomOffset {wholeScreen.bottom() - currentScreen.bottom()};
strut.bottom_width = dockRect.height() + bottomOffset;
strut.bottom_start = dockRect.x();
strut.bottom_end = dockRect.x() + dockRect.width() - 1;
break;
}
case Plasma::Types::LeftEdge: {
const int leftOffset = {screen.geometry().left()};
strut.left_width = dockRect.width() + leftOffset;
strut.left_start = dockRect.y();
strut.left_end = dockRect.y() + dockRect.height() - 1;
break;
}
case Plasma::Types::RightEdge: {
const int rightOffset = {wholeScreen.right() - currentScreen.right()};
strut.right_width = dockRect.width() + rightOffset;
strut.right_start = dockRect.y();
strut.right_end = dockRect.y() + dockRect.height() - 1;
break;
}
default:
qWarning() << "wrong location:" << qEnumToStr(location);
return;
}
KWindowSystem::setExtendedStrut(dockId.value<WId>(),
strut.left_width, strut.left_start, strut.left_end,
strut.right_width, strut.right_start, strut.right_end,
strut.top_width, strut.top_start, strut.top_end,
strut.bottom_width, strut.bottom_start, strut.bottom_end
);
// auto surface = std::make_unique<Surface>(Surface::fromWindow(&view));
// if (!surface) {
// qWarning() << "the surface of the Dock can't be created";
// return;
// }
//
// auto shellSurface = std::make_unique<PlasmaShellSurface>(m_plasmaShell->createSurface(surface.get(), this));
// if (!shellSurface) {
// qWarning() << "the shell surface can't be created";
// return;
// }
//
// shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible);
// NETExtendedStrut strut;
//
// const QRect currentScreen {screen.geometry()};
// const QRect wholeScreen {{0, 0}, screen.virtualSize()};
// switch (location) {
// case Plasma::Types::TopEdge: {
// const int topOffset {screen.geometry().top()};
// strut.top_width = dockRect.height() + topOffset;
// strut.top_start = dockRect.x();
// strut.top_end = dockRect.x() + dockRect.width() - 1;
// break;
// }
//
// case Plasma::Types::BottomEdge: {
// const int bottomOffset {wholeScreen.bottom() - currentScreen.bottom()};
// strut.bottom_width = dockRect.height() + bottomOffset;
// strut.bottom_start = dockRect.x();
// strut.bottom_end = dockRect.x() + dockRect.width() - 1;
// break;
// }
//
// case Plasma::Types::LeftEdge: {
// const int leftOffset = {screen.geometry().left()};
// strut.left_width = dockRect.width() + leftOffset;
// strut.left_start = dockRect.y();
// strut.left_end = dockRect.y() + dockRect.height() - 1;
// break;
// }
//
// case Plasma::Types::RightEdge: {
// const int rightOffset = {wholeScreen.right() - currentScreen.right()};
// strut.right_width = dockRect.width() + rightOffset;
// strut.right_start = dockRect.y();
// strut.right_end = dockRect.y() + dockRect.height() - 1;
// break;
// }
//
// default:
// qWarning() << "wrong location:" << qEnumToStr(location);
// return;
// }
//
// KWindowSystem::setExtendedStrut(dockId.value<WId>(),
// strut.left_width, strut.left_start, strut.left_end,
// strut.right_width, strut.right_start, strut.right_end,
// strut.top_width, strut.top_start, strut.top_end,
// strut.bottom_width, strut.bottom_start, strut.bottom_end
// );
}
void WaylandInterface::removeDockStruts(WindowId dockId) const
void WaylandInterface::removeDockStruts(QWindow &view) const
{
KWindowSystem::setStrut(dockId.value<WId>(), 0, 0, 0, 0);
KWindowSystem::setStrut(view.winId(), 0, 0, 0, 0);
}
WindowId WaylandInterface::activeWindow() const
@ -194,7 +197,7 @@ void WaylandInterface::skipTaskBar(const QDialog &dialog) const
KWindowSystem::setState(dialog.winId(), NET::SkipTaskbar);
}
void WaylandInterface::slideWindow(QQuickWindow &view, AbstractWindowInterface::Slide location) const
void WaylandInterface::slideWindow(QWindow &view, AbstractWindowInterface::Slide location) const
{
auto slideLocation = KWindowEffects::NoEdge;
@ -222,7 +225,7 @@ void WaylandInterface::slideWindow(QQuickWindow &view, AbstractWindowInterface::
KWindowEffects::slideWindow(view.winId(), slideLocation, -1);
}
void WaylandInterface::enableBlurBehind(QQuickWindow &view) const
void WaylandInterface::enableBlurBehind(QWindow &view) const
{
KWindowEffects::enableBlurBehind(view.winId());
}
@ -304,7 +307,7 @@ void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w)
emit windowRemoved(win->internalId());
});
//connect(w, SIGNAL(activeChanged()), mapper, SLOT(map()));
connect(w, SIGNAL(activeChanged()), mapper, SLOT(map()));
connect(w, SIGNAL(fullscreenChanged()), mapper, SLOT(map()));
connect(w, SIGNAL(geometryChanged()), mapper, SLOT(map()));
connect(w, SIGNAL(maximizedChanged()), mapper, SLOT(map()));

@ -45,11 +45,11 @@ public:
explicit WaylandInterface(QObject *parent = nullptr);
~WaylandInterface() override;
void setDockExtraFlags(QQuickWindow &view) override;
void setDockStruts(WindowId dockId, const QRect &dockRect
, const QScreen &screen, Plasma::Types::Location location) const override;
void setDockExtraFlags(QWindow &view) override;
void setDockStruts(QWindow &view, const QRect &dockRect
, Plasma::Types::Location location) override;
void removeDockStruts(WindowId dockId) const override;
void removeDockStruts(QWindow &view) const override;
WindowId activeWindow() const override;
WindowInfoWrap requestInfo(WindowId wid) const override;
@ -58,15 +58,14 @@ public:
const std::list<WindowId> &windows() const override;
void skipTaskBar(const QDialog &dialog) const override;
void slideWindow(QQuickWindow &view, Slide location) const override;
void enableBlurBehind(QQuickWindow &view) const override;
void slideWindow(QWindow &view, Slide location) const override;
void enableBlurBehind(QWindow &view) const override;
private:
void init();
inline bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const;
void windowCreatedProxy(KWayland::Client::PlasmaWindow *w);
WindowId m_desktopId;
QSignalMapper *mapper{nullptr};
KWayland::Client::Registry *m_registry{nullptr};

@ -73,7 +73,7 @@ XWindowInterface::~XWindowInterface()
{
}
void XWindowInterface::setDockExtraFlags(QQuickWindow &view)
void XWindowInterface::setDockExtraFlags(QWindow &view)
{
NETWinInfo winfo(QX11Info::connection()
, static_cast<xcb_window_t>(view.winId())
@ -87,17 +87,19 @@ void XWindowInterface::setDockExtraFlags(QQuickWindow &view)
KWindowSystem::setOnActivities(view.winId(), {"0"});
}
void XWindowInterface::setDockStruts(WindowId dockId, const QRect &dockRect
, const QScreen &screen, Plasma::Types::Location location) const
void XWindowInterface::setDockStruts(QWindow &view, const QRect &dockRect
, Plasma::Types::Location location)
{
NETExtendedStrut strut;
const QRect currentScreen {screen.geometry()};
const QRect wholeScreen {{0, 0}, screen.virtualSize()};
const auto screen {view.screen()};
const QRect currentScreen {screen->geometry()};
const QRect wholeScreen {{0, 0}, screen->virtualSize()};
switch (location) {
case Plasma::Types::TopEdge: {
const int topOffset {screen.geometry().top()};
const int topOffset {screen->geometry().top()};
strut.top_width = dockRect.height() + topOffset;
strut.top_start = dockRect.x();
strut.top_end = dockRect.x() + dockRect.width() - 1;
@ -112,7 +114,7 @@ void XWindowInterface::setDockStruts(WindowId dockId, const QRect &dockRect
break;
}
case Plasma::Types::LeftEdge: {
const int leftOffset = {screen.geometry().left()};
const int leftOffset = {screen->geometry().left()};
strut.left_width = dockRect.width() + leftOffset;
strut.left_start = dockRect.y();
strut.left_end = dockRect.y() + dockRect.height() - 1;
@ -130,7 +132,7 @@ void XWindowInterface::setDockStruts(WindowId dockId, const QRect &dockRect
return;
}
KWindowSystem::setExtendedStrut(dockId.value<WId>(),
KWindowSystem::setExtendedStrut(view.winId(),
strut.left_width, strut.left_start, strut.left_end,
strut.right_width, strut.right_start, strut.right_end,
strut.top_width, strut.top_start, strut.top_end,
@ -138,9 +140,9 @@ void XWindowInterface::setDockStruts(WindowId dockId, const QRect &dockRect
);
}
void XWindowInterface::removeDockStruts(WindowId dockId) const
void XWindowInterface::removeDockStruts(QWindow &view) const
{
KWindowSystem::setStrut(dockId.value<WId>(), 0, 0, 0, 0);
KWindowSystem::setStrut(view.winId(), 0, 0, 0, 0);
}
WindowId XWindowInterface::activeWindow() const
@ -158,7 +160,7 @@ void XWindowInterface::skipTaskBar(const QDialog &dialog) const
KWindowSystem::setState(dialog.winId(), NET::SkipTaskbar);
}
void XWindowInterface::slideWindow(QQuickWindow &view, AbstractWindowInterface::Slide location) const
void XWindowInterface::slideWindow(QWindow &view, AbstractWindowInterface::Slide location) const
{
auto slideLocation = KWindowEffects::NoEdge;
@ -186,7 +188,7 @@ void XWindowInterface::slideWindow(QQuickWindow &view, AbstractWindowInterface::
KWindowEffects::slideWindow(view.winId(), slideLocation, -1);
}
void XWindowInterface::enableBlurBehind(QQuickWindow &view) const
void XWindowInterface::enableBlurBehind(QWindow &view) const
{
KWindowEffects::enableBlurBehind(view.winId());
}

@ -38,11 +38,11 @@ public:
explicit XWindowInterface(QObject *parent = nullptr);
~XWindowInterface() override;
void setDockExtraFlags(QQuickWindow &view) override;
void setDockStruts(WindowId dockId, const QRect &dockRect
, const QScreen &screen, Plasma::Types::Location location) const override;
void setDockExtraFlags(QWindow &view) override;
void setDockStruts(QWindow &view, const QRect &dockRect
, Plasma::Types::Location location) override;
void removeDockStruts(WindowId dockId) const override;
void removeDockStruts(QWindow &view) const override;
WindowId activeWindow() const override;
WindowInfoWrap requestInfo(WindowId wid) const override;
@ -51,8 +51,8 @@ public:
const std::list<WindowId> &windows() const override;
void skipTaskBar(const QDialog &dialog) const override;
void slideWindow(QQuickWindow &view, Slide location) const override;
void enableBlurBehind(QQuickWindow &view) const override;
void slideWindow(QWindow &view, Slide location) const override;
void enableBlurBehind(QWindow &view) const override;
private:
bool isValidWindow(const KWindowInfo &winfo) const;

Loading…
Cancel
Save