Commit 2642741e authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix hiding the brush outline when the cursor is outside the canvas

Please check this patch on Gnome and Windows!

BUG:335649
CCMAIL:kimageshop@kde.org

Conflicts:

	krita/ui/input/kis_input_manager.cpp
parent 01c8700d
......@@ -613,6 +613,8 @@ bool KisInputManager::eventFilter(QObject* object, QEvent* event)
d->canvas->canvasWidget()->setFocus();
stop_ignore_cursor_events();
touch_stop_block_press_events();
d->matcher.enterEvent();
break;
case QEvent::Leave:
d->debugEvent<QEvent, false>(event);
......@@ -623,6 +625,8 @@ bool KisInputManager::eventFilter(QObject* object, QEvent* event)
*/
stop_ignore_cursor_events();
touch_stop_block_press_events();
d->matcher.leaveEvent();
break;
case QEvent::FocusIn:
d->debugEvent<QEvent, false>(event);
......
......@@ -43,6 +43,7 @@ public:
, readyShortcut(0)
, touchShortcut(0)
, suppressAllActions(false)
, cursorEntered(false)
, usingTouch(false)
{}
......@@ -60,7 +61,12 @@ public:
KisTouchShortcut *touchShortcut;
bool suppressAllActions;
bool cursorEntered;
bool usingTouch;
inline bool actionsSuppressed() const {
return suppressAllActions || !cursorEntered;
}
};
KisShortcutMatcher::KisShortcutMatcher()
......@@ -216,6 +222,26 @@ bool KisShortcutMatcher::mouseMoved(QMouseEvent *event)
return true;
}
void KisShortcutMatcher::enterEvent()
{
m_d->cursorEntered = true;
if (!m_d->runningShortcut) {
prepareReadyShortcuts();
tryActivateReadyShortcut();
}
}
void KisShortcutMatcher::leaveEvent()
{
m_d->cursorEntered = false;
if (!m_d->runningShortcut) {
prepareReadyShortcuts();
tryActivateReadyShortcut();
}
}
bool KisShortcutMatcher::touchBeginEvent( QTouchEvent* event )
{
Q_UNUSED(event)
......@@ -313,7 +339,7 @@ bool KisShortcutMatcher::tryRunKeyShortcut(Qt::Key key, QKeyEvent *event)
template<typename T, typename U>
bool KisShortcutMatcher::tryRunSingleActionShortcutImpl(T param, U *event, const QList<Qt::Key> &keysState)
{
if (m_d->suppressAllActions) return false;
if (m_d->actionsSuppressed()) return false;
KisSingleActionShortcut *goodCandidate = 0;
......@@ -336,7 +362,7 @@ bool KisShortcutMatcher::tryRunSingleActionShortcutImpl(T param, U *event, const
void KisShortcutMatcher::prepareReadyShortcuts()
{
m_d->readyShortcuts.clear();
if (m_d->suppressAllActions) return;
if (m_d->actionsSuppressed()) return;
foreach(KisStrokeShortcut *s, m_d->strokeShortcuts) {
if (s->matchReady(m_d->keys, m_d->buttons)) {
......@@ -424,7 +450,7 @@ bool KisShortcutMatcher::tryRunTouchShortcut( QTouchEvent* event )
{
KisTouchShortcut *goodCandidate = 0;
if (m_d->suppressAllActions)
if (m_d->actionsSuppressed())
return false;
foreach(KisTouchShortcut* shortcut, m_d->touchShortcuts) {
......
......@@ -166,6 +166,18 @@ public:
*/
bool mouseMoved(QMouseEvent *event);
/**
* Handle cursor's Enter event.
* We never eat it because it might be used by someone else
*/
void enterEvent();
/**
* Handle cursor's Leave event.
* We never eat it because it might be used by someone else
*/
void leaveEvent();
bool touchBeginEvent(QTouchEvent *event);
bool touchUpdateEvent(QTouchEvent *event);
bool touchEndEvent(QTouchEvent *event);
......
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