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)
|
||||
{
|
||||
switch(e->type) {
|
||||
case QWindowSystemInterfacePrivate::FrameStrutMouse:
|
||||
case QWindowSystemInterfacePrivate::Mouse:
|
||||
QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
|
||||
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
|
||||
// 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.
|
||||
QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(
|
||||
e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers, e->source);
|
||||
QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(e->window.data(), e->timestamp,
|
||||
e->localPos, e->globalPos, e->buttons, e->modifiers, e->source, e->nonClientArea);
|
||||
if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
|
||||
mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
|
||||
e->buttons = mouse_buttons;
|
||||
@ -1888,10 +1887,9 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
||||
|
||||
Qt::MouseButton button = Qt::NoButton;
|
||||
bool doubleClick = false;
|
||||
const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse;
|
||||
|
||||
if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) {
|
||||
type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
|
||||
type = e->nonClientArea ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
|
||||
QGuiApplicationPrivate::lastCursorPosition = globalPoint;
|
||||
if (qAbs(globalPoint.x() - mousePressX) > 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) {
|
||||
ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
|
||||
doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
|
||||
type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
|
||||
type = e->nonClientArea ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
|
||||
mousePressTime = e->timestamp;
|
||||
mousePressButton = button;
|
||||
const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint();
|
||||
mousePressX = point.x();
|
||||
mousePressY = point.y();
|
||||
} 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);
|
||||
e->eventAccepted = ev.isAccepted();
|
||||
if (!e->synthetic() && !ev.isAccepted()
|
||||
&& !frameStrut
|
||||
&& !e->nonClientArea
|
||||
&& qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
|
||||
if (!m_fakeTouchDevice) {
|
||||
m_fakeTouchDevice = new QTouchDevice;
|
||||
@ -1994,7 +1992,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
|
||||
if (doubleClick) {
|
||||
mousePressButton = Qt::NoButton;
|
||||
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,
|
||||
button, mouse_buttons, e->modifiers, e->source);
|
||||
dblClickEvent.setTimestamp(e->timestamp);
|
||||
|
@ -368,8 +368,9 @@ void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, ulong t
|
||||
{
|
||||
QWindowSystemInterfacePrivate::MouseEvent * e =
|
||||
new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp,
|
||||
QWindowSystemInterfacePrivate::FrameStrutMouse,
|
||||
QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window), b, mods, source);
|
||||
QHighDpi::fromNativeLocalPosition(local, window),
|
||||
QHighDpi::fromNativePixels(global, window),
|
||||
b, mods, source, true);
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
ActivatedWindow = 0x05,
|
||||
WindowStateChanged = 0x06,
|
||||
Mouse = UserInputEvent | 0x07,
|
||||
FrameStrutMouse = UserInputEvent | 0x08,
|
||||
FrameStrutMouse = UserInputEvent | 0x08, // ### Qt6 remove
|
||||
Wheel = UserInputEvent | 0x09,
|
||||
Key = UserInputEvent | 0x0a,
|
||||
Touch = UserInputEvent | 0x0b,
|
||||
@ -227,16 +227,14 @@ public:
|
||||
public:
|
||||
MouseEvent(QWindow * w, ulong time, const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons b, Qt::KeyboardModifiers mods,
|
||||
Qt::MouseEventSource src = Qt::MouseEventNotSynthesized)
|
||||
: InputEvent(w, time, Mouse, mods), localPos(local), globalPos(global), buttons(b), source(src) { }
|
||||
MouseEvent(QWindow * w, ulong time, EventType t, const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons b, Qt::KeyboardModifiers mods,
|
||||
Qt::MouseEventSource src = Qt::MouseEventNotSynthesized)
|
||||
: InputEvent(w, time, t, mods), localPos(local), globalPos(global), buttons(b), source(src) { }
|
||||
Qt::MouseEventSource src = Qt::MouseEventNotSynthesized, bool frame = false)
|
||||
: InputEvent(w, time, Mouse, mods), localPos(local), globalPos(global), buttons(b),
|
||||
source(src), nonClientArea(frame) { }
|
||||
QPointF localPos;
|
||||
QPointF globalPos;
|
||||
Qt::MouseButtons buttons;
|
||||
Qt::MouseEventSource source;
|
||||
bool nonClientArea;
|
||||
};
|
||||
|
||||
class WheelEvent : public InputEvent {
|
||||
|
Loading…
x
Reference in New Issue
Block a user