diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qinputmethod.cpp | 40 | ||||
-rw-r--r-- | src/gui/kernel/qinputmethod.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qplatforminputcontext.cpp | 27 | ||||
-rw-r--r-- | src/gui/kernel/qplatforminputcontext.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglengineshadermanager.cpp | 15 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 7 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 14 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtextoption.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextoption.h | 1 |
15 files changed, 116 insertions, 33 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index c97d3bb61a..9f566213bc 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2300,9 +2300,17 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt, e->tangentialPressure, e->rotation, e->z, e->modifiers, e->uid, button, e->buttons); + ev.setAccepted(false); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &ev); pointData.state = e->buttons; + if (!ev.isAccepted() && !QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse + && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents)) { + QWindowSystemInterfacePrivate::MouseEvent fake(window, e->timestamp, e->local, e->global, + e->buttons, e->modifiers, Qt::MouseEventSynthesizedByQt); + fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; + processMouseEvent(&fake); + } #else Q_UNUSED(e) #endif diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp index ca988f2523..b81e166d3a 100644 --- a/src/gui/kernel/qinputmethod.cpp +++ b/src/gui/kernel/qinputmethod.cpp @@ -97,6 +97,7 @@ void QInputMethod::setInputItemTransform(const QTransform &transform) d->inputItemTransform = transform; emit cursorRectangleChanged(); + emit anchorRectangleChanged(); } @@ -126,6 +127,19 @@ void QInputMethod::setInputItemRectangle(const QRectF &rect) d->inputRectangle = rect; } +static QRectF inputMethodQueryRectangle_helper(Qt::InputMethodQuery imquery, const QTransform &xform) +{ + QRectF r; + if (QObject *focusObject = qGuiApp->focusObject()) { + QInputMethodQueryEvent query(imquery); + QGuiApplication::sendEvent(focusObject, &query); + r = query.value(imquery).toRectF(); + if (r.isValid()) + r = xform.mapRect(r); + } + return r; +} + /*! \property QInputMethod::cursorRectangle \brief Input item's cursor rectangle in window coordinates. @@ -136,18 +150,20 @@ void QInputMethod::setInputItemRectangle(const QRectF &rect) QRectF QInputMethod::cursorRectangle() const { Q_D(const QInputMethod); + return inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform); +} - QObject *focusObject = qGuiApp->focusObject(); - if (!focusObject) - return QRectF(); - - QInputMethodQueryEvent query(Qt::ImCursorRectangle); - QGuiApplication::sendEvent(focusObject, &query); - QRectF r = query.value(Qt::ImCursorRectangle).toRectF(); - if (!r.isValid()) - return QRectF(); +/*! + \property QInputMethod::anchorRectangle + \brief Input item's anchor rectangle in window coordinates. - return d->inputItemTransform.mapRect(r); + Anchor rectangle is often used by various text editing controls + like text prediction popups for following the text selection. +*/ +QRectF QInputMethod::anchorRectangle() const +{ + Q_D(const QInputMethod); + return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform); } /*! @@ -300,6 +316,10 @@ void QInputMethod::update(Qt::InputMethodQueries queries) if (queries & Qt::ImCursorRectangle) emit cursorRectangleChanged(); + + if (queries & (Qt::ImAnchorRectangle)) + emit anchorRectangleChanged(); + } /*! diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h index 68dc679d14..22e4677eaa 100644 --- a/src/gui/kernel/qinputmethod.h +++ b/src/gui/kernel/qinputmethod.h @@ -55,6 +55,7 @@ class Q_GUI_EXPORT QInputMethod : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QInputMethod) Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) + Q_PROPERTY(QRectF anchorRectangle READ anchorRectangle NOTIFY anchorRectangleChanged) Q_PROPERTY(QRectF keyboardRectangle READ keyboardRectangle NOTIFY keyboardRectangleChanged) Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) Q_PROPERTY(bool animating READ isAnimating NOTIFY animatingChanged) @@ -70,6 +71,7 @@ public: // in window coordinates QRectF cursorRectangle() const; // ### what if we have rotations for the item? + QRectF anchorRectangle() const; // ### ditto // keyboard geometry in window coords QRectF keyboardRectangle() const; @@ -102,6 +104,7 @@ public Q_SLOTS: Q_SIGNALS: void cursorRectangleChanged(); + void anchorRectangleChanged(); void keyboardRectangleChanged(); void visibleChanged(); void animatingChanged(); diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 81c0971ea0..59bf2bb065 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -516,8 +516,10 @@ void QOpenGLContext::setScreen(QScreen *screen) void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object) { Q_Q(QOpenGLContext); - if (object == static_cast<QObject *>(screen)) + if (object == static_cast<QObject *>(screen)) { + screen = 0; q->setScreen(0); + } } /*! diff --git a/src/gui/kernel/qplatforminputcontext.cpp b/src/gui/kernel/qplatforminputcontext.cpp index bad6422cb8..3f59116e9a 100644 --- a/src/gui/kernel/qplatforminputcontext.cpp +++ b/src/gui/kernel/qplatforminputcontext.cpp @@ -43,6 +43,8 @@ #include "private/qkeymapper_p.h" #include <qpa/qplatforminputcontext_p.h> +#include <QtGui/qtransform.h> + QT_BEGIN_NAMESPACE /*! @@ -267,5 +269,30 @@ void QPlatformInputContextPrivate::setInputMethodAccepted(bool accepted) QPlatformInputContextPrivate::s_inputMethodAccepted = accepted; } +/*! + * \brief QPlatformInputContext::setSelectionOnFocusObject + * \param anchorPos Beginning of selection in currently active window coordinates + * \param cursorPos End of selection in currently active window coordinates + */ +void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos) +{ + QObject *focus = qApp->focusObject(); + if (!focus) + return; + + QInputMethod *im = QGuiApplication::inputMethod(); + const QTransform mapToLocal = im->inputItemTransform().inverted(); + bool success; + int anchor = QInputMethod::queryFocusObject(Qt::ImCursorPosition, anchorPos * mapToLocal).toInt(&success); + if (success) { + int cursor = QInputMethod::queryFocusObject(Qt::ImCursorPosition, cursorPos * mapToLocal).toInt(&success); + if (success) { + QList<QInputMethodEvent::Attribute> imAttributes; + imAttributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, anchor, cursor - anchor, QVariant())); + QInputMethodEvent event(QString(), imAttributes); + QGuiApplication::sendEvent(focus, &event); + } + } +} QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h index 24c6178541..7afa6b82f2 100644 --- a/src/gui/kernel/qplatforminputcontext.h +++ b/src/gui/kernel/qplatforminputcontext.h @@ -95,6 +95,8 @@ public: virtual void setFocusObject(QObject *object); bool inputMethodAccepted() const; + static void setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos); + private: friend class QGuiApplication; friend class QGuiApplicationPrivate; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index abcd6c113b..60b2706d35 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE QElapsedTimer QWindowSystemInterfacePrivate::eventTime; bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false; +bool QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse = true; QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed; QMutex QWindowSystemInterfacePrivate::flushEventMutex; QAtomicInt QWindowSystemInterfacePrivate::eventAccepted; @@ -948,4 +949,9 @@ QWindowSystemInterfacePrivate::WheelEvent::WheelEvent(QWindow *w, ulong time, co { } +void QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(bool v) +{ + platformSynthesizesMouse = v; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 3ccf815c54..b218c1c68c 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -352,6 +352,7 @@ public: int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, qint64 uid, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static void setPlatformSynthesizesMouse(bool v); TabletEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, int device, int pointerType, Qt::MouseButtons b, qreal pressure, int xTilt, int yTilt, qreal tpressure, @@ -372,6 +373,7 @@ public: qreal rotation; int z; qint64 uid; + static bool platformSynthesizesMouse; }; class TabletEnterProximityEvent : public InputEvent { diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp index 1bcb1c6760..4e3d14ba37 100644 --- a/src/gui/opengl/qopenglengineshadermanager.cpp +++ b/src/gui/opengl/qopenglengineshadermanager.cpp @@ -45,6 +45,8 @@ #include <QtGui/private/qopenglcontext_p.h> #include <QtCore/qthreadstorage.h> +#include <algorithm> + #if defined(QT_DEBUG) #include <QMetaEnum> #endif @@ -475,15 +477,16 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO void QOpenGLEngineSharedShaders::cleanupCustomStage(QOpenGLCustomShaderStage* stage) { - // Remove any shader programs which has this as the custom shader src: - for (int i = 0; i < cachedPrograms.size(); ++i) { - QOpenGLEngineShaderProg *cachedProg = cachedPrograms[i]; + auto hasStageAsCustomShaderSouce = [stage](QOpenGLEngineShaderProg *cachedProg) -> bool { if (cachedProg->customStageSource == stage->source()) { delete cachedProg; - cachedPrograms.removeAt(i); - i--; + return true; } - } + return false; + }; + cachedPrograms.erase(std::remove_if(cachedPrograms.begin(), cachedPrograms.end(), + hasStageAsCustomShaderSouce), + cachedPrograms.end()); } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 00dc4ccb81..d3b4acbbcd 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1693,8 +1693,12 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) // ### Optimize for non transformed ellipses and rectangles... QRectF cpRect = path.controlPointRect(); - const QRect deviceRect = s->matrix.mapRect(cpRect).toRect(); - ProcessSpans blend = d->getBrushFunc(deviceRect, &s->brushData); + const QRect pathDeviceRect = s->matrix.mapRect(cpRect).toRect(); + // Skip paths that by conservative estimates are completely outside the paint device. + if (!pathDeviceRect.intersects(d->deviceRect)) + return; + + ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData); // ### Falcon // const bool do_clip = (deviceRect.left() < -QT_RASTER_COORD_LIMIT @@ -3893,7 +3897,7 @@ void QClipData::setClipRect(const QRect &rect) void QClipData::setClipRegion(const QRegion ®ion) { if (region.rectCount() == 1) { - setClipRect(*region.begin()); + setClipRect(region.boundingRect()); return; } diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 86f176bc99..02f9be197f 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1561,6 +1561,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) int toUnicode = requestObject(); QFontEngine::Properties properties = font->fontEngine->properties(); + QByteArray postscriptName = properties.postscriptName.replace(' ', '_'); { qreal scale = 1000/properties.emSquare.toReal(); @@ -1574,7 +1575,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) s << (char)('A' + (tag % 26)); tag /= 26; } - s << '+' << properties.postscriptName << "\n" + s << '+' << postscriptName << "\n" "/Flags " << 4 << "\n" "/FontBBox [" << properties.boundingBox.x()*scale @@ -1617,7 +1618,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) QPdf::ByteStream s(&cid); s << "<< /Type /Font\n" "/Subtype /CIDFontType2\n" - "/BaseFont /" << properties.postscriptName << "\n" + "/BaseFont /" << postscriptName << "\n" "/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>\n" "/FontDescriptor " << fontDescriptor << "0 R\n" "/CIDToGIDMap /Identity\n" @@ -1641,7 +1642,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font) QPdf::ByteStream s(&font); s << "<< /Type /Font\n" "/Subtype /Type0\n" - "/BaseFont /" << properties.postscriptName << "\n" + "/BaseFont /" << postscriptName << "\n" "/Encoding /Identity-H\n" "/DescendantFonts [" << cidfont << "0 R]\n" "/ToUnicode " << toUnicode << "0 R" diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index a8b57d6dfd..1b2113d281 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2901,14 +2901,12 @@ static void markFrames(QTextFrame *current, int from, int oldLength, int length) return; QTextFrameData *fd = data(current); - for (int i = 0; i < fd->floats.size(); ++i) { - QTextFrame *f = fd->floats[i]; - if (!f) { - // float got removed in editing operation - fd->floats.removeAt(i); - --i; - } - } + // float got removed in editing operation + QTextFrame *null = nullptr; // work-around for (at least) MSVC 2012 emitting + // warning C4100 for its own header <algorithm> + // when passing nullptr directly to std::remove + fd->floats.erase(std::remove(fd->floats.begin(), fd->floats.end(), null), + fd->floats.end()); fd->layoutDirty = true; fd->sizeDirty = true; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 8e03797080..e65ec15caa 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1569,8 +1569,12 @@ void QTextEngine::validate() const layoutData = new LayoutData(); if (block.docHandle()) { layoutData->string = block.text(); - if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) - layoutData->string += QLatin1Char(block.next().isValid() ? 0xb6 : 0xA7); + if (block.next().isValid()) { + if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) + layoutData->string += QChar(0xb6); + } else if (option.flags() & QTextOption::ShowDocumentTerminator) { + layoutData->string += QChar(0xA7); + } } else { layoutData->string = text; } diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 2eb025f412..87e31eeb2c 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -309,6 +309,8 @@ QList<QTextOption::Tab> QTextOption::tabs() const this width is excluded. \value ShowTabsAndSpaces Visualize spaces with little dots, and tabs with little arrows. \value ShowLineAndParagraphSeparators Visualize line and paragraph separators with appropriate symbol characters. + \value ShowDocumentTerminator Visualize the end of the document with a section sign. This enum value was added + in Qt 5.7. \value AddSpaceForLineAndParagraphSeparators While determining the line-break positions take into account the space added for drawing a separator character. \value SuppressColors Suppress all color changes in the character formats (except the main selection). diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h index 2ae0ec3d4c..f9c24ffeaf 100644 --- a/src/gui/text/qtextoption.h +++ b/src/gui/text/qtextoption.h @@ -109,6 +109,7 @@ public: ShowLineAndParagraphSeparators = 0x2, AddSpaceForLineAndParagraphSeparators = 0x4, SuppressColors = 0x8, + ShowDocumentTerminator = 0x10, IncludeTrailingSpaces = 0x80000000 }; Q_DECLARE_FLAGS(Flags, Flag) |