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

sinked events:various fixes

--disable sinked events when parabolic effect is
enabled. It needs to be rethought how this could work
properly with parabolic effect.
This commit is contained in:
Michail Vourlakos 2020-12-25 01:14:11 +02:00
parent a74a6ee3ff
commit 96fd421e9f
6 changed files with 61 additions and 48 deletions

View File

@ -96,5 +96,10 @@ void Padding::setRight(int rightpad)
emit paddingsChanged(); emit paddingsChanged();
} }
QMargins Padding::margins() const
{
return QMargins(m_left, m_top, m_right, m_bottom);
}
} }
} }

View File

@ -21,6 +21,7 @@
#define PADDING_H #define PADDING_H
// Qt // Qt
#include <QMargins>
#include <QObject> #include <QObject>
@ -54,6 +55,8 @@ public:
int right() const; int right() const;
void setRight(int rightpad); void setRight(int rightpad);
QMargins margins() const;
signals: signals:
void paddingsChanged(); void paddingsChanged();

View File

@ -1337,6 +1337,8 @@ void View::setInterfacesGraphicObj(Latte::Interfaces *ifaces)
bool View::event(QEvent *e) bool View::event(QEvent *e)
{ {
QEvent *adjustedevent = e;
if (!m_inDelete) { if (!m_inDelete) {
emit eventTriggered(e); emit eventTriggered(e);
@ -1355,12 +1357,13 @@ bool View::event(QEvent *e)
if (auto de = static_cast<QDragEnterEvent *>(e)) { if (auto de = static_cast<QDragEnterEvent *>(e)) {
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() && !containmentContainsPosition(de->pos())) { if (m_padding
&& !m_padding->isEmpty()
&& !containmentContainsPosition(de->pos())) {
auto de2 = new QDragEnterEvent(positionAdjustedForContainment(de->pos()).toPoint(), auto de2 = new QDragEnterEvent(positionAdjustedForContainment(de->pos()).toPoint(),
de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers());
QCoreApplication::postEvent(this, de2); adjustedevent = de2;
return true;
} }
} }
break; break;
@ -1372,12 +1375,13 @@ bool View::event(QEvent *e)
case QEvent::DragMove: case QEvent::DragMove:
if (auto de = static_cast<QDragMoveEvent *>(e)) { if (auto de = static_cast<QDragMoveEvent *>(e)) {
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() && !containmentContainsPosition(de->pos())) { if (m_padding
&& !m_padding->isEmpty()
&& !containmentContainsPosition(de->pos())) {
auto de2 = new QDragMoveEvent(positionAdjustedForContainment(de->pos()).toPoint(), auto de2 = new QDragMoveEvent(positionAdjustedForContainment(de->pos()).toPoint(),
de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers());
QCoreApplication::postEvent(this, de2); adjustedevent = de2;
return true;
} }
} }
break; break;
@ -1387,12 +1391,13 @@ bool View::event(QEvent *e)
if (auto de = static_cast<QDropEvent *>(e)) { if (auto de = static_cast<QDropEvent *>(e)) {
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() && !containmentContainsPosition(de->pos())) { if (m_padding
&& !m_padding->isEmpty()
&& !containmentContainsPosition(de->pos())) {
auto de2 = new QDropEvent(positionAdjustedForContainment(de->pos()).toPoint(), auto de2 = new QDropEvent(positionAdjustedForContainment(de->pos()).toPoint(),
de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers());
QCoreApplication::postEvent(this, de2); adjustedevent = de2;
return true;
} }
} }
@ -1402,7 +1407,8 @@ bool View::event(QEvent *e)
if (auto me = dynamic_cast<QMouseEvent *>(e)) { if (auto me = dynamic_cast<QMouseEvent *>(e)) {
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() if (m_padding
&& !m_padding->isEmpty()
&& m_positioner && m_positioner->isCursorInsideView() /*dont break drags when cursor is outside*/ && m_positioner && m_positioner->isCursorInsideView() /*dont break drags when cursor is outside*/
&& !containmentContainsPosition(me->windowPos())) { && !containmentContainsPosition(me->windowPos())) {
auto me2 = new QMouseEvent(me->type(), auto me2 = new QMouseEvent(me->type(),
@ -1411,8 +1417,8 @@ bool View::event(QEvent *e)
positionAdjustedForContainment(me->windowPos()) + position(), positionAdjustedForContainment(me->windowPos()) + position(),
me->button(), me->buttons(), me->modifiers()); me->button(), me->buttons(), me->modifiers());
QCoreApplication::postEvent(this, me2); qDebug() << "adjusted sinked move...";
return true; adjustedevent = me2;
} }
} }
break; break;
@ -1422,17 +1428,18 @@ bool View::event(QEvent *e)
emit mousePressed(me->pos(), me->button()); emit mousePressed(me->pos(), me->button());
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() if (m_padding
&& !m_padding->isEmpty()
&& m_positioner && m_positioner->isCursorInsideView() /*dont break drags when cursor is outside*/ && m_positioner && m_positioner->isCursorInsideView() /*dont break drags when cursor is outside*/
&& !containmentContainsPosition(me->windowPos())) { && !containmentContainsPosition(me->windowPos())) {
qDebug() << "adjusted sinked pressed...";
auto me2 = new QMouseEvent(me->type(), auto me2 = new QMouseEvent(me->type(),
positionAdjustedForContainment(me->windowPos()), positionAdjustedForContainment(me->windowPos()),
positionAdjustedForContainment(me->windowPos()), positionAdjustedForContainment(me->windowPos()),
positionAdjustedForContainment(me->windowPos()) + position(), positionAdjustedForContainment(me->windowPos()) + position(),
me->button(), me->buttons(), me->modifiers()); me->button(), me->buttons(), me->modifiers());
QCoreApplication::postEvent(this, me2); adjustedevent = me2;
return true;
} }
} }
break; break;
@ -1442,7 +1449,8 @@ bool View::event(QEvent *e)
emit mouseReleased(me->pos(), me->button()); emit mouseReleased(me->pos(), me->button());
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() if (m_padding
&& !m_padding->isEmpty()
&& m_positioner && m_positioner->isCursorInsideView() /*dont break drags when cursor is outside*/ && m_positioner && m_positioner->isCursorInsideView() /*dont break drags when cursor is outside*/
&& !containmentContainsPosition(me->windowPos())) { && !containmentContainsPosition(me->windowPos())) {
auto me2 = new QMouseEvent(me->type(), auto me2 = new QMouseEvent(me->type(),
@ -1451,8 +1459,7 @@ bool View::event(QEvent *e)
positionAdjustedForContainment(me->windowPos()) + position(), positionAdjustedForContainment(me->windowPos()) + position(),
me->button(), me->buttons(), me->modifiers()); me->button(), me->buttons(), me->modifiers());
QCoreApplication::postEvent(this, me2); adjustedevent = me2;
return true;
} }
} }
break; break;
@ -1501,14 +1508,15 @@ bool View::event(QEvent *e)
emit wheelScrolled(pos, we->angleDelta(), we->buttons()); emit wheelScrolled(pos, we->angleDelta(), we->buttons());
//! adjust event by taking into account paddings //! adjust event by taking into account paddings
if (m_padding && !m_padding->isEmpty() && !containmentContainsPosition(pos)) { if (m_padding
&& !m_padding->isEmpty()
&& !containmentContainsPosition(pos)) {
auto we2 = new QWheelEvent(positionAdjustedForContainment(pos), auto we2 = new QWheelEvent(positionAdjustedForContainment(pos),
positionAdjustedForContainment(pos) + position(), positionAdjustedForContainment(pos) + position(),
we->pixelDelta(), we->angleDelta(), we->angleDelta().y(), we->pixelDelta(), we->angleDelta(), we->angleDelta().y(),
we->orientation(), we->buttons(), we->modifiers(), we->phase()); we->orientation(), we->buttons(), we->modifiers(), we->phase());
QCoreApplication::postEvent(this, we2); adjustedevent = we2;
return true;
} }
} }
break; break;
@ -1517,7 +1525,7 @@ bool View::event(QEvent *e)
} }
} }
return ContainmentView::event(e); return ContainmentView::event(adjustedevent);
} }
bool View::containmentContainsPosition(const QPointF &point) const bool View::containmentContainsPosition(const QPointF &point) const
@ -1526,16 +1534,8 @@ bool View::containmentContainsPosition(const QPointF &point) const
return false; return false;
} }
QQuickItem *containmentItem = containment()->property("_plasma_graphicObject").value<QQuickItem *>(); QRectF local= m_localGeometry - m_padding->margins();
return local.contains(point);
if (!containmentItem) {
return false;
}
return QRectF(
containmentItem->mapToScene(QPoint(m_padding->left(),m_padding->top())),
QSizeF(containmentItem->width()-m_padding->left()-m_padding->right(),
containmentItem->height()-m_padding->top()-m_padding->bottom())).contains(point);
} }
QPointF View::positionAdjustedForContainment(const QPointF &point) const QPointF View::positionAdjustedForContainment(const QPointF &point) const
@ -1544,16 +1544,9 @@ QPointF View::positionAdjustedForContainment(const QPointF &point) const
return point; return point;
} }
QQuickItem *containmentItem = containment()->property("_plasma_graphicObject").value<QQuickItem *>(); QRectF local = m_localGeometry - m_padding->margins();
return QPointF(qBound(local.left(), point.x(), local.right()),
if (!containmentItem) { qBound(local.top(), point.y(), local.bottom()));
return point;
}
QRectF containmentRect(containmentItem->mapToScene(QPoint(0,0)), QSizeF(containmentItem->width(), containmentItem->height()));
return QPointF(qBound(containmentRect.left() + m_padding->left(), point.x(), containmentRect.right() - m_padding->right()),
qBound(containmentRect.top() + m_padding->top(), point.y(), containmentRect.bottom() - m_padding->bottom()));
} }

