Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 30136e54 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix canvas lockup when using Guides at the top of the image

1) We should never eat Enter/Leave events in priority event filters,
   it makes input manager crazy

2) Enter event also has a cursor position that should be handled
   gracefully.

BUG:391098
parent f09bc200
......@@ -69,7 +69,7 @@ struct KisGuidesManager::Private
void deleteGuide(const GuideHandle &h);
const GuideHandle invalidGuide;
bool updateCursor(const QPointF &docPos);
bool updateCursor(const QPointF &docPos, bool forceDisableCursor = false);
void initDragStart(const GuideHandle &guide,
const QPointF &dragStart,
......@@ -456,12 +456,12 @@ void KisGuidesManager::Private::deleteGuide(const GuideHandle &h)
}
}
bool KisGuidesManager::Private::updateCursor(const QPointF &docPos)
bool KisGuidesManager::Private::updateCursor(const QPointF &docPos, bool forceDisableCursor)
{
KisCanvas2 *canvas = view->canvasBase();
const GuideHandle guide = findGuide(docPos);
const bool guideValid = isGuideValid(guide);
const bool guideValid = isGuideValid(guide) && !forceDisableCursor;
if (guideValid && !cursorSwitched) {
oldCursor = canvas->canvasWidget()->cursor();
......@@ -576,7 +576,10 @@ QPointF KisGuidesManager::Private::getDocPointFromEvent(QEvent *event)
KisCanvas2 *canvas = view->canvasBase();
const KisCoordinatesConverter *converter = canvas->coordinatesConverter();
if (event->type() == QEvent::MouseMove ||
if (event->type() == QEvent::Enter) {
QEnterEvent *enterEvent = static_cast<QEnterEvent*>(event);
result = alignToPixels(converter->widgetToDocument(enterEvent->pos()));
} else if (event->type() == QEvent::MouseMove ||
event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease) {
......@@ -589,6 +592,10 @@ QPointF KisGuidesManager::Private::getDocPointFromEvent(QEvent *event)
QTabletEvent *tabletEvent = static_cast<QTabletEvent*>(event);
result = alignToPixels(converter->widgetToDocument(tabletEvent->pos()));
} else {
// we shouldn't silently return QPointF(0,0), higher level code may
// snap to some unexpected guide
KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "event type is not supported!");
}
return result;
......@@ -623,13 +630,17 @@ bool KisGuidesManager::eventFilter(QObject *obj, QEvent *event)
bool retval = false;
switch (event->type()) {
case QEvent::Enter:
case QEvent::Leave:
m_d->updateCursor(QPointF(), true);
break;
case QEvent::Enter:
case QEvent::TabletMove:
case QEvent::MouseMove: {
const QPointF docPos = m_d->getDocPointFromEvent(event);
const Qt::KeyboardModifiers modifiers = qApp->keyboardModifiers();
retval = m_d->mouseMoveHandler(docPos, modifiers);
// we should never eat Enter events, input manager may get crazy about it
retval = m_d->mouseMoveHandler(docPos, modifiers) && event->type() != QEvent::Enter;
break;
}
......
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