From bc5ba5014778a72fd18e3873677b90b1525e48c9 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 27 Dec 2020 13:47:01 +0200 Subject: [PATCH] refactor:plenty of fixes for masks/input events --use only input events in order to identify the area from which a window accepts input and also remove almost every mask-qml code handling --by reducing mask usage to minimum we fix also the BLACKLINE bug under X11 --- app/view/effects.cpp | 39 ++++++++++++++----- app/view/visibilitymanager.cpp | 25 ++++++------ .../package/contents/ui/VisibilityManager.qml | 11 +----- containment/package/contents/ui/main.qml | 11 +----- 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/app/view/effects.cpp b/app/view/effects.cpp index 52414adb9..3db5bec7e 100644 --- a/app/view/effects.cpp +++ b/app/view/effects.cpp @@ -60,10 +60,21 @@ void Effects::init() connect(this, &Effects::enabledBordersChanged, this, &Effects::updateEffects); connect(this, &Effects::rectChanged, this, &Effects::updateEffects); + connect(this, &Effects::backgroundCornersMaskChanged, this, &Effects::updateMask); connect(this, &Effects::backgroundRadiusEnabledChanged, this, &Effects::updateMask); connect(this, &Effects::subtractedMaskRegionsChanged, this, &Effects::updateMask); connect(this, &Effects::unitedMaskRegionsChanged, this, &Effects::updateMask); + connect(m_view, &Latte::View::typeChanged, this, &Effects::updateMask); + connect(m_view, &QQuickWindow::widthChanged, this, &Effects::updateMask); + connect(m_view, &QQuickWindow::heightChanged, this, &Effects::updateMask); + connect(KWindowSystem::self(), &KWindowSystem::compositingChanged, this, &Effects::updateMask); + + connect(this, &Effects::rectChanged, this, [&]() { + if (!KWindowSystem::compositingActive() && !m_view->behaveAsPlasmaPanel()) { + setMask(m_rect); + } + }); connect(this, &Effects::backgroundRadiusChanged, this, &Effects::updateBackgroundCorners); @@ -305,7 +316,13 @@ void Effects::setInputMask(QRect area) } m_inputMask = area; - m_corona->wm()->setInputMask(m_view, area); + + if (KWindowSystem::isPlatformX11()) { + m_corona->wm()->setInputMask(m_view, area); + } else { + //under wayland mask() is providing the Input Area + m_view->setMask(area); + } emit inputMaskChanged(); } @@ -427,10 +444,12 @@ void Effects::updateMask() { if (KWindowSystem::compositingActive()) { if (KWindowSystem::isPlatformX11()) { - if (m_view->mask() != VisibilityManager::ISHIDDENMASK ) { - m_view->setMask(QRect(0, 0, m_view->width(), m_view->height())); - } + m_view->setMask(QRect(0, 0, m_view->width(), m_view->height())); } else { + // do nothing + } + + /* else { //! this needs investigation under Wayland how to work correctly if (m_view->behaveAsPlasmaPanel()) { if (!m_view->visibility()->isHidden()) { @@ -441,13 +460,15 @@ void Effects::updateMask() } else { m_view->setMask(maskCombinedRegion()); } - } + }*/ } else { QRegion fixedMask; + QRect maskRect = m_view->behaveAsPlasmaPanel() ? QRect(0,0, m_view->width(), m_view->height()) : m_mask; + if (m_backgroundRadiusEnabled) { //! CustomBackground way - fixedMask = customMask(QRect(0,0,m_mask.width(), m_mask.height())); + fixedMask = customMask(QRect(0,0,maskRect.width(), maskRect.height())); } else { //! Plasma::Theme way //! this is used when compositing is disabled and provides @@ -468,15 +489,15 @@ void Effects::updateMask() } m_background->setEnabledBorders(m_enabledBorders); - m_background->resizeFrame(m_mask.size()); + m_background->resizeFrame(maskRect.size()); fixedMask = m_background->mask(); } - fixedMask.translate(m_mask.x(), m_mask.y()); + fixedMask.translate(maskRect.x(), maskRect.y()); //! fix for KF5.32 that return empty QRegion's for the mask if (fixedMask.isEmpty()) { - fixedMask = QRegion(m_mask); + fixedMask = QRegion(maskRect); } m_view->setMask(fixedMask); diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index d827ca491..d801194b2 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -643,22 +643,15 @@ void VisibilityManager::updateGhostWindowState() void VisibilityManager::hide() { - if (!m_latteView->effects()) { - return; + if (KWindowSystem::isPlatformX11()) { + m_latteView->setVisible(false); } - - // m_lastMask = m_latteView->effects()->mask(); - m_latteView->effects()->setMask(ISHIDDENMASK); } void VisibilityManager::show() { - if (!m_latteView->effects()) { - return; - } - - if (m_latteView->mask() == ISHIDDENMASK) { - m_latteView->effects()->setMask(QRect(0, 0, m_latteView->width(), m_latteView->height())); + if (KWindowSystem::isPlatformX11()) { + m_latteView->setVisible(true); } } @@ -784,7 +777,15 @@ void VisibilityManager::applyActivitiesToHiddenWindows(const QStringList &activi void VisibilityManager::startTimerHide(const int &msec) { if (msec == 0) { - m_timerHide.start(m_timerHideInterval); + int secs = m_timerHideInterval; + + if (!KWindowSystem::compositingActive()) { + //! this is needed in order to give view time to show and + //! for floating case to give time to user to reach the view with its mouse + secs = qMax(m_timerHideInterval, m_latteView->screenEdgeMargin() > 0 ? 700 : 200); + } + + m_timerHide.start(secs); } else { m_timerHide.start(msec); } diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 96f3c6e37..3711c2c35 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -564,17 +564,10 @@ Item{ } } - if (!LatteCore.WindowSystem.compositingActive) { - if (!latteView.visibility.isHidden) { - latteView.effects.mask = latteView.effects.rect; - } - } else { - latteView.effects.mask = Qt.rect(0, 0, root.width, root.height); - } - //console.log("reached updating geometry ::: "+dock.maskArea); - if(inPublishingState && !latteView.visibility.isHidden && normalState) { + + if (inPublishingState && !latteView.visibility.isHidden && normalState) { //! Important: Local Geometry must not be updated when view ISHIDDEN //! because it breaks Dodge(s) modes in such case diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index e965bd4d2..6d653b525 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -71,16 +71,7 @@ Item { && (latteView.extendedInterface.plasmaTasksModel.count === 0) property bool backgroundOnlyOnMaximized: plasmoid.configuration.backgroundOnlyOnMaximized - property bool behaveAsPlasmaPanel: { - if (!LatteCore.WindowSystem.compositingActive) { - //! In NOCOMPOSITING mode VIEWS are ALWAYS using mask techniques because - //! this is what works much better. In the future that might change. - return false; - } - - return viewType === LatteCore.Types.PanelView; - } - + readonly property bool behaveAsPlasmaPanel: viewType === LatteCore.Types.PanelView readonly property bool behaveAsDockWithMask: !behaveAsPlasmaPanel readonly property bool viewIsAvailable: latteView && latteView.visibility && latteView.effects