Commit 1cb0d180 authored by David Edmundson's avatar David Edmundson

Fix autohide panels on wayland

Summary:
To test if the panel is under the cursor we used:
if (geometry().contains(QCursor::pos(screenToFollow()))) {

Unsurprisingly in wayland we don't know the cursor position once it's
left our window. Behaviour seems to be undefined.

We were already using enter and leave events to start the autohide
timer, so we may as well rely on that for tracking state too.

BUG: 377838

Test Plan:
Tested mouse in, mouse out

Tested mouse in and waiting and panel stayed open

Tested opening wifi applet and closing it
That will trigger the restoreAutoHide method as an applet status changed
The panel stayed open because the mouse was on it.

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10101
parent fb3775c2
......@@ -624,7 +624,7 @@ void PanelView::restoreAutoHide()
if (!edgeActivated()) {
autoHide = false;
}
else if (geometry().contains(QCursor::pos(screenToFollow()))) {
else if (m_containsMouse) {
autoHide = false;
}
else if (containment() && containment()->isUserConfiguring()) {
......@@ -802,18 +802,25 @@ void PanelView::adaptToScreen()
bool PanelView::event(QEvent *e)
{
if (edgeActivated()) {
if (e->type() == QEvent::Enter) {
m_unhideTimer.stop();
} else if (e->type() == QEvent::Leave) {
m_unhideTimer.start();
}
}
/*Fitt's law: if the containment has margins, and the mouse cursor clicked
* on the mouse edge, forward the click in the containment boundaries
*/
switch (e->type()) {
case QEvent::Enter:
m_containsMouse = true;
if (edgeActivated()) {
m_unhideTimer.stop();
}
break;
case QEvent::Leave:
m_containsMouse = false;
if (edgeActivated()) {
m_unhideTimer.start();
}
break;
/*Fitt's law: if the containment has margins, and the mouse cursor clicked
* on the mouse edge, forward the click in the containment boundaries
*/
case QEvent::MouseMove:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease: {
......@@ -839,12 +846,6 @@ bool PanelView::event(QEvent *e)
break;
}
case QEvent::Enter:
case QEvent::Leave:
// QtQuick < 5.6 issue:
// QEvent::Leave is triggered on MouseButtonPress Qt::LeftButton
break;
case QEvent::Wheel: {
QWheelEvent *we = static_cast<QWheelEvent *>(e);
......@@ -901,6 +902,7 @@ bool PanelView::event(QEvent *e)
if (m_panelConfigView && m_panelConfigView.data()->isVisible()) {
m_panelConfigView.data()->hide();
}
m_containsMouse = false;
break;
}
case QEvent::PlatformSurface:
......
......@@ -221,6 +221,7 @@ private:
int m_distance;
int m_thickness;
bool m_initCompleted;
bool m_containsMouse = false;
Qt::Alignment m_alignment;
QPointer<PlasmaQuick::ConfigView> m_panelConfigView;
ShellCorona *m_corona;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment