Fix corner screen glows that suddenly pop up
Summary: Depending on how pointer approaches a screen corner, the maximum distance between two may be smaller than 2 * edgeDistance. This can happen for example when approaching the corner along of any two adjacent screen edges. As a result, the calculated factor can be anywhere between 0 and 0.5 when pointer enters approachGeometry(). This change adjusts calculation of the factor, so it always ranges from 0 to 1 no matter how the pointer approaches corners. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D20707
This commit is contained in:
parent
bf6f05bf3c
commit
e4456347c4
1 changed files with 7 additions and 6 deletions
|
@ -616,20 +616,21 @@ void Edge::updateApproaching(const QPoint &point)
|
||||||
if (approachGeometry().contains(point)) {
|
if (approachGeometry().contains(point)) {
|
||||||
int factor = 0;
|
int factor = 0;
|
||||||
const int edgeDistance = m_edges->cornerOffset();
|
const int edgeDistance = m_edges->cornerOffset();
|
||||||
// manhattan length for our edge
|
auto cornerDistance = [=](const QPoint &corner) {
|
||||||
const int cornerDistance = 2*edgeDistance;
|
return qMax(qAbs(corner.x() - point.x()), qAbs(corner.y() - point.y()));
|
||||||
|
};
|
||||||
switch (border()) {
|
switch (border()) {
|
||||||
case ElectricTopLeft:
|
case ElectricTopLeft:
|
||||||
factor = (point.manhattanLength()<<8) / cornerDistance;
|
factor = (cornerDistance(approachGeometry().topLeft())<<8) / edgeDistance;
|
||||||
break;
|
break;
|
||||||
case ElectricTopRight:
|
case ElectricTopRight:
|
||||||
factor = ((point - approachGeometry().topRight()).manhattanLength()<<8) / cornerDistance;
|
factor = (cornerDistance(approachGeometry().topRight())<<8) / edgeDistance;
|
||||||
break;
|
break;
|
||||||
case ElectricBottomRight:
|
case ElectricBottomRight:
|
||||||
factor = ((point - approachGeometry().bottomRight()).manhattanLength()<<8) / cornerDistance;
|
factor = (cornerDistance(approachGeometry().bottomRight())<<8) / edgeDistance;
|
||||||
break;
|
break;
|
||||||
case ElectricBottomLeft:
|
case ElectricBottomLeft:
|
||||||
factor = ((point - approachGeometry().bottomLeft()).manhattanLength()<<8) / cornerDistance;
|
factor = (cornerDistance(approachGeometry().bottomLeft())<<8) / edgeDistance;
|
||||||
break;
|
break;
|
||||||
case ElectricTop:
|
case ElectricTop:
|
||||||
factor = (qAbs(point.y() - approachGeometry().y())<<8) / edgeDistance;
|
factor = (qAbs(point.y() - approachGeometry().y())<<8) / edgeDistance;
|
||||||
|
|
Loading…
Reference in a new issue