From 0e69230d02813f0b7a050645fb7e443bd504ab6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Mon, 13 Jan 2014 14:29:16 +0100 Subject: Revert "QAIV - Fix scollbars with ScrollPerPixel to scroll 1 pixel." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 934f06220391eb0e0ebf66a2eb037f48adb4c43c. The patch needs to be modified a bit. Many users considers not having the old feature as a big regression. The feature needs to be improved with a variable that is only set when the user uses setSingleStep. Task-number: QTBUG-33906 Change-Id: I35e5d3e9d3d7a3ebd01807b03a0e7a424185d483 Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qlistview.cpp | 8 ++++---- src/widgets/itemviews/qtableview.cpp | 4 ++-- src/widgets/itemviews/qtreeview.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 0cca52daa2..7f7c60b10e 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1837,18 +1837,18 @@ void QCommonListViewBase::paintDragDrop(QPainter *painter) } #endif -void QCommonListViewBase::updateHorizontalScrollBar(const QSize & /*step*/) +void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) { + horizontalScrollBar()->setSingleStep(step.width() + spacing()); horizontalScrollBar()->setPageStep(viewport()->width()); horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width()); - // we do not want to overwrite (a possible user set) single step } -void QCommonListViewBase::updateVerticalScrollBar(const QSize & /*step*/) +void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) { + verticalScrollBar()->setSingleStep(step.height() + spacing()); verticalScrollBar()->setPageStep(viewport()->height()); verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height()); - // we do not want to overwrite (a possible user set) single step } void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/) diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 08600b3ef7..a252428a81 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -2170,7 +2170,7 @@ void QTableView::updateGeometries() } else { // ScrollPerPixel horizontalScrollBar()->setPageStep(vsize.width()); horizontalScrollBar()->setRange(0, horizontalLength - vsize.width()); - // here we do not want to overwrite (a possible user set) single step + horizontalScrollBar()->setSingleStep(qMax(vsize.width() / (columnsInViewport + 1), 2)); } // vertical scroll bar @@ -2198,7 +2198,7 @@ void QTableView::updateGeometries() } else { // ScrollPerPixel verticalScrollBar()->setPageStep(vsize.height()); verticalScrollBar()->setRange(0, verticalLength - vsize.height()); - // here we do not want to overwrite (a possible user set) single step + verticalScrollBar()->setSingleStep(qMax(vsize.height() / (rowsInViewport + 1), 2)); } d->geometryRecursionBlock = false; diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 4d0eb5c3ad..5d0e835b0e 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3685,7 +3685,7 @@ void QTreeViewPrivate::updateScrollBars() } vbar->setRange(0, contentsHeight - viewportSize.height()); vbar->setPageStep(viewportSize.height()); - // here we do not want to overwrite (a possible user set) single step + vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2)); } const int columnCount = header->count(); @@ -3711,7 +3711,7 @@ void QTreeViewPrivate::updateScrollBars() viewportSize = maxSize; hbar->setPageStep(viewportSize.width()); hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0)); - // here we do not want to overwrite (a possible user set) single step + hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2)); } } -- cgit v1.2.3 From 6eeab0b0e19818815dffb1ff603bc84aac3ffcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:15:38 +0100 Subject: Remove Mac unified toolbar workarounds. QMainWindow::unifiedTitleAndToolBarOnMac() will again return true, but the new implementation is much more similar to the cross platform one so these workarounds are not needed. Task-number: QTBUG-34411 Change-Id: I8f63067f929c94aab252fc2e88f98fb94c870c44 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qtoolbararealayout.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 04ef6a80be..5ec76569aa 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -655,9 +655,7 @@ QRect QToolBarAreaLayout::fitLayout() docks[QInternal::BottomDock].rect = QRect(rect.left(), center.bottom() + 1, rect.width(), bottom_hint.height()); - if (!mainWindow->unifiedTitleAndToolBarOnMac()) { - docks[QInternal::TopDock].fitLayout(); - } + docks[QInternal::TopDock].fitLayout(); docks[QInternal::LeftDock].fitLayout(); docks[QInternal::RightDock].fitLayout(); docks[QInternal::BottomDock].fitLayout(); @@ -1307,8 +1305,6 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList toolBars = _toolBars; int lines; stream >> lines; - if (!testing) - testing = mainWindow->unifiedTitleAndToolBarOnMac(); for (int j = 0; j < lines; ++j) { int pos; @@ -1319,7 +1315,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList> cnt; QToolBarAreaLayoutInfo &dock = docks[pos]; - const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac()); + const bool applyingLayout = !testing; QToolBarAreaLayoutLine line(dock.o); for (int k = 0; k < cnt; ++k) { -- cgit v1.2.3 From 7edb5f22bf78cf2691145ab4160998c7b7f9416a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:21:43 +0100 Subject: Implement QMainWindow::setUnifiedTitleAndToolBarOnMac Fix a feature regression from Qt 4. Unlike the Qt 4 implementation this does not move the tool bars out of the QMainWindow while pretending they are still there. Instead, use setContentBorderThickness from the Cocoa platform plugin to draw a background gradient that unifies the title and toolbar area. QToolBar can then draw itself with a transparent background and let the gradient shine throughout. This is a style-only change, toolbar behavior is kept as-is. [ChangeLog][Platform Specific Changes][OS X] Implemented QMainWindow::setUnifiedTitleAndToolBarOnMac. Task-number: QTBUG-34411 Change-Id: Idcaab6399f249b11edb1147856d9aece9923ab36 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmainwindow.cpp | 43 ++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 0638981a9c..07db78c06c 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -60,6 +60,9 @@ #include #include "qtoolbar_p.h" #include "qwidgetanimator_p.h" +#ifdef Q_OS_OSX +#include +#endif #ifdef Q_WS_MAC #include #include @@ -76,6 +79,9 @@ class QMainWindowPrivate : public QWidgetPrivate public: inline QMainWindowPrivate() : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) +#ifdef Q_OS_OSX + , useUnifiedToolBar(false) +#endif #ifdef Q_WS_MAC , useHIToolBar(false) , activateUnifiedToolbarAfterFullScreen(false) @@ -88,6 +94,9 @@ public: QSize iconSize; bool explicitIconSize; Qt::ToolButtonStyle toolButtonStyle; +#ifdef Q_OS_OSX + bool useUnifiedToolBar; +#endif #ifdef Q_WS_MAC bool useHIToolBar; bool activateUnifiedToolbarAfterFullScreen; @@ -1492,16 +1501,29 @@ bool QMainWindow::event(QEvent *event) /*! \property QMainWindow::unifiedTitleAndToolBarOnMac \brief whether the window uses the unified title and toolbar look on Mac OS X - \since 4.3 - \obsolete - - This property is not implemented in Qt 5. Setting it has no effect. - - A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras at - http://qt.gitorious.org/qtplayground/qtmacextras + \since 5.2 */ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) { +#ifdef Q_OS_OSX + Q_D(QMainWindow); + if (isWindow()) { + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + QPlatformNativeInterface::NativeResourceForIntegrationFunction function = + nativeInterface->nativeResourceFunctionForIntegration("setContentBorderThickness"); + if (!function) + return; // Not Cocoa platform plugin. + + createWinId(); + + d->useUnifiedToolBar = set; + + const int toolBarHeight = 50; + typedef void (*SetContentBorderThicknessFunction)(QWindow *window, int topThickness, int bottomThickness); + (reinterpret_cast(function))(window()->windowHandle(), toolBarHeight, 0); + } +#endif + #ifdef Q_WS_MAC Q_D(QMainWindow); if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) @@ -1534,6 +1556,9 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) bool QMainWindow::unifiedTitleAndToolBarOnMac() const { +#ifdef Q_OS_OSX + return d_func()->useUnifiedToolBar; +#endif #ifdef Q_WS_MAC return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); #endif @@ -1655,9 +1680,7 @@ QMenu *QMainWindow::createPopupMenu() for (int i = 0; i < toolbars.size(); ++i) { QToolBar *toolBar = toolbars.at(i); if (toolBar->parentWidget() == this - && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty() - || (unifiedTitleAndToolBarOnMac() - && toolBarArea(toolBar) == Qt::TopToolBarArea))) { + && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty())) { menu->addAction(toolbars.at(i)->toggleViewAction()); } } -- cgit v1.2.3 From 6cbbd1f93d369059e16c62f4b8ba60ad3407d886 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 14 Jan 2014 13:10:09 +0100 Subject: Cocoa: Popups should not become key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... at least not like that. We still need to find a way for the popup to receive and process key events on its own, instead of depending on other layers inside Qt. This would make Qt Quick control's PopupWindow implementation much simpler, for example. Revert "Cocoa: Allow popups to grab mouse and keyboard" This reverts commit a25e6528d3806d3b5fd87c5a1cacd6c748215db1. Task-number: QTBUG-35820 Task-number: QTBUG-35904 Change-Id: Ica10529308ab25938397c16b9c1e1ce6cbd8f247 Reviewed-by: Gabriel de Dietrich Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 - src/plugins/platforms/cocoa/qcocoawindow.mm | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 66c3241b3d..452be90108 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -211,7 +211,6 @@ public: // for QNSView QRect m_exposedGeometry; int m_registerTouchCount; bool m_resizableTransientParent; - bool m_overrideBecomeKey; static const int NoAlertRequest; NSInteger m_alertRequest; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8e977236fa..56665719e8 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -160,9 +160,7 @@ static bool isMouseEvent(NSEvent *ev) // Only tool or dialog windows should become key: if (m_cocoaPlatformWindow - && (m_cocoaPlatformWindow->m_overrideBecomeKey || - m_cocoaPlatformWindow->window()->type() == Qt::Tool || - m_cocoaPlatformWindow->window()->type() == Qt::Dialog)) + && (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog)) return YES; return NO; } @@ -217,7 +215,6 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_isExposed(false) , m_registerTouchCount(0) , m_resizableTransientParent(false) - , m_overrideBecomeKey(false) , m_alertRequest(NoAlertRequest) , monitor(nil) , m_drawContentBorderGradient(false) @@ -705,8 +702,6 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) if (!m_nsWindow) return false; - m_overrideBecomeKey = grab; - if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; else if (!grab && [m_nsWindow isKeyWindow]) @@ -719,8 +714,6 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab) if (!m_nsWindow) return false; - m_overrideBecomeKey = grab; - if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; else if (!grab && [m_nsWindow isKeyWindow]) -- cgit v1.2.3 From 2565ef220b9f261fc2d62869b8d38625e41bc6fd Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 14 Jan 2014 09:34:47 +0100 Subject: Revert "Cocoa: fix single punctuation input via CJK input method" This change makes a regression. This reverts commit a79f8a3a6774875fc16fd63461e04c2791a8d03d. Task-number: QTBUG-36033 Change-Id: Ibcb19cd8631f85c81433c9625bbbf280404db1c4 Reviewed-by: Jens Bache-Wiig --- src/plugins/platforms/cocoa/qnsview.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f7b129aea1..ecb6c127aa 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1346,6 +1346,11 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) { Q_UNUSED(replacementRange) + if (m_sendKeyEvent && m_composingText.isEmpty()) { + // don't send input method events for simple text input (let handleKeyEvent send key events instead) + return; + } + QString commitString; if ([aString length]) { if ([aString isKindOfClass:[NSAttributedString class]]) { -- cgit v1.2.3 From 84be1bd4d3ed8d2d9e65301649bc841ea4197fe2 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 14 Jan 2014 18:27:33 +0200 Subject: Fix crash due to a stale pointer dereferencing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The HB face caching mechanism introduced in 227e9a40cfeb7e00658cd3 wasn't complete due that fact that HB-NG doesn't parse the entire font table at once but rather references a table on-demand. This incompleteness caused a crash in case the engine doesn't get cached or when it removed from the cache and then re-used. Task-number: QTBUG-36099 Change-Id: I7816836107655ce7cf6eb9683bb5dc7f892f9cd1 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Michael Krasnyk Reviewed-by: Lars Knoll Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfontengine.cpp | 13 ++++++++++++- src/gui/text/qfontengine_ft.cpp | 29 +++++++++++++++++++---------- src/gui/text/qfontengine_p.h | 5 +++++ src/gui/text/qharfbuzzng.cpp | 22 +++++++++++++++------- 4 files changed, 51 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 303c85ce75..9eea2e786f 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -171,7 +171,8 @@ static const HB_FontClass hb_fontClass = { static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB_UInt *length) { QFontEngine *fe = (QFontEngine *)font; - if (!fe->getSfntTableData(tableTag, buffer, length)) + Q_ASSERT(fe->faceData.get_font_table); + if (!fe->faceData.get_font_table(fe->faceData.user_data, tableTag, buffer, length)) return HB_Err_Invalid_Argument; return HB_Err_Ok; } @@ -182,6 +183,13 @@ static void hb_freeFace(void *face) } +static bool qt_get_font_table_default(void *user_data, uint tag, uchar *buffer, uint *length) +{ + QFontEngine *fe = (QFontEngine *)user_data; + return fe->getSfntTableData(tag, buffer, length); +} + + #ifdef QT_BUILD_INTERNAL // for testing purpose only, not thread-safe! static QList *enginesCollector = 0; @@ -210,6 +218,9 @@ QFontEngine::QFontEngine() font_(0), font_destroy_func(0), face_(0), face_destroy_func(0) { + faceData.user_data = this; + faceData.get_font_table = qt_get_font_table_default; + cache_cost = 0; fsType = 0; symbol = false; diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 42cf15ee3b..05bd014bd7 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -116,6 +116,21 @@ QT_BEGIN_NAMESPACE #define TRUNC(x) ((x) >> 6) #define ROUND(x) (((x)+32) & -64) +static bool ft_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length) +{ + FT_Face face = (FT_Face)user_data; + + bool result = false; + if (FT_IS_SFNT(face)) { + FT_ULong len = *length; + result = FT_Load_Sfnt_Table(face, tag, 0, buffer, &len) == FT_Err_Ok; + *length = len; + } + + return result; +} + + // -------------------------- Freetype support ------------------------------ class QtFreetypeData @@ -408,15 +423,7 @@ QFontEngine::Properties QFreetypeFace::properties() const bool QFreetypeFace::getSfntTable(uint tag, uchar *buffer, uint *length) const { - bool result = false; -#if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) > 20103 - if (FT_IS_SFNT(face)) { - FT_ULong len = *length; - result = FT_Load_Sfnt_Table(face, tag, 0, buffer, &len) == FT_Err_Ok; - *length = len; - } -#endif - return result; + return ft_getSfntTable(face, tag, buffer, length); } /* Some fonts (such as MingLiu rely on hinting to scale different @@ -761,6 +768,8 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, fontDef.styleName = QString::fromUtf8(face->style_name); if (!freetype->hbFace) { + faceData.user_data = face; + faceData.get_font_table = ft_getSfntTable; freetype->hbFace = harfbuzzFace(); freetype->hbFace_destroy_func = face_destroy_func; } else { @@ -1179,7 +1188,7 @@ QFixed QFontEngineFT::emSquareSize() const bool QFontEngineFT::getSfntTableData(uint tag, uchar *buffer, uint *length) const { - return freetype->getSfntTable(tag, buffer, length); + return ft_getSfntTable(freetype->face, tag, buffer, length); } int QFontEngineFT::synthesized() const diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index c181d61d73..a04f4bd0ac 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -85,6 +85,7 @@ enum HB_Compat_Error { }; typedef void (*qt_destroy_func_t) (void *user_data); +typedef bool (*qt_get_font_table_func_t) (void *user_data, uint tag, uchar *buffer, uint *length); class Q_GUI_EXPORT QFontEngine { @@ -280,6 +281,10 @@ public: mutable qt_destroy_func_t font_destroy_func; mutable void *face_; mutable qt_destroy_func_t face_destroy_func; + struct FaceData { + void *user_data; + qt_get_font_table_func_t get_font_table; + } faceData; uint cache_cost; // amount of mem used in kb by the font uint fsType : 16; diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index b4ab5856df..d2e7df9c10 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -623,19 +623,22 @@ hb_font_funcs_t *hb_qt_get_font_funcs() static hb_blob_t * -_hb_qt_get_font_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) +_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) { - QFontEngine *fe = (QFontEngine *)user_data; - Q_ASSERT(fe); + QFontEngine::FaceData *data = (QFontEngine::FaceData *)user_data; + Q_ASSERT(data); + + qt_get_font_table_func_t get_font_table = data->get_font_table; + Q_ASSERT(get_font_table); uint length = 0; - if (Q_UNLIKELY(!fe->getSfntTableData(tag, 0, &length) || length == 0)) + if (Q_UNLIKELY(!get_font_table(data->user_data, tag, 0, &length) || length == 0)) return hb_blob_get_empty(); char *buffer = (char *)malloc(length); Q_CHECK_PTR(buffer); - if (Q_UNLIKELY(!fe->getSfntTableData(tag, reinterpret_cast(buffer), &length))) + if (Q_UNLIKELY(!get_font_table(data->user_data, tag, reinterpret_cast(buffer), &length))) length = 0; return hb_blob_create(const_cast(buffer), length, @@ -646,9 +649,14 @@ _hb_qt_get_font_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) static inline hb_face_t * _hb_qt_face_create(QFontEngine *fe) { - hb_face_t *face; + Q_ASSERT(fe); + + QFontEngine::FaceData *data = (QFontEngine::FaceData *)malloc(sizeof(QFontEngine::FaceData)); + Q_CHECK_PTR(data); + data->user_data = fe->faceData.user_data; + data->get_font_table = fe->faceData.get_font_table; - face = hb_face_create_for_tables(_hb_qt_get_font_table, (void *)fe, NULL); + hb_face_t *face = hb_face_create_for_tables(_hb_qt_reference_table, (void *)data, free); if (Q_UNLIKELY(hb_face_is_immutable(face))) { hb_face_destroy(face); return NULL; -- cgit v1.2.3 From 5dee237022e84a378468c3839e4e7af13cb1246d Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Wed, 15 Jan 2014 13:53:00 +0100 Subject: [QNX] Set Window usage Set Window usage prior to use the framebuffer. For OpenGL windows set OpenGL usage and for normal painting set it to native usage. Some QNX libscreen implementations don't set usage automatically, so we must set this explicitly. Task-number: QTBUG-35912 Change-Id: I5154c0bcf9c65ef6d47af6a1cf8f17765ccf51dd Reviewed-by: Fabian Bumberger Reviewed-by: Vladimir Minenko Reviewed-by: Giuseppe D'Angelo Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxeglwindow.cpp | 7 +++++++ src/plugins/platforms/qnx/qqnxrasterwindow.cpp | 6 ++++++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxeglwindow.cpp b/src/plugins/platforms/qnx/qqnxeglwindow.cpp index b57227a60b..984de67d7d 100644 --- a/src/plugins/platforms/qnx/qqnxeglwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxeglwindow.cpp @@ -63,6 +63,13 @@ QQnxEglWindow::QQnxEglWindow(QWindow *window, screen_context_t context, bool nee m_eglSurface(EGL_NO_SURFACE) { initWindow(); + + // Set window usage + const int val = SCREEN_USAGE_OPENGL_ES2; + const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); + if (result != 0) + qFatal("QQnxEglWindow: failed to set window alpha usage, errno=%d", errno); + m_requestedBufferSize = screen()->rootWindow() == this ? screen()->geometry().size() : window->geometry().size(); } diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index 1f974b268d..0d8daac0ee 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -60,6 +60,12 @@ QQnxRasterWindow::QQnxRasterWindow(QWindow *window, screen_context_t context, bo m_previousBufferIndex(-1) { initWindow(); + + // Set window usage + const int val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE; + const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); + if (result != 0) + qFatal("QQnxEglWindow: failed to set window alpha usage, errno=%d", errno); } void QQnxRasterWindow::post(const QRegion &dirty) -- cgit v1.2.3 From 0c09d2ccb9b46138a908950d65a49aa58dd55062 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 13 Jan 2014 11:12:34 +0100 Subject: Windows: Do not try to update keymap on WM_IME_CHAR messages Task-number: QTBUG-35806 Change-Id: Ie1082353155aa7ee61f49f2fbcbfdb01d57e797c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 1baea6faff..334df17026 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -743,10 +743,10 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd, return true; } - // WM_CHAR messages already contain the character in question so there is + // WM_(IME_)CHAR messages already contain the character in question so there is // no need to fiddle with our key map. In any other case add this key to the // keymap if it is not present yet. - if (msg.message != WM_CHAR) + if (msg.message != WM_CHAR && msg.message != WM_IME_CHAR) updateKeyMap(msg); MSG peekedMsg; -- cgit v1.2.3 From a19817082caa49309ba425e42f22637628f985d1 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Jan 2014 11:53:43 +0100 Subject: Use non-threaded render loop on Samsung Galaxy Tab 3 We get EGL_BAD_ACCESS from eglMakeCurrent() on this device, and only on this device, so we simply work around it by disabling the threaded render loop. [ChangeLog][Android] Add workarounds for OpenGL bugs on Samsung Galaxy Tab 3. Task-number: QTBUG-34984 Change-Id: I309881f8317473ff87aea2f92d0f6f1b898342d3 Reviewed-by: Gunnar Sletta --- src/plugins/platforms/android/src/androidjnimain.cpp | 10 +++++++++- src/plugins/platforms/android/src/androidjnimain.h | 1 + .../android/src/qandroidplatformintegration.cpp | 18 ++++++++++++++++++ .../android/src/qandroidplatformintegration.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp index 3064e5d4e2..6461fa4733 100644 --- a/src/plugins/platforms/android/src/androidjnimain.cpp +++ b/src/plugins/platforms/android/src/androidjnimain.cpp @@ -418,7 +418,15 @@ namespace QtAndroid { return m_qtTag; } -} + + QString deviceName() + { + QString manufacturer = QJNIObjectPrivate::getStaticObjectField("android/os/Build", "MANUFACTURER", "Ljava/lang/String;").toString(); + QString model = QJNIObjectPrivate::getStaticObjectField("android/os/Build", "MODEL", "Ljava/lang/String;").toString(); + + return manufacturer + QStringLiteral(" ") + model; + } +} // namespace QtAndroid static jboolean startQtAndroidPlugin(JNIEnv* /*env*/, jobject /*object*//*, jobject applicationAssetManager*/) { diff --git a/src/plugins/platforms/android/src/androidjnimain.h b/src/plugins/platforms/android/src/androidjnimain.h index 11d3573404..a7b7072ba3 100644 --- a/src/plugins/platforms/android/src/androidjnimain.h +++ b/src/plugins/platforms/android/src/androidjnimain.h @@ -120,5 +120,6 @@ namespace QtAndroid const char *methodErrorMsgFmt(); const char *qtTagText(); + QString deviceName(); } #endif // ANDROID_APP_H diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index ae3e257d3c..e09cc40e01 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -89,6 +89,10 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA return &m_palettes; if (resource == "AndroidStyleFonts") return &m_fonts; + if (resource == "AndroidDeviceName") { + static QString deviceName = QtAndroid::deviceName(); + return &deviceName; + } return 0; } @@ -119,12 +123,26 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidSystemLocale = new QAndroidSystemLocale; } +bool QAndroidPlatformIntegration::needsBasicRenderloopWorkaround() +{ + static bool needsWorkaround = + QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 + || QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0 + || QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0; + return needsWorkaround; +} + bool QAndroidPlatformIntegration::hasCapability(Capability cap) const { switch (cap) { case ThreadedPixmaps: return true; case ApplicationState: return true; case NativeWidgets: return false; + + case ThreadedOpenGL: + if (needsBasicRenderloopWorkaround()) + return false; + // fall through default: #ifndef ANDROID_PLUGIN_OPENGL return QPlatformIntegration::hasCapability(cap); diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index bd08ad694c..15a8ad33dd 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -146,6 +146,7 @@ public: #endif private: + static bool needsBasicRenderloopWorkaround(); friend class QEglFSAndroidHooks; -- cgit v1.2.3 From 09f54e99f2e956908f9104181e7d61fa2f6a027d Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 20 Jan 2014 09:56:24 +0100 Subject: Cocoa: avoid a crash for cursor in QCocoaWindow It need to be copied. Task-number: QTBUG-35887 Change-Id: Ia165e6a8f9dc23733e53e11f9e1e98bf54e7dd20 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 56665719e8..bf5e0cfbc4 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -264,6 +264,7 @@ QCocoaWindow::~QCocoaWindow() [m_contentView release]; [m_nsWindow release]; [m_nsWindowDelegate release]; + [m_windowCursor release]; } QSurfaceFormat QCocoaWindow::format() const @@ -1059,7 +1060,10 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor) [cursor set]; // or we can set the cursor on mouse enter/leave using tracking // areas. This is done in QNSView, save the cursor: - m_windowCursor = cursor; + if (m_windowCursor != cursor) { + [m_windowCursor release]; + m_windowCursor = [cursor retain]; + } } void QCocoaWindow::registerTouch(bool enable) -- cgit v1.2.3 From c2629632cf82be842a29493f87e6bdbd0b84a974 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 21 Jan 2014 10:23:38 +0100 Subject: Fix compilation of ANGLE with mingw-tdm64 gcc 4.8.1 Do not rely on sprintf_s being declared/defined. This also fixes deployment to Windows XP. See https://chromium-review.googlesource.com/#/c/182975/ for a similar commit proposed upstream. Task-number: QTBUG-36242 Change-Id: I520e2f61aeab34963e7a57baafd413c7db93f110 Reviewed-by: Friedemann Kleint --- src/3rdparty/angle/src/libEGL/Display.cpp | 2 +- ...ation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch (limited to 'src') diff --git a/src/3rdparty/angle/src/libEGL/Display.cpp b/src/3rdparty/angle/src/libEGL/Display.cpp index a382c3b1eb..82b48cedcf 100644 --- a/src/3rdparty/angle/src/libEGL/Display.cpp +++ b/src/3rdparty/angle/src/libEGL/Display.cpp @@ -523,7 +523,7 @@ void Display::initVendorString() if (mRenderer && mRenderer->getLUID(&adapterLuid)) { char adapterLuidString[64]; - sprintf_s(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08x%08x)", adapterLuid.HighPart, adapterLuid.LowPart); + snprintf(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08l%08l)", adapterLuid.HighPart, adapterLuid.LowPart); mVendorString += adapterLuidString; } diff --git a/src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch b/src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch new file mode 100644 index 0000000000..498cce1b7c --- /dev/null +++ b/src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch @@ -0,0 +1,33 @@ +From 58a797397378aff3aa039a8b2a2d7011fe788737 Mon Sep 17 00:00:00 2001 +From: Kai Koehne +Date: Tue, 21 Jan 2014 10:23:38 +0100 +Subject: [PATCH] Fix compilation of ANGLE with mingw-tdm64 gcc 4.8.1 + +Do not rely on sprintf_s being declared/defined. This also fixes +deployment to Windows XP. + +See https://chromium-review.googlesource.com/#/c/182975/ for a similar +commit proposed upstream. + +Task-number: QTBUG-36242 +Change-Id: I520e2f61aeab34963e7a57baafd413c7db93f110 +--- + src/3rdparty/angle/src/libEGL/Display.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/3rdparty/angle/src/libEGL/Display.cpp b/src/3rdparty/angle/src/libEGL/Display.cpp +index a382c3b..82b48ce 100644 +--- a/src/3rdparty/angle/src/libEGL/Display.cpp ++++ b/src/3rdparty/angle/src/libEGL/Display.cpp +@@ -523,7 +523,7 @@ void Display::initVendorString() + if (mRenderer && mRenderer->getLUID(&adapterLuid)) + { + char adapterLuidString[64]; +- sprintf_s(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08x%08x)", adapterLuid.HighPart, adapterLuid.LowPart); ++ snprintf(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08l%08l)", adapterLuid.HighPart, adapterLuid.LowPart); + + mVendorString += adapterLuidString; + } +-- +1.8.5.2.msysgit.0 + -- cgit v1.2.3 From 909dbb92eb8ae607142e4316c01058090faaf1c7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 20 Jan 2014 08:38:27 +0100 Subject: Work around FBO readback bug on Samsung Galaxy Tab 3 Symptom of the error is garbled text in Qt Quick 2, and the fix has been confirmed to be enabling the texture resize workaround. Task-number: QTBUG-34984 Change-Id: If6f621b43120c7913cbd33ab326c52ad6e2599bc Reviewed-by: Gunnar Sletta --- .../platforms/android/src/opengl/qandroidopenglcontext.cpp | 8 +++++--- src/plugins/platforms/android/src/qandroidplatformintegration.cpp | 4 ++-- src/plugins/platforms/android/src/qandroidplatformintegration.h | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp index 6431914812..d94bb241f7 100644 --- a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp +++ b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp @@ -82,12 +82,14 @@ void QAndroidOpenGLContext::swapBuffers(QPlatformSurface *surface) bool QAndroidOpenGLContext::makeCurrent(QPlatformSurface *surface) { bool ret = QEglFSContext::makeCurrent(surface); + QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); const char *rendererString = reinterpret_cast(glGetString(GL_RENDERER)); - if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) { - QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); + if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) ctx_d->workaround_missingPrecisionQualifiers = true; - } + + if (!ctx_d->workaround_brokenFBOReadBack && QAndroidPlatformIntegration::needsWorkaround()) + ctx_d->workaround_brokenFBOReadBack = true; return ret; } diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index e09cc40e01..e4a2ad582d 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -123,7 +123,7 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidSystemLocale = new QAndroidSystemLocale; } -bool QAndroidPlatformIntegration::needsBasicRenderloopWorkaround() +bool QAndroidPlatformIntegration::needsWorkaround() { static bool needsWorkaround = QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 @@ -140,7 +140,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case NativeWidgets: return false; case ThreadedOpenGL: - if (needsBasicRenderloopWorkaround()) + if (needsWorkaround()) return false; // fall through default: diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index 15a8ad33dd..474c1e837e 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -145,9 +145,9 @@ public: QEglFSScreen *createScreen() const; #endif -private: - static bool needsBasicRenderloopWorkaround(); + static bool needsWorkaround(); +private: friend class QEglFSAndroidHooks; QTouchDevice *m_touchDevice; -- cgit v1.2.3 From 9eba69d7f914e4823e94699c5653df5ad279eb46 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 21 Jan 2014 08:42:05 +0100 Subject: Fix a bug in some QString comparison operators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some comparison operators comparing to const char * where not implemented correctly. Task-number: QTBUG-34024 Change-Id: Idbdc64c8ed93e88d9f2b2f55213bc785b33cb543 Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qstring.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0a0a609728..9778d42c1d 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1029,13 +1029,13 @@ inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QString &s2) inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QString &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) != 0; } inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QString &s2) -{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; } -inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) > 0; } +inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2) +{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; } inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2) -{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; } -inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; } +inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2) +{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; } inline QT_ASCII_CAST_WARN bool operator==(const char *s1, QLatin1String s2) { return QString::fromUtf8(s1) == s2; } -- cgit v1.2.3