From 7db9e02ad11c391c1d616defd11e7deb2718d60a Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 23 Apr 2019 09:12:30 +1000 Subject: wasm: don't propagate touch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-75263 Change-Id: I099f76114f876b3d6d81df3efb94db126db6a806 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index f4ca49997a..c5c12e9f87 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -776,7 +776,7 @@ int QWasmEventTranslator::handleTouch(int eventType, const EmscriptenTouchEvent QWindowSystemInterface::handleTouchCancelEvent(window2, getTimestamp(), touchDevice, keyModifier); QWasmEventDispatcher::maintainTimers(); - return 0; + return 1; } quint64 QWasmEventTranslator::getTimestamp() -- cgit v1.2.3 From 1d128ed1dfbcf49453ada922e54381c37264fde5 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 23 Apr 2019 16:30:15 +0200 Subject: Fix artifacts when reading certain 32 bit ico files Images in an ico file contains transparency information stored as a 1 bit mask. However, when the depth is 32 bit, it means there is an alpha channel present, and the mask should be ignored. The Qt ico handler failed to do that. This has gone unnoticed, since the mask in such images is typically set to all 0s, and so makes no difference to the result. But ico files exist that contain junk mask data, so fix the reader to ignore it properly. Fixes: QTBUG-75214 Change-Id: I1b4456d71689ec783076a582f2fb215e7dc56e62 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/imageformats/ico/qicohandler.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 30935cacda..4908850cc5 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -523,17 +523,21 @@ QImage ICOReader::iconAt(int index) if (!image.isNull()) { readBMP(image); if (!image.isNull()) { - QImage mask(image.width(), image.height(), QImage::Format_Mono); - if (!mask.isNull()) { - mask.setColorCount(2); - mask.setColor(0, qRgba(255,255,255,0xff)); - mask.setColor(1, qRgba(0 ,0 ,0 ,0xff)); - read1BitBMP(mask); + if (icoAttrib.depth == 32) { + img = std::move(image).convertToFormat(QImage::Format_ARGB32_Premultiplied); + } else { + QImage mask(image.width(), image.height(), QImage::Format_Mono); if (!mask.isNull()) { - img = image; - img.setAlphaChannel(mask); - // (Luckily, it seems that setAlphaChannel() does not ruin the alpha values - // of partially transparent pixels in those icons that have that) + mask.setColorCount(2); + mask.setColor(0, qRgba(255,255,255,0xff)); + mask.setColor(1, qRgba(0 ,0 ,0 ,0xff)); + read1BitBMP(mask); + if (!mask.isNull()) { + img = image; + img.setAlphaChannel(mask); + // (Luckily, it seems that setAlphaChannel() does not ruin the alpha values + // of partially transparent pixels in those icons that have that) + } } } } -- cgit v1.2.3 From 913dd26c92f406e3da83ed83701ce47e659bcc48 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 12 Apr 2019 12:21:52 +0200 Subject: QMacStyle - set the proper appearance if needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, AppKit, while rendering 'detached' (not in any view hierarchy) controls and cells will use NSAppearance.currentAppearance, which is not guaranteed to be the same as NSApplication.effectiveAppearance. Task-number: QTBUG-74515 Change-Id: I82dcebf2230932ecfcbf33c422a3b7bd0aed61d7 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 847b1a6034..2a6f212569 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -447,6 +447,42 @@ static const int toolButtonArrowMargin = 2; static const qreal focusRingWidth = 3.5; +// An application can force 'Aqua' theme while the system theme is one of +// the 'Dark' variants. Since in Qt we sometimes use NSControls and even +// NSCells directly without attaching them to any view hierarchy, we have +// to set NSAppearance.currentAppearance to 'Aqua' manually, to make sure +// the correct rendering path is triggered. Apple recommends us to un-set +// the current appearance back after we finished with drawing. This is what +// AppearanceSync is for. + +class AppearanceSync { +public: + AppearanceSync() + { +#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSMojave + && !qt_mac_applicationIsInDarkMode()) { + auto requiredAppearanceName = NSApplication.sharedApplication.effectiveAppearance.name; + if (![NSAppearance.currentAppearance.name isEqualToString:requiredAppearanceName]) { + previous = NSAppearance.currentAppearance; + NSAppearance.currentAppearance = [NSAppearance appearanceNamed:requiredAppearanceName]; + } + } +#endif // QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) + } + + ~AppearanceSync() + { + if (previous) + NSAppearance.currentAppearance = previous; + } + +private: + NSAppearance *previous = nil; + + Q_DISABLE_COPY(AppearanceSync) +}; + static bool setupScroller(NSScroller *scroller, const QStyleOptionSlider *sb) { const qreal length = sb->maximum - sb->minimum + sb->pageStep; @@ -2918,6 +2954,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai const QWidget *w) const { Q_D(const QMacStyle); + const AppearanceSync appSync; QMacCGContext cg(p); QWindow *window = w && w->window() ? w->window()->windowHandle() : nullptr; d->resolveCurrentNSView(window); @@ -3443,6 +3480,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const QWidget *w) const { Q_D(const QMacStyle); + const AppearanceSync sync; QMacCGContext cg(p); QWindow *window = w && w->window() ? w->window()->windowHandle() : nullptr; d->resolveCurrentNSView(window); @@ -5033,6 +5071,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex const QWidget *widget) const { Q_D(const QMacStyle); + const AppearanceSync sync; QMacCGContext cg(p); QWindow *window = widget && widget->window() ? widget->window()->windowHandle() : nullptr; d->resolveCurrentNSView(window); -- cgit v1.2.3 From d6e65ecac5852ed09fbf580b3fab5b21125dfd69 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 15 Mar 2019 11:56:01 +0100 Subject: platforminputcontexts: future-proof compose plugin If this plugin is loaded at some later point during application run-time, the focus object might be nullptr. We can avoid that by using qApp->focusObject(), when m_focusObject==nullptr; Task-number: QTBUG-74465 Change-Id: I0d82410ed557ea1a8fde28a1807f790854951cda Reviewed-by: Johan Helsing --- .../compose/qcomposeplatforminputcontext.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp index 57fe7c2fa2..4e9828663f 100644 --- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp @@ -40,6 +40,7 @@ #include #include +#include #include @@ -121,7 +122,14 @@ bool QComposeInputContext::filterEvent(const QEvent *event) QInputMethodEvent event; event.setCommitString(composedText); - QCoreApplication::sendEvent(m_focusObject, &event); + + if (!m_focusObject && qApp) + m_focusObject = qApp->focusObject(); + + if (m_focusObject) + QCoreApplication::sendEvent(m_focusObject, &event); + else + qCWarning(lcXkbCompose, "no focus object"); reset(); return true; -- cgit v1.2.3