1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-08 13:18:09 +03:00

fix #64,position views properly under wayland

--last week commit about beautiful slide in/out through
kwin infrastructure broke the wayland placement for
docks and panels. This commit fixes the issue
and at the same time provide beautifule slide in/outs
for docks panels during their creation and removal.
This commit is contained in:
Michail Vourlakos 2021-04-22 10:11:20 +03:00
parent a25760df5d
commit 00a3d15478
4 changed files with 28 additions and 21 deletions

View File

@ -773,7 +773,7 @@ void GenericLayout::containmentDestroyed(QObject *cont)
if (view) {
view->disconnectSensitiveSignals();
view->positioner()->hideOnExit(containment->location());
view->positioner()->slideOutDuringExit(containment->location());
view->deleteLater();
emit viewEdgeChanged();
@ -919,7 +919,6 @@ void GenericLayout::addView(Plasma::Containment *containment, bool forceOnPrimar
qDebug() << "Rejected explicit latteView and removing it in order add an onPrimary with higher priority at screen: " << connector;
auto viewToDelete = m_latteViews.take(testContainment);
viewToDelete->disconnectSensitiveSignals();
viewToDelete->positioner()->hideOnExit();
viewToDelete->deleteLater();
}
}
@ -1441,7 +1440,6 @@ void GenericLayout::syncLatteViewsToScreens(Layout::ViewsMap *occupiedMap)
auto view = m_latteViews.take(containment);
qDebug() << "syncLatteViewsToScreens: view must be deleted... for containment:" << containment->id() << " at screen:" << view->positioner()->currentScreenName();
view->disconnectSensitiveSignals();
view->positioner()->hideOnExit();
view->deleteLater();
}
@ -1603,7 +1601,6 @@ void GenericLayout::updateView(const Latte::Data::View &viewData)
//! viewMustBeDeleted
m_latteViews.remove(view->containment());
view->disconnectSensitiveSignals();
view->positioner()->hideOnExit();
delete view;
}
}

View File

@ -106,6 +106,7 @@ Positioner::Positioner(Latte::View *parent)
Positioner::~Positioner()
{
m_inDelete = true;
slideOutDuringExit();
m_corona->wm()->unregisterIgnoredWindow(m_trackedWindowId);
m_screenSyncTimer.stop();
@ -294,9 +295,9 @@ QString Positioner::currentScreenName() const
return m_screenNameToFollow;
}
void Positioner::hideOnExit(Plasma::Types::Location location)
WindowSystem::AbstractWindowInterface::Slide Positioner::slideLocation(Plasma::Types::Location location)
{
auto slideLocation = WindowSystem::AbstractWindowInterface::Slide::None;
auto slideedge = WindowSystem::AbstractWindowInterface::Slide::None;
if (location == Plasma::Types::Floating && m_view->containment()) {
location = m_view->containment()->location();
@ -304,19 +305,19 @@ void Positioner::hideOnExit(Plasma::Types::Location location)
switch (location) {
case Plasma::Types::TopEdge:
slideLocation = WindowSystem::AbstractWindowInterface::Slide::Top;
slideedge = WindowSystem::AbstractWindowInterface::Slide::Top;
break;
case Plasma::Types::RightEdge:
slideLocation = WindowSystem::AbstractWindowInterface::Slide::Right;
slideedge = WindowSystem::AbstractWindowInterface::Slide::Right;
break;
case Plasma::Types::BottomEdge:
slideLocation = WindowSystem::AbstractWindowInterface::Slide::Bottom;
slideedge = WindowSystem::AbstractWindowInterface::Slide::Bottom;
break;
case Plasma::Types::LeftEdge:
slideLocation = WindowSystem::AbstractWindowInterface::Slide::Left;
slideedge = WindowSystem::AbstractWindowInterface::Slide::Left;
break;
default:
@ -324,14 +325,20 @@ void Positioner::hideOnExit(Plasma::Types::Location location)
break;
}
m_corona->wm()->slideWindow(*m_view, slideLocation);
m_view->setVisible(false);
return slideedge;
}
void Positioner::showInStartup()
void Positioner::slideOutDuringExit(Plasma::Types::Location location)
{
hideOnExit();
m_view->setVisible(true);
if (m_view->isVisible()) {
m_corona->wm()->slideWindow(*m_view, slideLocation(location));
m_view->setVisible(false);
}
}
void Positioner::slideInDuringStartup()
{
m_corona->wm()->slideWindow(*m_view, slideLocation(m_view->containment()->location()));
}
void Positioner::onCurrentLayoutIsSwitching(const QString &layoutName)
@ -341,8 +348,7 @@ void Positioner::onCurrentLayoutIsSwitching(const QString &layoutName)
}
m_inLayoutUnloading = true;
hideOnExit();
slideOutDuringExit();
}
void Positioner::syncLatteViews()

View File

@ -22,6 +22,7 @@
//local
#include <coretypes.h>
#include "../wm/abstractwindowinterface.h"
#include "../wm/windowinfowrap.h"
// Qt
@ -108,8 +109,8 @@ public slots:
//! that might prevent them. It must be called with care.
void immediateSyncGeometry();
void showInStartup();
void hideOnExit(Plasma::Types::Location location = Plasma::Types::Floating);
void slideInDuringStartup();
void slideOutDuringExit(Plasma::Types::Location location = Plasma::Types::Floating);
void initDelayedSignals();
void updateWaylandId();
@ -163,6 +164,8 @@ private:
QRect maximumNormalGeometry();
WindowSystem::AbstractWindowInterface::Slide slideLocation(Plasma::Types::Location location);
private:
bool m_inDelete{false};
bool m_inLayoutUnloading{false};

View File

@ -86,7 +86,8 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
m_parabolic(new ViewPart::Parabolic(this)),
m_sink(new ViewPart::EventsSink(this))
{
setVisible(false);
//this is disabled because under wayland breaks Views positioning
//setVisible(false);
//! needs to be created after Effects because it catches some of its signals
//! and avoid a crash from View::winId() at the same time
@ -183,7 +184,7 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
m_positioner->immediateSyncGeometry();
if (m_inStartup) {
m_inStartup = false;
m_positioner->showInStartup();
m_positioner->slideInDuringStartup();
}
}