View File

@ -220,28 +220,32 @@ Item{
target: latteView.padding target: latteView.padding
property: "top" property: "top"
when: latteView when: latteView
value: plasmoid.location === PlasmaCore.Types.TopEdge ? metrics.margin.screenEdge : 0 value: plasmoid.formFactor === PlasmaCore.Types.Vertical && !parabolic.isEnabled ?
background.paddings.top + Math.abs(metrics.padding.length) : 0
} }
Binding{ Binding{
target: latteView.padding target: latteView.padding
property: "bottom" property: "bottom"
when: latteView when: latteView
value: plasmoid.location === PlasmaCore.Types.BottomEdge ? metrics.margin.screenEdge : 0 value: plasmoid.formFactor === PlasmaCore.Types.Vertical && !parabolic.isEnabled ?
background.paddings.bottom + Math.abs(metrics.padding.length) : 0
} }
Binding{ Binding{
target: latteView.padding target: latteView.padding
property: "left" property: "left"
when: latteView when: latteView
value: plasmoid.location === PlasmaCore.Types.LeftEdge ? metrics.margin.screenEdge : 0 value: plasmoid.formFactor === PlasmaCore.Types.Horizontal && !parabolic.isEnabled ?
background.paddings.left + Math.abs(metrics.padding.length) : 0
} }
Binding{ Binding{
target: latteView.padding target: latteView.padding
property: "right" property: "right"
when: latteView when: latteView
value: plasmoid.location === PlasmaCore.Types.RightEdge ? metrics.margin.screenEdge : 0 value: plasmoid.formFactor === PlasmaCore.Types.Horizontal && !parabolic.isEnabled ?
background.paddings.right + Math.abs(metrics.padding.length) : 0
} }
//! View::Effects bindings //! View::Effects bindings

