1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 01:33:50 +03:00

fix View recraetion and frameExtents freezes

--View recreation path was broken from new implementation
for Latte::Interfaces that pass objects to containment
interface. This is now fixed and Interfaces::View object is updated
and broadcasted correctly when changed
--when GtkFrameExtents are zeroed for behaveAsPlasmaPanels
then it is better to recreate the view to avoid freezes and
hidings of the view because of compositor strange behavior
This commit is contained in:
Michail Vourlakos 2020-05-12 14:45:31 +03:00
parent 677caab132
commit ec949948b6
9 changed files with 119 additions and 23 deletions

View File

@ -117,6 +117,13 @@ void Interfaces::setUniversalSettings(QObject *settings)
emit universalSettingsChanged();
}
void Interfaces::updateView()
{
if (m_plasmoid) {
setView(m_plasmoid->property("_latte_view_object").value<QObject *>());
}
}
QObject *Interfaces::view() const
{
return m_view;

View File

@ -53,6 +53,9 @@ public:
QObject *plasmoidInterface() const;
void setPlasmoidInterface(QObject *interface);
public slots:
Q_INVOKABLE void updateView();
signals:
void interfaceChanged();
void globalShortcutsChanged();

View File

@ -63,10 +63,12 @@ void Effects::init()
});
connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::View::screenEdgeMarginEnabledChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects);
connect(this, &Effects::drawShadowsChanged, this, &Effects::updateShadows);
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateShadows);
connect(m_view, &Latte::View::configWindowGeometryChanged, this, &Effects::updateMask);
connect(m_view, &Latte::View::screenEdgeMarginEnabledChanged, this, &Effects::updateEnabledBorders);
connect(&m_theme, &Plasma::Theme::themeChanged, this, [&]() {
auto background = m_background;
@ -113,12 +115,6 @@ void Effects::setDrawShadows(bool draw)
m_drawShadows = draw;
if (m_view->behaveAsPlasmaPanel() && m_drawShadows) {
PanelShadows::self()->addWindow(m_view, m_enabledBorders);
} else {
PanelShadows::self()->removeWindow(m_view);
}
emit drawShadowsChanged();
}

View File

@ -29,6 +29,7 @@
#include "settings/secondaryconfigview.h"
#include "../apptypes.h"
#include "../lattecorona.h"
#include "../declarativeimports/interfaces.h"
#include "../indicator/factory.h"
#include "../layout/genericlayout.h"
#include "../layouts/manager.h"
@ -144,6 +145,15 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
connect(m_visibility, &ViewPart::VisibilityManager::containsMouseChanged,
this, &View::updateTransientWindowsTracking);
connect(m_visibility, &ViewPart::VisibilityManager::frameExtentsCleared, this, [&]() {
if (behaveAsPlasmaPanel()) {
//! recreate view because otherwise compositor frame extents implementation
//! is triggering a crazy behavior of moving/hiding the view and freezing Latte
//! in some cases.
reloadSource();
}
});
emit visibilityChanged();
}
@ -294,6 +304,13 @@ void View::init(Plasma::Containment *plasma_containment)
containmentGraphicItem->setProperty("_latte_themeExtended_object", QVariant::fromValue(m_corona->themeExtended()));
containmentGraphicItem->setProperty("_latte_universalSettings_object", QVariant::fromValue(m_corona->universalSettings()));
containmentGraphicItem->setProperty("_latte_view_object", QVariant::fromValue(this));
Latte::Interfaces *ifacesGraphicObject = qobject_cast<Latte::Interfaces *>(containmentGraphicItem->property("_latte_view_interfacesobject").value<QObject *>());
if (ifacesGraphicObject) {
ifacesGraphicObject->updateView();
setInterfacesGraphicObj(ifacesGraphicObject);
}
}
setSource(corona()->kPackage().filePath("lattedockui"));
@ -1326,6 +1343,33 @@ ViewPart::WindowsTracker *View::windowsTracker() const
return m_windowsTracker;
}
Latte::Interfaces *View::interfacesGraphicObj() const
{
return m_interfacesGraphicObj;
}
void View::setInterfacesGraphicObj(Latte::Interfaces *ifaces)
{
if (m_interfacesGraphicObj == ifaces) {
return;
}
m_interfacesGraphicObj = ifaces;
qDebug() << " @#$@#$@#$@#$ @#$ @#$ @#$ @#$ SETINTERFACESGRAPHICOBJECT 111";
if (containment()) {
QQuickItem *containmentGraphicItem = qobject_cast<QQuickItem *>(containment()->property("_plasma_graphicObject").value<QObject *>());
qDebug() << " @#$@#$@#$@#$ @#$ @#$ @#$ @#$ SETINTERFACESGRAPHICOBJECT 222";
if (containmentGraphicItem) {
qDebug() << " @#$@#$@#$@#$ @#$ @#$ @#$ @#$ SETINTERFACESGRAPHICOBJECT 333";
containmentGraphicItem->setProperty("_latte_view_interfacesobject", QVariant::fromValue(m_interfacesGraphicObj));
}
}
emit interfacesGraphicObjChanged();
}
bool View::event(QEvent *e)
{
if (!m_inDelete) {

View File

@ -67,6 +67,7 @@ class PlasmaShellSurface;
namespace Latte {
class Corona;
class Interfaces;
class GenericLayout;
namespace ViewPart {
@ -124,6 +125,8 @@ class View : public PlasmaQuick::ContainmentView
Q_PROPERTY(Latte::ViewPart::VisibilityManager *visibility READ visibility NOTIFY visibilityChanged)
Q_PROPERTY(Latte::ViewPart::WindowsTracker *windowsTracker READ windowsTracker NOTIFY windowsTrackerChanged)
Q_PROPERTY(Latte::Interfaces *interfacesGraphicObj READ interfacesGraphicObj WRITE setInterfacesGraphicObj NOTIFY interfacesGraphicObjChanged)
Q_PROPERTY(QRect absoluteGeometry READ absoluteGeometry NOTIFY absoluteGeometryChanged)
Q_PROPERTY(QRect localGeometry READ localGeometry WRITE setLocalGeometry NOTIFY localGeometryChanged)
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
@ -235,6 +238,9 @@ public:
ViewPart::VisibilityManager *visibility() const;
ViewPart::WindowsTracker *windowsTracker() const;
Latte::Interfaces *interfacesGraphicObj() const;
void setInterfacesGraphicObj(Latte::Interfaces *ifaces);
Layout::GenericLayout *layout() const;
void setLayout(Layout::GenericLayout *layout);
@ -298,6 +304,7 @@ signals:
void inEditModeChanged();
void indicatorChanged();
void inSettingsAdvancedModeChanged();
void interfacesGraphicObjChanged();
void isPreferredForShortcutsChanged();
void isTouchingBottomViewAndIsBusyChanged();
void isTouchingTopViewAndIsBusyChanged();
@ -420,6 +427,8 @@ private:
QPointer<ViewPart::VisibilityManager> m_visibility;
QPointer<ViewPart::WindowsTracker> m_windowsTracker;
QPointer<Latte::Interfaces> m_interfacesGraphicObj;
//! Connections to release and bound for the assigned layout
QList<QMetaObject::Connection> connectionsLayout;

View File

@ -80,9 +80,9 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
//! Frame Extents
connect(m_latteView, &Latte::View::headThicknessGapChanged, this, &VisibilityManager::on_publishFrameExtents);
connect(m_latteView, &Latte::View::inEditModeChanged, this, [&]() { publishFrameExtents(); });
connect(m_latteView, &Latte::View::forcedShown, this, [&]() {
//resend information to compositor otherwise it is lost from compositor abnormal behavior
//! Resend frame extents to compositor otherwise because compositor cleared
//! them with no reason when the user is closing an activity
const bool forceUpdate{true};
publishFrameExtents(forceUpdate);
});
@ -98,7 +98,7 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
});
}
m_timerStartUp.setInterval(5000);
m_timerStartUp.setInterval(4000);
m_timerStartUp.setSingleShot(true);
m_timerShow.setSingleShot(true);
m_timerHide.setSingleShot(true);
@ -121,7 +121,7 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
}
});
m_timerPublishFrameExtents.setInterval(2000);
m_timerPublishFrameExtents.setInterval(1500);
m_timerPublishFrameExtents.setSingleShot(true);
connect(&m_timerPublishFrameExtents, &QTimer::timeout, this, [&]() { publishFrameExtents(); });
@ -526,7 +526,15 @@ void VisibilityManager::publishFrameExtents(bool forceUpdate)
}
qDebug() << " -> Frame Extents :: " << m_frameExtentsLocation << " __ " << " extents :: " << frameExtents;
m_wm->setFrameExtents(m_latteView, frameExtents);
if (!frameExtents.isNull()) {
//! When a view returns its frame extents to zero then that triggers a compositor
//! strange behavior that moves/hides the view totally and freezes entire Latte
//! this is why we have blocked that setting
m_wm->setFrameExtents(m_latteView, frameExtents);
} else if (m_latteView->behaveAsPlasmaPanel()) {
emit frameExtentsCleared();
}
}
}
@ -942,12 +950,12 @@ void VisibilityManager::createEdgeGhostWindow()
if (!m_edgeGhostWindow) {
m_edgeGhostWindow = new ScreenEdgeGhostWindow(m_latteView);
connect(m_edgeGhostWindow, &ScreenEdgeGhostWindow::containsMouseChanged, this, [ = ](bool contains) {
connect(m_edgeGhostWindow, &ScreenEdgeGhostWindow::containsMouseChanged, this, [ = ](bool contains) {
if (contains) {
raiseView(true);
} else {
m_timerShow.stop();
updateGhostWindowState();
m_timerShow.stop();
updateGhostWindowState();
}
});

View File

@ -127,6 +127,7 @@ signals:
void slideOutFinished();
void slideInFinished();
void frameExtentsCleared();
void modeChanged();
void raiseOnDesktopChanged();
void raiseOnActivityChanged();

View File

@ -353,17 +353,34 @@ void XWindowInterface::setFrameExtents(QWindow *view, const QMargins &margins)
#if KF5_VERSION_MINOR >= 65
NETWinInfo ni(QX11Info::connection(), view->winId(), QX11Info::appRootWindow(), 0, NET::WM2GTKFrameExtents);
NETStrut struts;
struts.left = margins.left();
struts.top = margins.top();
struts.right = margins.right();
struts.bottom = margins.bottom();
if (margins.isNull()) {
//! delete property
xcb_connection_t *c = QX11Info::connection();
const QByteArray atomName = QByteArrayLiteral("_GTK_FRAME_EXTENTS");
xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, atomName.length(), atomName.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, atomCookie, nullptr));
ni.setGtkFrameExtents(struts);
if (!atom) {
return;
}
NETStrut applied = ni.gtkFrameExtents();
// qDebug() << " deleting gtk frame extents atom..";
xcb_delete_property(c, view->winId(), atom->atom);
} else {
NETStrut struts;
struts.left = margins.left();
struts.top = margins.top();
struts.right = margins.right();
struts.bottom = margins.bottom();
ni.setGtkFrameExtents(struts);
}
/*NETWinInfo ni2(QX11Info::connection(), view->winId(), QX11Info::appRootWindow(), 0, NET::WM2GTKFrameExtents);
NETStrut applied = ni2.gtkFrameExtents();
QMargins amargins(applied.left, applied.top, applied.right, applied.bottom);
qDebug() << " window applied extents :: " << amargins;
qDebug() << " window gtk frame extents applied :: " << amargins;*/
#endif
}

View File

@ -138,6 +138,7 @@ Item {
property bool disablePanelShadowMaximized: plasmoid.configuration.disablePanelShadowForMaximized && LatteCore.WindowSystem.compositingActive
property bool drawShadowsExternal: panelShadowsActive && behaveAsPlasmaPanel && !visibilityManager.inTempHiding
property bool editMode: editModeVisual.inEditMode
property bool windowIsTouching: latteView && latteView.windowsTracker
&& (latteView.windowsTracker.currentScreen.activeWindowTouching || hasExpandedApplet)
@ -1601,6 +1602,16 @@ Item {
LatteApp.Interfaces {
id: _interfaces
plasmoidInterface: plasmoid
Component.onCompleted: {
view.interfacesGraphicObj = _interfaces;
}
onViewChanged: {
if (view) {
view.interfacesGraphicObj = _interfaces;
}
}
}
///////////////END ABILITIES