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

REFACTOR:input events and mask area

-- The new approach reduces mask area calls to
barely minimum. Input mask is used instead to
specify the area for which we accept input.
-- The new approach solves also the BLACKLINE issue
when hovering the view at startup. This is because
at all times the full window area is drawn.
This commit is contained in:
Michail Vourlakos 2020-12-27 11:04:04 +02:00
parent bc9e39a6b2
commit ba94315ecb
6 changed files with 57 additions and 244 deletions

View File

@ -305,7 +305,6 @@ void Effects::setInputMask(QRect area)
}
m_inputMask = area;
m_corona->wm()->setInputMask(m_view, area);
emit inputMaskChanged();
@ -427,14 +426,21 @@ void Effects::updateBackgroundCorners()
void Effects::updateMask()
{
if (KWindowSystem::compositingActive()) {
if (m_view->behaveAsPlasmaPanel()) {
if (!m_view->visibility()->isHidden()) {
m_view->setMask(QRect());
} else {
m_view->setMask(VisibilityManager::ISHIDDENMASK);
if (KWindowSystem::isPlatformX11()) {
if (m_view->mask() != VisibilityManager::ISHIDDENMASK ) {
m_view->setMask(QRect(0, 0, m_view->width(), m_view->height()));
}
} else {
m_view->setMask(maskCombinedRegion());
//! this needs investigation under Wayland how to work correctly
if (m_view->behaveAsPlasmaPanel()) {
if (!m_view->visibility()->isHidden()) {
m_view->setMask(QRect());
} else {
m_view->setMask(VisibilityManager::ISHIDDENMASK);
}
} else {
m_view->setMask(maskCombinedRegion());
}
}
} else {
QRegion fixedMask;

View File

@ -647,7 +647,7 @@ void VisibilityManager::hide()
return;
}
m_lastMask = m_latteView->effects()->mask();
// m_lastMask = m_latteView->effects()->mask();
m_latteView->effects()->setMask(ISHIDDENMASK);
}
@ -657,8 +657,8 @@ void VisibilityManager::show()
return;
}
if (m_latteView->effects()->mask() == ISHIDDENMASK) {
m_latteView->effects()->setMask(m_lastMask);
if (m_latteView->mask() == ISHIDDENMASK) {
m_latteView->effects()->setMask(QRect(0, 0, m_latteView->width(), m_latteView->height()));
}
}

View File

@ -60,7 +60,10 @@ Item{
property bool inScreenEdgeInternalWindowSliding: root.behaveAsDockWithMask && hideThickScreenGap
readonly property bool inSliding: inSlidingIn || inSlidingOut || inRelocationHiding || inScreenEdgeInternalWindowSliding || inLocationAnimation
readonly property bool isSinkedEventEnabled: !(parabolic.isEnabled && (animations.needBothAxis.count>0 || animations.needLength.count>0)) && !inSlidingIn
readonly property bool isSinkedEventEnabled: !(parabolic.isEnabled && (animations.needBothAxis.count>0 || animations.needLength.count>0))
&& !inSlidingIn
&& !inSlidingOut
&& !latteView.visibility.isHidden
property int length: root.isVertical ? Screen.height : Screen.width //screenGeometry.height : screenGeometry.width
@ -561,223 +564,14 @@ Item{
}
}
var tempLength = root.isHorizontal ? width : height;
var tempThickness = root.isHorizontal ? height : width;
if (LatteCore.WindowSystem.compositingActive) {
if (normalState) {
//console.log("entered normal state...");
//count panel length
tempLength = background.totals.visualLength;
tempThickness = metrics.mask.thickness.normal;
if (animations.needThickness.count > 0) {
tempThickness = LatteCore.WindowSystem.compositingActive ? metrics.mask.thickness.zoomed : metrics.mask.thickness.normal;
}
if (maskIsFloating) {
tempThickness = tempThickness - maskFloatedGap;
}
if (latteView.visibility.isHidden && !slidingAnimationAutoHiddenOut.running ) {
tempThickness = metrics.mask.thickness.hidden;
}
//configure x,y based on plasmoid position and root.panelAlignment(Alignment)
if ((plasmoid.location === PlasmaCore.Types.BottomEdge) || (plasmoid.location === PlasmaCore.Types.TopEdge)) {
if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
if (latteView.visibility.isHidden && latteView.visibility.supportsKWinEdges) {
localY = latteView.height + tempThickness;
} else if (maskIsFloating && !latteView.visibility.isHidden) {
localY = latteView.height - tempThickness - maskFloatedGap;
} else {
localY = latteView.height - tempThickness;
}
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
if (latteView.visibility.isHidden && latteView.visibility.supportsKWinEdges) {
localY = -tempThickness;
} else if (maskIsFloating && !latteView.visibility.isHidden) {
localY = maskFloatedGap;
} else {
localY = 0;
}
}
if (plasmoid.configuration.alignment === LatteCore.Types.Justify) {
localX = (latteView.width/2) - tempLength/2 + background.offset;
} else if (root.panelAlignment === LatteCore.Types.Left) {
localX = background.offset;
} else if (root.panelAlignment === LatteCore.Types.Center) {
localX = (latteView.width/2) - tempLength/2 + background.offset;
} else if (root.panelAlignment === LatteCore.Types.Right) {
localX = latteView.width - tempLength - background.offset;
}
} else if ((plasmoid.location === PlasmaCore.Types.LeftEdge) || (plasmoid.location === PlasmaCore.Types.RightEdge)){
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
if (latteView.visibility.isHidden && latteView.visibility.supportsKWinEdges) {
localX = -tempThickness;
} else if (maskIsFloating && !latteView.visibility.isHidden) {
localX = maskFloatedGap;
} else {
localX = 0;
}
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
if (latteView.visibility.isHidden && latteView.visibility.supportsKWinEdges) {
localX = latteView.width + tempThickness;
} else if (maskIsFloating && !latteView.visibility.isHidden) {
localX = latteView.width - tempThickness - maskFloatedGap;
} else {
localX = latteView.width - tempThickness;
}
}
if (plasmoid.configuration.alignment === LatteCore.Types.Justify) {
localY = (latteView.height/2) - tempLength/2 + background.offset;
} else if (root.panelAlignment === LatteCore.Types.Top) {
localY = background.offset;
} else if (root.panelAlignment === LatteCore.Types.Center) {
localY = (latteView.height/2) - tempLength/2 + background.offset;
} else if (root.panelAlignment === LatteCore.Types.Bottom) {
localY = latteView.height - tempLength - background.offset;
}
}
if (latteView.visibility.isHidden && latteView && latteView.visibility.mode === LatteCore.Types.SidebarOnDemand) {
//!hide completely
localX = -1;
localY = -1;
tempThickness = 1;
tempLength = 1;
}
} else {
// !inNormalState
if(root.isHorizontal)
tempLength = Screen.width; //screenGeometry.width;
else
tempLength = Screen.height; //screenGeometry.height;
//grow only on length and not thickness
var onlyLengthAnimation = (animations.needLength.count>0 && animations.needBothAxis.count === 0);
if(onlyLengthAnimation) {
//this is used to fix a bug with shadow showing when the animation of edit mode
//is triggered
tempThickness = metrics.mask.thickness.normal;
if (latteView.visibility.isHidden && !slidingAnimationAutoHiddenOut.running ) {
tempThickness = metrics.mask.thickness.hidden;
} else if (animations.needThickness.count > 0) {
tempThickness = metrics.mask.thickness.maxZoomed;
}
} else{
//use all thickness space
if (latteView.visibility.isHidden && !slidingAnimationAutoHiddenOut.running ) {
tempThickness = LatteCore.WindowSystem.compositingActive ? metrics.mask.thickness.hidden : metrics.mask.thickness.maxNormalForItems;
} else {
tempThickness = !maskIsFloating ? metrics.mask.thickness.maxZoomed : metrics.mask.thickness.maxZoomed - maskFloatedGap;
}
}
//configure the x,y position based on thickness
if(plasmoid.location === PlasmaCore.Types.RightEdge) {
localX = !maskIsFloating ? latteView.width - tempThickness : latteView.width - tempThickness - maskFloatedGap;
if (localX < 0) {
tempThickness = tempThickness + localX;
localX = 0;
}
} else if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
localY = !maskIsFloating ? latteView.height - tempThickness : latteView.height - tempThickness - maskFloatedGap;
if (localY < 0) {
tempThickness = tempThickness + localY;
localY = 0;
}
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
localY = !maskIsFloating ? 0 : maskFloatedGap;
} else if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
localX = !maskIsFloating ? 0 : maskFloatedGap;
}
}
} // end of compositing calculations
var maskArea = latteView.effects.mask;
if (LatteCore.WindowSystem.compositingActive) {
var maskLength = maskArea.width; //in Horizontal
if (root.isVertical) {
maskLength = maskArea.height;
}
var maskThickness = maskArea.height; //in Horizontal
if (root.isVertical) {
maskThickness = maskArea.width;
if (!LatteCore.WindowSystem.compositingActive) {
if (!latteView.visibility.isHidden) {
latteView.effects.mask = latteView.effects.rect;
}
} else {
//! no compositing case
var overridesHidden = latteView.visibility.isHidden && !latteView.visibility.supportsKWinEdges;
if (!overridesHidden) {
localX = latteView.effects.rect.x;
localY = latteView.effects.rect.y;
} else {
if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
localX = latteView.effects.rect.x;
localY = root.height - metrics.mask.thickness.hidden;
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
localX = latteView.effects.rect.x;
localY = 0;
} else if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
localX = 0;
localY = latteView.effects.rect.y;
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
localX = root.width - metrics.mask.thickness.hidden;
localY = latteView.effects.rect.y;
}
}
if (root.isHorizontal) {
tempThickness = overridesHidden ? metrics.mask.thickness.hidden : latteView.effects.rect.height;
tempLength = latteView.effects.rect.width;
} else {
tempThickness = overridesHidden ? metrics.mask.thickness.hidden : latteView.effects.rect.width;
tempLength = latteView.effects.rect.height;
}
latteView.effects.mask = Qt.rect(0, 0, root.width, root.height);
}
// console.log("Not updating mask...");
if( maskArea.x !== localX || maskArea.y !== localY
|| maskLength !== tempLength || maskThickness !== tempThickness) {
// console.log("Updating mask...");
var newMaskArea = Qt.rect(-1,-1,0,0);
newMaskArea.x = localX;
newMaskArea.y = localY;
if (isHorizontal) {
newMaskArea.width = tempLength;
newMaskArea.height = tempThickness;
} else {
newMaskArea.width = tempThickness;
newMaskArea.height = tempLength;
}
if (!LatteCore.WindowSystem.compositingActive) {
latteView.effects.mask = newMaskArea;
} else {
if (latteView.behaveAsPlasmaPanel) {
latteView.effects.mask = Qt.rect(0,0,root.width,root.height);
} else {
latteView.effects.mask = newMaskArea;
}
}
}
var validIconSize = (metrics.iconSize===metrics.maxIconSize || metrics.iconSize === autosize.iconSize);
//console.log("reached updating geometry ::: "+dock.maskArea);
if(inPublishingState && !latteView.visibility.isHidden && normalState) {
@ -831,20 +625,16 @@ Item{
latteView.localGeometry = localGeometry;
}
//! Input Mask
if (LatteCore.WindowSystem.isPlatformX11) {
//! This is not needed under wayland environment, mask() can be used instead
var animated = ( animations.needBothAxis.count>0
|| animations.needLength.count>0
|| animations.needThickness.count>0
|| latteView.visibility.isHidden);
var animated = (animations.needBothAxis.count>0);
if (!LatteCore.WindowSystem.compositingActive || animated || latteView.behaveAsPlasmaPanel) {
latteView.effects.inputMask = Qt.rect(0, 0, -1, -1);
} else {
var inputThickness = metrics.mask.screenEdge + metrics.totals.thickness;
var inputThickness = latteView.visibility.isHidden ? metrics.mask.thickness.hidden : metrics.mask.screenEdge + metrics.totals.thickness;
var inputGeometry = Qt.rect(0, 0, root.width, root.height);
if (plasmoid.location === PlasmaCore.Types.TopEdge) {

View File

@ -320,10 +320,10 @@ BackgroundProperties{
//! the compositor to provide blurriness and from Mask calculations to provide the View Local Geometry
PlasmaCore.FrameSvgItem{
id: solidBackground
anchors.leftMargin: LatteCore.WindowSystem.compositingActive ? shadows.left : 0
anchors.rightMargin: LatteCore.WindowSystem.compositingActive ? shadows.right : 0
anchors.topMargin: LatteCore.WindowSystem.compositingActive ? shadows.top : 0
anchors.bottomMargin: LatteCore.WindowSystem.compositingActive ? shadows.bottom : 0
anchors.leftMargin: shadows.left
anchors.rightMargin: shadows.right
anchors.topMargin: shadows.top
anchors.bottomMargin: shadows.bottom
anchors.fill: shadowsSvgItem
imagePath: "widgets/panel-background"

View File

@ -175,13 +175,13 @@ Window{
}
Text{
text: "Absolute Geometry"+space
text: "Input "+space
}
Text{
text: {
if (latteView && latteView.absoluteGeometry) {
return latteView.absoluteGeometry.x + ", " + latteView.absoluteGeometry.y + " " + latteView.absoluteGeometry.width + "x" + latteView.absoluteGeometry.height;
if (latteView && latteView.effects && latteView.effects.inputMask) {
return latteView.effects.inputMask.x +", "+ latteView.effects.inputMask.y+" "+latteView.effects.inputMask.width+"x"+latteView.effects.inputMask.height;
} else {
return "_,_ _x_";
}
@ -202,6 +202,21 @@ Window{
}
}
Text{
text: "Absolute Geometry"+space
}
Text{
text: {
if (latteView && latteView.absoluteGeometry) {
return latteView.absoluteGeometry.x + ", " + latteView.absoluteGeometry.y + " " + latteView.absoluteGeometry.width + "x" + latteView.absoluteGeometry.height;
} else {
return "_,_ _x_";
}
}
}
Text{
text: "Draw Effects"+space
}

View File

@ -1557,8 +1557,9 @@ Item {
sourceComponent: Rectangle{
x: latteView.localGeometry.x
y: latteView.localGeometry.y
width: latteView.localGeometry.width
height: latteView.localGeometry.height
//! when view is resized there is a chance that geometry is faulty stacked in old values
width: Math.min(latteView.localGeometry.width, root.width) //! fixes updating
height: Math.min(latteView.localGeometry.height, root.height) //! fixes updating
color: "blue"
border.width: 2
@ -1574,14 +1575,15 @@ Item {
sourceComponent: Rectangle{
x: latteView.effects.inputMask.x
y: latteView.effects.inputMask.y
width: latteView.effects.inputMask.width
height: latteView.effects.inputMask.height
//! when view is resized there is a chance that geometry is faulty stacked in old values
width: Math.min(latteView.effects.inputMask.width, root.width) //! fixes updating
height: Math.min(latteView.effects.inputMask.height, root.height) //! fixes updating
color: "purple"
border.width: 2
border.color: "purple"
border.width: 1
border.color: "black"
opacity: 0.35
opacity: 0.20
}
}
}