View File

@ -657,6 +657,11 @@ Item {
var local = appletItem.mapFromItem(root, pos.x, pos.y); var local = appletItem.mapFromItem(root, pos.x, pos.y);
appletItem.mousePressed(local.x, local.y, button); appletItem.mousePressed(local.x, local.y, button);
if (button === Qt.LeftButton && parabolic.isEnabled) {
/*Hack, until the sinked events plasma approach works propertly with parabolic effect*/
appletItem.activateAppletForNeutralAreas(local);
}
} }
} }

View File

@ -98,7 +98,10 @@ Item{
property int marginsThickness: appletItem.metrics.totals.thicknessEdges property int marginsThickness: appletItem.metrics.totals.thicknessEdges
property int marginsLength: 0 //Fitt's Law, through Binding to avoid Binding loops property int marginsLength: 0 //Fitt's Law, through Binding to avoid Binding loops
property int localLengthMargins: isSeparator || !communicator.requires.lengthMarginsEnabled || isInternalViewSplitter ? 0 : appletItem.lengthAppletFullMargins property int localLengthMargins: isSeparator
|| !communicator.requires.lengthMarginsEnabled
|| isInternalViewSplitter
? 0 : appletItem.lengthAppletFullMargins
property int edgeLengthMargins: edgeLengthMarginsDisabled ? 0 : appletItem.lengthAppletPadding * 2 property int edgeLengthMargins: edgeLengthMarginsDisabled ? 0 : appletItem.lengthAppletPadding * 2
property real scaledLength: zoomScaleLength * (layoutLength + marginsLength) property real scaledLength: zoomScaleLength * (layoutLength + marginsLength)
@ -174,7 +177,7 @@ Item{
} }
} }
onAppletMinimumLengthChanged: { onAppletMinimumLengthChanged: {
if(zoomScale === 1) { if(zoomScale === 1) {
appletItem.updateParabolicEffectIsSupported(); appletItem.updateParabolicEffectIsSupported();
} }