update/improve hack part of screenghostwindow

--related to KWin faulty behavior for visibility
pull/5/head
Michail Vourlakos 6 years ago
parent ebeabb1033
commit f63a0ad658

@ -82,31 +82,41 @@ ScreenEdgeGhostWindow::ScreenEdgeGhostWindow(Latte::View *view) :
if (!KWindowSystem::isPlatformWayland()) { if (!KWindowSystem::isPlatformWayland()) {
connect(this, &QWindow::visibleChanged, this, [&]() { //! IMPORTANT!!! ::: This fixes a bug when closing an Activity all views from all Activities are
//! IMPORTANT!!! ::: This fixes a bug when closing an Activity all views from all Activities are //! disappearing! With this code parts they reappear!!!
//! disappearing! With this they reappear!!! m_visibleHackTimer1.setInterval(400);
if (m_latteView && m_latteView->layout()) { m_visibleHackTimer2.setInterval(2500);
if (!isVisible()) { m_visibleHackTimer1.setSingleShot(true);
QTimer::singleShot(100, [this]() { m_visibleHackTimer2.setSingleShot(true);
if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) {
setVisible(true); connectionsHack << connect(this, &QWindow::visibleChanged, this, [&]() {
} if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) {
}); m_visibleHackTimer1.start();
m_visibleHackTimer2.start();
QTimer::singleShot(1500, [this]() { } else if (!m_inDelete) {
if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) { //! For some reason when the window is hidden in the edge under X11 afterwards
setVisible(true); //! is losing its window flags
} KWindowSystem::setType(winId(), NET::Dock);
}); KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
} else { KWindowSystem::setOnAllDesktops(winId(), true);
//! For some reason when the window is hidden in the edge under X11 afterwards }
//! is losing its window flags });
if (!m_inDelete) {
KWindowSystem::setType(winId(), NET::Dock); connectionsHack << connect(&m_visibleHackTimer1, &QTimer::timeout, this, [&]() {
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager); if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) {
KWindowSystem::setOnAllDesktops(winId(), true); setVisible(true);
} //qDebug() << "Ghost Edge:: Enforce reshow from timer 1...";
} } else {
//qDebug() << "Ghost Edge:: No needed reshow from timer 1...";
}
});
connectionsHack << connect(&m_visibleHackTimer2, &QTimer::timeout, this, [&]() {
if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) {
setVisible(true);
//qDebug() << "Ghost Edge:: Enforce reshow from timer 2...";
} else {
//qDebug() << "Ghost Edge:: No needed reshow from timer 2...";
} }
}); });
} }
@ -124,6 +134,13 @@ ScreenEdgeGhostWindow::~ScreenEdgeGhostWindow()
m_inDelete = true; m_inDelete = true;
m_latteView = nullptr; m_latteView = nullptr;
// clear mode
m_visibleHackTimer1.stop();
m_visibleHackTimer2.stop();
for (auto &c : connectionsHack) {
disconnect(c);
}
if (m_shellSurface) { if (m_shellSurface) {
delete m_shellSurface; delete m_shellSurface;
} }
@ -147,7 +164,12 @@ KWayland::Client::PlasmaShellSurface *ScreenEdgeGhostWindow::surface()
void ScreenEdgeGhostWindow::updateGeometry() void ScreenEdgeGhostWindow::updateGeometry()
{ {
QRect newGeometry; QRect newGeometry;
int thickness{KWindowSystem::compositingActive() ? 4 : 2}; int thickness;
if (KWindowSystem::compositingActive()) {
thickness == 4;
} else {
thickness == 2;
};
if (m_latteView->location() == Plasma::Types::BottomEdge) { if (m_latteView->location() == Plasma::Types::BottomEdge) {
newGeometry.setX(m_latteView->absoluteGeometry().left()); newGeometry.setX(m_latteView->absoluteGeometry().left());
@ -179,8 +201,8 @@ void ScreenEdgeGhostWindow::updateGeometry()
void ScreenEdgeGhostWindow::fixGeometry() void ScreenEdgeGhostWindow::fixGeometry()
{ {
if (!m_calculatedGeometry.isEmpty() if (!m_calculatedGeometry.isEmpty()
&& (m_calculatedGeometry.x() != x() || m_calculatedGeometry.y() != y() && (m_calculatedGeometry.x() != x() || m_calculatedGeometry.y() != y()
|| m_calculatedGeometry.width() != width() || m_calculatedGeometry.height() != height())) { || m_calculatedGeometry.width() != width() || m_calculatedGeometry.height() != height())) {
setMinimumSize(m_calculatedGeometry.size()); setMinimumSize(m_calculatedGeometry.size());
setMaximumSize(m_calculatedGeometry.size()); setMaximumSize(m_calculatedGeometry.size());
resize(m_calculatedGeometry.size()); resize(m_calculatedGeometry.size());

@ -98,6 +98,14 @@ private:
QTimer m_delayedMouseTimer; QTimer m_delayedMouseTimer;
QTimer m_fixGeometryTimer; QTimer m_fixGeometryTimer;
//! HACK: Timers in order to handle KWin faulty
//! behavior that hides Views when closing Activities
//! with no actual reason
QTimer m_visibleHackTimer1;
QTimer m_visibleHackTimer2;
//! Connections for the KWin visibility hack
QList<QMetaObject::Connection> connectionsHack;
Latte::View *m_latteView{nullptr}; Latte::View *m_latteView{nullptr};
KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr}; KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};

@ -244,6 +244,7 @@ void VisibilityManager::updateStrutsBasedOnLayoutsAndActivities()
&& m_latteView->layout()->isCurrent()); && m_latteView->layout()->isCurrent());
if (m_corona->layoutsManager()->memoryUsage() == Types::SingleLayout || multipleLayoutsAndCurrent) { if (m_corona->layoutsManager()->memoryUsage() == Types::SingleLayout || multipleLayoutsAndCurrent) {
qDebug() << "UPDATING struts for ::: " << m_latteView->layout()->name();
QRect computedStruts = acceptableStruts(); QRect computedStruts = acceptableStruts();
if (m_publishedStruts != computedStruts) { if (m_publishedStruts != computedStruts) {
@ -251,6 +252,11 @@ void VisibilityManager::updateStrutsBasedOnLayoutsAndActivities()
m_wm->setViewStruts(*m_latteView, m_publishedStruts, m_latteView->location()); m_wm->setViewStruts(*m_latteView, m_publishedStruts, m_latteView->location());
} }
} else { } else {
if (m_latteView->layout()) {
qDebug() << "REMOVING struts for ::: " << m_latteView->layout()->name();
} else {
qDebug() << "REMOVING struts from NULL layout...";
}
m_publishedStruts = QRect(); m_publishedStruts = QRect();
m_wm->removeViewStruts(*m_latteView); m_wm->removeViewStruts(*m_latteView);
} }

Loading…
Cancel
Save