Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: .qmake.conf Change-Id: Ic75157b11eee188608c3ac7ed6fb1a033bb72750
This commit is contained in:
commit
4192bc7a06
@ -116,6 +116,14 @@ static const char * const qt_normalizeup_xpm[] = {
|
||||
# define BUTTON_WIDTH 22
|
||||
#endif
|
||||
|
||||
enum Button
|
||||
{
|
||||
None,
|
||||
Close,
|
||||
Maximize,
|
||||
Minimize
|
||||
};
|
||||
|
||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandBradientDecoration : public QWaylandAbstractDecoration
|
||||
{
|
||||
public:
|
||||
@ -130,6 +138,7 @@ private:
|
||||
void processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
||||
void processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
||||
void processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
||||
bool clickButton(Qt::MouseButtons b, Button btn);
|
||||
|
||||
QRectF closeButtonRect() const;
|
||||
QRectF maximizeButtonRect() const;
|
||||
@ -138,12 +147,14 @@ private:
|
||||
QColor m_foregroundColor;
|
||||
QColor m_backgroundColor;
|
||||
QStaticText m_windowTitle;
|
||||
Button m_clicking;
|
||||
};
|
||||
|
||||
|
||||
|
||||
QWaylandBradientDecoration::QWaylandBradientDecoration()
|
||||
: QWaylandAbstractDecoration()
|
||||
, m_clicking(None)
|
||||
{
|
||||
QPalette palette;
|
||||
m_foregroundColor = palette.color(QPalette::Active, QPalette::HighlightedText);
|
||||
@ -315,18 +326,37 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons b, Button btn)
|
||||
{
|
||||
if (isLeftClicked(b)) {
|
||||
m_clicking = btn;
|
||||
return false;
|
||||
} else if (isLeftReleased(b)) {
|
||||
if (m_clicking == btn) {
|
||||
m_clicking = None;
|
||||
return true;
|
||||
} else {
|
||||
m_clicking = None;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
|
||||
|
||||
{
|
||||
Q_UNUSED(global);
|
||||
|
||||
// Figure out what area mouse is in
|
||||
if (closeButtonRect().contains(local) && isLeftClicked(b)) {
|
||||
QWindowSystemInterface::handleCloseEvent(window());
|
||||
} else if (maximizeButtonRect().contains(local) && isLeftClicked(b)) {
|
||||
window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
|
||||
} else if (minimizeButtonRect().contains(local) && isLeftClicked(b)) {
|
||||
window()->setWindowState(Qt::WindowMinimized);
|
||||
if (closeButtonRect().contains(local)) {
|
||||
if (clickButton(b, Close))
|
||||
QWindowSystemInterface::handleCloseEvent(window());
|
||||
} else if (maximizeButtonRect().contains(local)) {
|
||||
if (clickButton(b, Maximize))
|
||||
window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
|
||||
} else if (minimizeButtonRect().contains(local)) {
|
||||
if (clickButton(b, Minimize))
|
||||
window()->setWindowState(Qt::WindowMinimized);
|
||||
} else if (local.y() <= margins().top()) {
|
||||
processMouseTop(inputDevice,local,b,mods);
|
||||
} else if (local.y() > window()->height() - margins().bottom() + margins().top()) {
|
||||
|
@ -147,7 +147,7 @@ void QWaylandAbstractDecoration::startMove(QWaylandInputDevice *inputDevice, Qt:
|
||||
bool QWaylandAbstractDecoration::isLeftClicked(Qt::MouseButtons newMouseButtonState)
|
||||
{
|
||||
Q_D(QWaylandAbstractDecoration);
|
||||
if ((!d->m_mouseButtons & Qt::LeftButton) && (newMouseButtonState & Qt::LeftButton))
|
||||
if (!(d->m_mouseButtons & Qt::LeftButton) && (newMouseButtonState & Qt::LeftButton))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -94,10 +94,10 @@ QWaylandDataSource *QWaylandDataDevice::selectionSource() const
|
||||
|
||||
void QWaylandDataDevice::setSelectionSource(QWaylandDataSource *source)
|
||||
{
|
||||
m_selectionSource.reset(source);
|
||||
if (source)
|
||||
connect(source, &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::selectionSourceCancelled);
|
||||
set_selection(source ? source->object() : Q_NULLPTR, m_inputDevice->serial());
|
||||
m_selectionSource.reset(source);
|
||||
}
|
||||
|
||||
QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
|
||||
|
@ -136,7 +136,7 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
|
||||
}
|
||||
|
||||
m_dataOffer->receive(mime, pipefd[1]);
|
||||
m_display->flushRequests();
|
||||
wl_display_flush(m_display->wl_display());
|
||||
|
||||
close(pipefd[1]);
|
||||
|
||||
|
@ -163,6 +163,9 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
|
||||
|
||||
QWaylandDisplay::~QWaylandDisplay(void)
|
||||
{
|
||||
qDeleteAll(mInputDevices);
|
||||
mInputDevices.clear();
|
||||
|
||||
foreach (QWaylandScreen *screen, mScreens) {
|
||||
mWaylandIntegration->destroyScreen(screen);
|
||||
}
|
||||
|
@ -494,6 +494,15 @@ void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t time
|
||||
}
|
||||
}
|
||||
|
||||
class WheelEvent : public QWaylandPointerEvent
|
||||
{
|
||||
public:
|
||||
WheelEvent(ulong t, const QPointF &l, const QPointF &g, const QPoint &pd, const QPoint &ad)
|
||||
: QWaylandPointerEvent(QWaylandPointerEvent::Wheel, t, l, g, pd, ad)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
QWaylandWindow *window = mFocus;
|
||||
@ -517,10 +526,8 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in
|
||||
angleDelta.setY(valueDelta);
|
||||
}
|
||||
|
||||
QWindowSystemInterface::handleWheelEvent(window->window(),
|
||||
time, mSurfacePos,
|
||||
mGlobalPos, pixelDelta,
|
||||
angleDelta);
|
||||
WheelEvent e(time, mSurfacePos, mGlobalPos, pixelDelta, angleDelta);
|
||||
window->handleMouse(mParent, e);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_WAYLAND_XKB
|
||||
|
@ -259,7 +259,8 @@ class QWaylandPointerEvent
|
||||
public:
|
||||
enum Type {
|
||||
Enter,
|
||||
Motion
|
||||
Motion,
|
||||
Wheel
|
||||
};
|
||||
inline QWaylandPointerEvent(Type t, ulong ts, const QPointF &l, const QPointF &g, Qt::MouseButtons b, Qt::KeyboardModifiers m)
|
||||
: type(t)
|
||||
@ -269,6 +270,14 @@ public:
|
||||
, buttons(b)
|
||||
, modifiers(m)
|
||||
{}
|
||||
inline QWaylandPointerEvent(Type t, ulong ts, const QPointF &l, const QPointF &g, const QPoint &pd, const QPoint &ad)
|
||||
: type(t)
|
||||
, timestamp(ts)
|
||||
, local(l)
|
||||
, global(g)
|
||||
, pixelDelta(pd)
|
||||
, angleDelta(ad)
|
||||
{}
|
||||
|
||||
Type type;
|
||||
ulong timestamp;
|
||||
@ -276,6 +285,8 @@ public:
|
||||
QPointF global;
|
||||
Qt::MouseButtons buttons;
|
||||
Qt::KeyboardModifiers modifiers;
|
||||
QPoint pixelDelta;
|
||||
QPoint angleDelta;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -625,6 +625,9 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan
|
||||
case QWaylandPointerEvent::Motion:
|
||||
QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.modifiers);
|
||||
break;
|
||||
case QWaylandPointerEvent::Wheel:
|
||||
QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, e.pixelDelta, e.angleDelta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,6 +687,9 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
|
||||
case QWaylandPointerEvent::Motion:
|
||||
QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers);
|
||||
break;
|
||||
case QWaylandPointerEvent::Wheel:
|
||||
QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta);
|
||||
break;
|
||||
}
|
||||
|
||||
mMouseEventsInContentArea = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user