qpa: stop using QWindowSystemInterfacePrivate::FrameStrutMouse enum
Non client area mouse events are mouse events too. There is no need for a dedicated event type in QWindowSystemInterface. Instead we pass the state through a 'nonClientArea' variable of the mouse event, corresponding to QEvent::NonClientArea{Press,Release,Move}. Change-Id: Ia0a188400787506c8fe0cfe58aee0776c1ab13c7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
6f16b7a8f3
commit
196f7af6e2
@ -1736,7 +1736,6 @@ bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArra
|
|||||||
void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
|
void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
|
||||||
{
|
{
|
||||||
switch(e->type) {
|
switch(e->type) {
|
||||||
case QWindowSystemInterfacePrivate::FrameStrutMouse:
|
|
||||||
case QWindowSystemInterfacePrivate::Mouse:
|
case QWindowSystemInterfacePrivate::Mouse:
|
||||||
QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
|
QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
|
||||||
break;
|
break;
|
||||||
@ -1851,8 +1850,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
|||||||
// A mouse event should not change both position and buttons at the same time. Instead we
|
// A mouse event should not change both position and buttons at the same time. Instead we
|
||||||
// should first send a move event followed by a button changed event. Since this is not the case
|
// should first send a move event followed by a button changed event. Since this is not the case
|
||||||
// with the current event, we split it in two.
|
// with the current event, we split it in two.
|
||||||
QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(
|
QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(e->window.data(), e->timestamp,
|
||||||
e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers, e->source);
|
e->localPos, e->globalPos, e->buttons, e->modifiers, e->source, e->nonClientArea);
|
||||||
if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
|
if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
|
||||||
mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
|
mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
|
||||||
e->buttons = mouse_buttons;
|
e->buttons = mouse_buttons;
|
||||||
@ -1888,10 +1887,9 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
|||||||
|
|
||||||
Qt::MouseButton button = Qt::NoButton;
|
Qt::MouseButton button = Qt::NoButton;
|
||||||
bool doubleClick = false;
|
bool doubleClick = false;
|
||||||
const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse;
|
|
||||||
|
|
||||||
if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) {
|
if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) {
|
||||||
type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
|
type = e->nonClientArea ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
|
||||||
QGuiApplicationPrivate::lastCursorPosition = globalPoint;
|
QGuiApplicationPrivate::lastCursorPosition = globalPoint;
|
||||||
if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
|
if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
|
||||||
qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
|
qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
|
||||||
@ -1913,14 +1911,14 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
|||||||
if (button & e->buttons) {
|
if (button & e->buttons) {
|
||||||
ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
|
ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
|
||||||
doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
|
doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
|
||||||
type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
|
type = e->nonClientArea ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
|
||||||
mousePressTime = e->timestamp;
|
mousePressTime = e->timestamp;
|
||||||
mousePressButton = button;
|
mousePressButton = button;
|
||||||
const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint();
|
const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint();
|
||||||
mousePressX = point.x();
|
mousePressX = point.x();
|
||||||
mousePressY = point.y();
|
mousePressY = point.y();
|
||||||
} else {
|
} else {
|
||||||
type = frameStrut ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease;
|
type = e->nonClientArea ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1957,7 +1955,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
|||||||
QGuiApplication::sendSpontaneousEvent(window, &ev);
|
QGuiApplication::sendSpontaneousEvent(window, &ev);
|
||||||
e->eventAccepted = ev.isAccepted();
|
e->eventAccepted = ev.isAccepted();
|
||||||
if (!e->synthetic() && !ev.isAccepted()
|
if (!e->synthetic() && !ev.isAccepted()
|
||||||
&& !frameStrut
|
&& !e->nonClientArea
|
||||||
&& qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
|
&& qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
|
||||||
if (!m_fakeTouchDevice) {
|
if (!m_fakeTouchDevice) {
|
||||||
m_fakeTouchDevice = new QTouchDevice;
|
m_fakeTouchDevice = new QTouchDevice;
|
||||||
@ -1994,7 +1992,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
|||||||
if (doubleClick) {
|
if (doubleClick) {
|
||||||
mousePressButton = Qt::NoButton;
|
mousePressButton = Qt::NoButton;
|
||||||
if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press
|
if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press
|
||||||
const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
|
const QEvent::Type doubleClickType = e->nonClientArea ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
|
||||||
QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint,
|
QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint,
|
||||||
button, mouse_buttons, e->modifiers, e->source);
|
button, mouse_buttons, e->modifiers, e->source);
|
||||||
dblClickEvent.setTimestamp(e->timestamp);
|
dblClickEvent.setTimestamp(e->timestamp);
|
||||||
|
@ -368,8 +368,9 @@ void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, ulong t
|
|||||||
{
|
{
|
||||||
QWindowSystemInterfacePrivate::MouseEvent * e =
|
QWindowSystemInterfacePrivate::MouseEvent * e =
|
||||||
new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp,
|
new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp,
|
||||||
QWindowSystemInterfacePrivate::FrameStrutMouse,
|
QHighDpi::fromNativeLocalPosition(local, window),
|
||||||
QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window), b, mods, source);
|
QHighDpi::fromNativePixels(global, window),
|
||||||
|
b, mods, source, true);
|
||||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
ActivatedWindow = 0x05,
|
ActivatedWindow = 0x05,
|
||||||
WindowStateChanged = 0x06,
|
WindowStateChanged = 0x06,
|
||||||
Mouse = UserInputEvent | 0x07,
|
Mouse = UserInputEvent | 0x07,
|
||||||
FrameStrutMouse = UserInputEvent | 0x08,
|
FrameStrutMouse = UserInputEvent | 0x08, // ### Qt6 remove
|
||||||
Wheel = UserInputEvent | 0x09,
|
Wheel = UserInputEvent | 0x09,
|
||||||
Key = UserInputEvent | 0x0a,
|
Key = UserInputEvent | 0x0a,
|
||||||
Touch = UserInputEvent | 0x0b,
|
Touch = UserInputEvent | 0x0b,
|
||||||
@ -227,16 +227,14 @@ public:
|
|||||||
public:
|
public:
|
||||||
MouseEvent(QWindow * w, ulong time, const QPointF &local, const QPointF &global,
|
MouseEvent(QWindow * w, ulong time, const QPointF &local, const QPointF &global,
|
||||||
Qt::MouseButtons b, Qt::KeyboardModifiers mods,
|
Qt::MouseButtons b, Qt::KeyboardModifiers mods,
|
||||||
Qt::MouseEventSource src = Qt::MouseEventNotSynthesized)
|
Qt::MouseEventSource src = Qt::MouseEventNotSynthesized, bool frame = false)
|
||||||
: InputEvent(w, time, Mouse, mods), localPos(local), globalPos(global), buttons(b), source(src) { }
|
: InputEvent(w, time, Mouse, mods), localPos(local), globalPos(global), buttons(b),
|
||||||
MouseEvent(QWindow * w, ulong time, EventType t, const QPointF &local, const QPointF &global,
|
source(src), nonClientArea(frame) { }
|
||||||
Qt::MouseButtons b, Qt::KeyboardModifiers mods,
|
|
||||||
Qt::MouseEventSource src = Qt::MouseEventNotSynthesized)
|
|
||||||
: InputEvent(w, time, t, mods), localPos(local), globalPos(global), buttons(b), source(src) { }
|
|
||||||
QPointF localPos;
|
QPointF localPos;
|
||||||
QPointF globalPos;
|
QPointF globalPos;
|
||||||
Qt::MouseButtons buttons;
|
Qt::MouseButtons buttons;
|
||||||
Qt::MouseEventSource source;
|
Qt::MouseEventSource source;
|
||||||
|
bool nonClientArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WheelEvent : public InputEvent {
|
class WheelEvent : public InputEvent {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user