XCB: Suppress leave event, when mouse leaves with button pressed
Fixes: QTBUG-124003 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I232f731b4b5f9e332b1297e5fdae2cadbdf2db1a Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Błażej Szczygieł <mumei6102@gmail.com> (cherry picked from commit 80bfeb4e793c673d540bd7641fc159338f64af1b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
cce7f89532
commit
a225fb5d89
@ -1968,8 +1968,10 @@ void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection()->buttonState() == Qt::NoButton)
|
if (connection()->buttonState() == Qt::NoButton) {
|
||||||
connection()->setMousePressWindow(nullptr);
|
connection()->setMousePressWindow(nullptr);
|
||||||
|
m_ignorePressedWindowOnMouseLeave = false;
|
||||||
|
}
|
||||||
|
|
||||||
handleMouseEvent(timestamp, local, global, modifiers, type, source);
|
handleMouseEvent(timestamp, local, global, modifiers, type, source);
|
||||||
}
|
}
|
||||||
@ -1989,11 +1991,6 @@ static inline bool doCheckUnGrabAncestor(QXcbConnection *conn)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool windowContainsGlobalPoint(QXcbWindow *window, int x, int y)
|
|
||||||
{
|
|
||||||
return window ? window->geometry().contains(window->mapFromGlobal(QPoint(x, y))) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ignoreLeaveEvent(quint8 mode, quint8 detail, QXcbConnection *conn)
|
static bool ignoreLeaveEvent(quint8 mode, quint8 detail, QXcbConnection *conn)
|
||||||
{
|
{
|
||||||
return ((doCheckUnGrabAncestor(conn)
|
return ((doCheckUnGrabAncestor(conn)
|
||||||
@ -2017,12 +2014,17 @@ void QXcbWindow::handleEnterNotifyEvent(int event_x, int event_y, int root_x, in
|
|||||||
{
|
{
|
||||||
connection()->setTime(timestamp);
|
connection()->setTime(timestamp);
|
||||||
|
|
||||||
if (ignoreEnterEvent(mode, detail, connection()) || connection()->mousePressWindow())
|
if (ignoreEnterEvent(mode, detail, connection())
|
||||||
|
|| (connection()->mousePressWindow() && !m_ignorePressedWindowOnMouseLeave)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Updates scroll valuators, as user might have done some scrolling outside our X client.
|
// Updates scroll valuators, as user might have done some scrolling outside our X client.
|
||||||
connection()->xi2UpdateScrollingDevices();
|
connection()->xi2UpdateScrollingDevices();
|
||||||
|
|
||||||
|
if (mode == XCB_NOTIFY_MODE_UNGRAB && connection()->queryMouseButtons() != Qt::NoButton)
|
||||||
|
m_ignorePressedWindowOnMouseLeave = true;
|
||||||
|
|
||||||
const QPoint global = QPoint(root_x, root_y);
|
const QPoint global = QPoint(root_x, root_y);
|
||||||
const QPoint local(event_x, event_y);
|
const QPoint local(event_x, event_y);
|
||||||
QWindowSystemInterface::handleEnterEvent(window(), local, global);
|
QWindowSystemInterface::handleEnterEvent(window(), local, global);
|
||||||
@ -2035,7 +2037,7 @@ void QXcbWindow::handleLeaveNotifyEvent(int root_x, int root_y,
|
|||||||
|
|
||||||
QXcbWindow *mousePressWindow = connection()->mousePressWindow();
|
QXcbWindow *mousePressWindow = connection()->mousePressWindow();
|
||||||
if (ignoreLeaveEvent(mode, detail, connection())
|
if (ignoreLeaveEvent(mode, detail, connection())
|
||||||
|| (mousePressWindow && windowContainsGlobalPoint(mousePressWindow, root_x, root_y))) {
|
|| (mousePressWindow && !m_ignorePressedWindowOnMouseLeave)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2055,7 +2057,7 @@ void QXcbWindow::handleLeaveNotifyEvent(int root_x, int root_y,
|
|||||||
QWindowSystemInterface::handleEnterLeaveEvent(enterWindow->window(), window(), local, global);
|
QWindowSystemInterface::handleEnterLeaveEvent(enterWindow->window(), window(), local, global);
|
||||||
} else {
|
} else {
|
||||||
QWindowSystemInterface::handleLeaveEvent(window());
|
QWindowSystemInterface::handleLeaveEvent(window());
|
||||||
if (!windowContainsGlobalPoint(this, root_x, root_y))
|
if (m_ignorePressedWindowOnMouseLeave)
|
||||||
connection()->setMousePressWindow(nullptr);
|
connection()->setMousePressWindow(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +230,7 @@ protected:
|
|||||||
bool m_alertState = false;
|
bool m_alertState = false;
|
||||||
bool m_minimized = false;
|
bool m_minimized = false;
|
||||||
bool m_trayIconWindow = false;
|
bool m_trayIconWindow = false;
|
||||||
|
bool m_ignorePressedWindowOnMouseLeave = false;
|
||||||
xcb_window_t m_netWmUserTimeWindow = XCB_NONE;
|
xcb_window_t m_netWmUserTimeWindow = XCB_NONE;
|
||||||
|
|
||||||
QSurfaceFormat m_format;
|
QSurfaceFormat m_format;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user