From 9e59174b49b8d4c6ebe0cab2b8df9e93f1090211 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Sat, 20 Feb 2016 15:48:40 +0300 Subject: QPixmap: check data ptr in isQBitmap() Task-number: QTBUG-51271 Change-Id: I670e074ced1217d2614fa334eb365e40ef80b8b1 Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- src/gui/image/qpixmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index fb62889e40..0c8ab527b2 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -481,7 +481,7 @@ QMatrix QPixmap::trueMatrix(const QMatrix &m, int w, int h) bool QPixmap::isQBitmap() const { - return data->type == QPlatformPixmap::BitmapType; + return data && data->type == QPlatformPixmap::BitmapType; } /*! -- cgit v1.2.3 From e695b92464f886bb9026bb20877f0ea3ea57d2c8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 7 Jan 2016 12:18:26 +0100 Subject: QWindow: Use scaling when calling QPlatformWindow::mapTo/FromGlobal(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The platform window API uses native pixels. Task-number: QTBUG-50206 Change-Id: I1385d34bb0eacd61d77cad483e2a863d129ed129 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index e0d991aaf8..68bcbdec71 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2298,7 +2298,7 @@ QPoint QWindow::mapToGlobal(const QPoint &pos) const // QTBUG-43252, prefer platform implementation for foreign windows. if (d->platformWindow && (type() == Qt::ForeignWindow || d->platformWindow->isEmbedded())) { - return d->platformWindow->mapToGlobal(pos); + return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this); } return pos + d->globalPosition(); } @@ -2318,7 +2318,7 @@ QPoint QWindow::mapFromGlobal(const QPoint &pos) const // QTBUG-43252, prefer platform implementation for foreign windows. if (d->platformWindow && (type() == Qt::ForeignWindow || d->platformWindow->isEmbedded())) { - return d->platformWindow->mapFromGlobal(pos); + return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this); } return pos - d->globalPosition(); } -- cgit v1.2.3 From debc44cf1106fb20065aab7848759eace3211c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 25 Feb 2016 15:54:40 +0100 Subject: Add missing initializations in QWheelEvent Change-Id: I77f014934b97aa6729d568996f0e6c03feb44588 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index b0f7adf43a..4f368e1db3 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -726,7 +726,8 @@ QHoverEvent::~QHoverEvent() QWheelEvent::QWheelEvent(const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) - : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons) + : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons), + ph(Qt::ScrollUpdate), src(Qt::MouseEventNotSynthesized) { g = QCursor::pos(); if (orient == Qt::Vertical) @@ -760,7 +761,8 @@ QWheelEvent::~QWheelEvent() QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons) + : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons), + ph(Qt::ScrollUpdate), src(Qt::MouseEventNotSynthesized) { if (orient == Qt::Vertical) angleD = QPoint(0, delta); @@ -796,7 +798,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::ScrollUpdate) + angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::ScrollUpdate), + src(Qt::MouseEventNotSynthesized) {} /*! -- cgit v1.2.3 From c0963486ce689e778d59dafd26d36d8ef9e3ee74 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 24 Feb 2016 13:13:36 +0100 Subject: QScreen::grabWindow(): Scale the coordinates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The coordinates need to be scaled before calling QPlatformScreen::grabWindow() On return, set a devicePixelRatio on the pixmap. Adapt the QWidget test to scale the grabbed pixmaps. Fixes pixeltool displaying the wrong part of the screen when High DPI scaling is in effect. Task-number: QTBUG-46615 Change-Id: I12de7df0da669230cf0fae74f4a42d43f061d5ff Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qscreen.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 52e7686439..e87f58d735 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -40,6 +40,7 @@ #include #include +#include "qhighdpiscaling_p.h" QT_BEGIN_NAMESPACE @@ -683,7 +684,19 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) qWarning("invoked with handle==0"); return QPixmap(); } - return platformScreen->grabWindow(window, x, y, width, height); + const qreal factor = QHighDpiScaling::factor(this); + if (qFuzzyCompare(factor, 1)) + return platformScreen->grabWindow(window, x, y, width, height); + + const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor); + QSize nativeSize(width, height); + if (nativeSize.isValid()) + nativeSize = QHighDpi::toNative(nativeSize, factor); + QPixmap result = + platformScreen->grabWindow(window, nativePos.x(), nativePos.y(), + nativeSize.width(), nativeSize.height()); + result.setDevicePixelRatio(factor); + return result; } #ifndef QT_NO_DEBUG_STREAM -- cgit v1.2.3 From cf846d6a8a0df0f0935f7f1306ab8439309cf6e5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 25 Feb 2016 10:15:22 +0100 Subject: Fix QHighDpi::fromNative(QRect, QScreen *, QPoint). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Call fromNative() instead of toNative(). Task-number: QTBUG-46615 Change-Id: I1e648a2680126d1f560e71573f7346b053fe676b Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qhighdpiscaling_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index fac3ae420d..a7b80982af 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -162,7 +162,7 @@ inline QRect toNative(const QRect &rect, qreal scaleFactor, const QPoint &origin inline QRect fromNative(const QRect &rect, const QScreen *screen, const QPoint &screenOrigin) { - return toNative(rect, QHighDpiScaling::factor(screen), screenOrigin); + return fromNative(rect, QHighDpiScaling::factor(screen), screenOrigin); } inline QRect fromNativeScreenGeometry(const QRect &nativeScreenGeometry, const QScreen *screen) -- cgit v1.2.3 From 9f134750a1ab677cfba4f42fbf72208405e04b84 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 23 Feb 2016 15:26:49 +0100 Subject: QPlatformWindow::screenForGeometry(): Do not call mapToGlobal() on top level geometry. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use mapToGlobal() only for foreign windows passing relative coordinates. Amend change 9915630d0886434e8984904b1cadedc81dc78ca0. Task-number: QTBUG-50206 Task-number: QTBUG-51320 Change-Id: Idee60cc8ea8004c0355ce78a00f807798836b49c Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qplatformwindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 04532e82aa..9f2c6af51f 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -486,8 +486,9 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co QPlatformScreen *fallback = currentScreen; // QRect::center can return a value outside the rectangle if it's empty. // Apply mapToGlobal() in case it is a foreign/embedded window. - const QPoint center = - mapToGlobal(newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center()); + QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center(); + if (window()->type() == Qt::ForeignWindow) + center = mapToGlobal(center - newGeometry.topLeft()); if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) { Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { -- cgit v1.2.3 From f253f4c3310655933266f62e90f46fd12b5c49e4 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 10 Feb 2016 11:30:33 -0800 Subject: Track target widget when wheel events are received This issue is reproducible on OS X when using a Magic Mouse or a combination of Magic Trackpad and regular mouse. In these cases it's possible to start a scrolling gesture on one widget and move the mouse cursor over another widget. Although we send the wheel event phase information, we never made any use of it. This means that a widget would start scrolling even though it never received a ScrollBegin event. In this patch, we make sure the scrolling cycle is respected and that once a widget starts scrolling, it'll be recieving all the wheel events until a ScrollEnd event reaches the application. For those input devices not supporting a proper phase cycle, we introduce a new (undocumented) phase value, NoScrollPhase. If the wheel event phase is NoScrollPhase, then we ignore the current scroll widget and proceed as usual. This value is the default for wheel events. It's up to the platform plugin to set the proper phase value according to the data received from the OS. Finally, we fix a few of QWheelEvent constructors to properly initialize the phase and source properties. Task-number: QTBUG-50199 Change-Id: I3773729a9c757e2d2fcc5100dcd79f0ed26cb808 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 6 +++--- src/gui/kernel/qevent.h | 2 ++ src/gui/kernel/qwindowsysteminterface.h | 12 ++++++++++-- src/gui/kernel/qwindowsysteminterface_p.h | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 4f368e1db3..8abec2b05e 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -727,7 +727,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons), - ph(Qt::ScrollUpdate), src(Qt::MouseEventNotSynthesized) + ph(Qt::NoScrollPhase), src(Qt::MouseEventNotSynthesized) { g = QCursor::pos(); if (orient == Qt::Vertical) @@ -762,7 +762,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons), - ph(Qt::ScrollUpdate), src(Qt::MouseEventNotSynthesized) + ph(Qt::NoScrollPhase), src(Qt::MouseEventNotSynthesized) { if (orient == Qt::Vertical) angleD = QPoint(0, delta); @@ -798,7 +798,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::ScrollUpdate), + angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::NoScrollPhase), src(Qt::MouseEventNotSynthesized) {} diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index ed2deda9a0..b407663338 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -219,6 +219,8 @@ protected: uint ph : 2; uint src: 2; int reserved : 28; + + friend class QApplication; }; #endif diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index a27c68649e..20d560f82e 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -94,8 +94,16 @@ public: quint32 nativeModifiers, const QString& text = QString(), bool autorep = false, ushort count = 1, bool tryShortcutOverride = true); - static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::ScrollPhase phase = Qt::ScrollUpdate, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); - static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::ScrollPhase phase = Qt::ScrollUpdate, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, + QPoint pixelDelta, QPoint angleDelta, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::ScrollPhase phase = Qt::NoScrollPhase, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, + QPoint pixelDelta, QPoint angleDelta, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::ScrollPhase phase = Qt::NoScrollPhase, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); // Wheel event compatibility functions. Will be removed: do not use. static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier); diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index e48d1e965b..c2569f29cd 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -236,7 +236,7 @@ public: class WheelEvent : public InputEvent { public: WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O, - Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::ScrollUpdate, Qt::MouseEventSource src = Qt::MouseEventNotSynthesized) + Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::NoScrollPhase, Qt::MouseEventSource src = Qt::MouseEventNotSynthesized) : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase), source(src) { } QPoint pixelDelta; QPoint angleDelta; -- cgit v1.2.3