summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-13 09:49:38 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-13 09:49:38 +0200
commitdfc177e3a99dd593db4b1e9445d6243ce75ebf07 (patch)
tree4e33c7be90a44642e672fff22ea163b500ff3aef /src/plugins/platforms
parent72efb2e6f4af2fd909daaf9104f09fd1425acfb0 (diff)
parent1d6eb70dcec105af28d6a5e9b59d56c895c70389 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: qmake/library/qmakeevaluator.cpp (cherry picked from commit 1af6dc2c8fb4d91400fddc5050166f972ae57c9a in qttools) src/corelib/kernel/qcore_mac_objc.mm src/gui/painting/qcolor.h src/plugins/platforms/cocoa/qcocoawindow.mm Change-Id: I5b3ec468a5a9a73911b528d3d24ff8e19f339f31
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm46
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm33
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.mm24
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm8
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintdevice.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintersupport.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h50
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm219
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm16
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm37
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm7
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp4
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h1
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm1
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm11
-rw-r--r--src/plugins/platforms/platforms.pro2
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp11
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.h2
-rw-r--r--src/plugins/platforms/xcb/README10
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro1
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp21
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp24
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp48
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h4
-rw-r--r--src/plugins/platforms/xcb/xcb-static/xcb-static.pro3
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro3
49 files changed, 355 insertions, 355 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 1faa806480..b15c486e9d 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -359,7 +359,7 @@ id getValueAttribute(QAccessibleInterface *interface)
{
const QAccessible::Role qtrole = interface->role();
if (qtrole == QAccessible::StaticText) {
- return QCFString::toNSString(interface->text(QAccessible::Name));
+ return interface->text(QAccessible::Name).toNSString();
}
if (qtrole == QAccessible::EditableText) {
if (QAccessibleTextInterface *textInterface = interface->textInterface()) {
@@ -380,12 +380,12 @@ id getValueAttribute(QAccessibleInterface *interface)
// textInterface->textAfterOffset(0, QAccessible2::SentenceBoundary, &begin, &end);
text = textInterface->text(begin, end);
}
- return QCFString::toNSString(text);
+ return text.toNSString();
}
}
if (QAccessibleValueInterface *valueInterface = interface->valueInterface()) {
- return QCFString::toNSString(valueInterface->currentValue().toString());
+ return valueInterface->currentValue().toString().toNSString();
}
if (interface->state().checkable) {
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 7128fb72c3..9c410506b0 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -237,7 +237,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if (QWindow *window = iface->window()) {
QCocoaWindow *win = static_cast<QCocoaWindow*>(window->handle());
- return win->qtView();
+ return qnsview_cast(win->view());
}
QAccessibleInterface *parent = iface->parent();
@@ -300,9 +300,9 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
} else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) {
if (iface->role() == QAccessible::StaticText)
return nil;
- return QCFString::toNSString(iface->text(QAccessible::Name));
+ return iface->text(QAccessible::Name).toNSString();
} else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) {
- return QCFString::toNSString(iface->text(QAccessible::Description));
+ return iface->text(QAccessible::Description).toNSString();
} else if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) {
return [NSNumber numberWithBool:!iface->state().disabled];
} else if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
@@ -439,7 +439,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if ([attribute isEqualToString: NSAccessibilityAttributedStringForRangeParameterizedAttribute]) {
NSRange range = [parameter rangeValue];
QString text = iface->textInterface()->text(range.location, range.location + range.length);
- return [[NSAttributedString alloc] initWithString: text.toNSString()];
+ return [[NSAttributedString alloc] initWithString:text.toNSString()];
} else if ([attribute isEqualToString: NSAccessibilityRangeForPositionParameterizedAttribute]) {
NSPoint nsPoint = [parameter pointValue];
QPoint point(static_cast<int>(nsPoint.x), static_cast<int>(qt_mac_flipYCoordinate(nsPoint.y)));
@@ -532,7 +532,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
} else {
description = qAccessibleLocalizedActionDescription(qtAction);
}
- return QCFString::toNSString(description);
+ return description.toNSString();
}
- (void)accessibilityPerformAction:(NSString *)action {
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 4874fcf807..da755aa189 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -296,7 +296,7 @@ QT_END_NAMESPACE
Q_UNUSED(sender);
for (NSString *fileName in filenames) {
- QString qtFileName = QCFString::toQString(fileName);
+ QString qtFileName = QString::fromNSString(fileName);
if (inLaunch) {
// We need to be careful because Cocoa will be nice enough to take
// command line arguments and send them to us as events. Given the history
@@ -424,7 +424,7 @@ QT_END_NAMESPACE
{
Q_UNUSED(replyEvent);
NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
- QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString)));
+ QWindowSystemInterface::handleFileOpenEvent(QUrl(QString::fromNSString(urlString)));
}
- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index af5418315c..a74995319b 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -40,6 +40,7 @@
#include "qcocoabackingstore.h"
#include "qcocoawindow.h"
+#include "qcocoahelpers.h"
QT_BEGIN_NAMESPACE
@@ -51,7 +52,7 @@ QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
QCocoaBackingStore::~QCocoaBackingStore()
{
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()))
- [cocoaWindow->m_qtView clearBackingStore:this];
+ [qnsview_cast(cocoaWindow->view()) clearBackingStore:this];
}
QImage::Format QCocoaBackingStore::format() const
@@ -68,7 +69,7 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
return;
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle()))
- [cocoaWindow->m_qtView flushBackingStore:this region:region offset:offset];
+ [qnsview_cast(cocoaWindow->view()) flushBackingStore:this region:region offset:offset];
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 5f54110777..5c27cf8059 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -348,7 +348,7 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun
bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
{
Q_D(QCocoaEventDispatcher);
- d->interrupt = false;
+ QBoolBlocker interruptBlocker(d->interrupt, false);
bool interruptLater = false;
QtCocoaInterruptDispatcher::cancelInterruptLater();
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index c0055852c2..7706f39198 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -146,14 +146,14 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
QFileInfo sel(selectFile);
if (sel.isDir() && !sel.isBundle()){
- mCurrentDir = [QCFString::toNSString(sel.absoluteFilePath()) retain];
+ mCurrentDir = [sel.absoluteFilePath().toNSString() retain];
mCurrentSelection = new QString;
} else {
- mCurrentDir = [QCFString::toNSString(sel.absolutePath()) retain];
+ mCurrentDir = [sel.absolutePath().toNSString() retain];
mCurrentSelection = new QString(sel.absoluteFilePath());
}
- [mSavePanel setTitle:QCFString::toNSString(options->windowTitle())];
+ [mSavePanel setTitle:options->windowTitle().toNSString()];
[self createPopUpButton:selectedVisualNameFilter hideDetails:options->testOption(QFileDialogOptions::HideNameFilterDetails)];
[self createTextField];
[self createAccessory];
@@ -204,12 +204,12 @@ static QString strippedText(QString s)
- (NSString *)strip:(const QString &)label
{
- return QCFString::toNSString(strippedText(label));
+ return strippedText(label).toNSString();
}
- (void)closePanel
{
- *mCurrentSelection = QCFString::toQString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
+ *mCurrentSelection = QString::fromNSString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
if ([mSavePanel respondsToSelector:@selector(close)])
[mSavePanel close];
if ([mSavePanel isSheet])
@@ -220,14 +220,14 @@ static QString strippedText(QString s)
{
if (mOpenPanel){
QFileInfo info(*mCurrentSelection);
- NSString *filepath = QCFString::toNSString(info.filePath());
+ NSString *filepath = info.filePath().toNSString();
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
[self updateProperties];
QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
[mOpenPanel setAllowedFileTypes:nil];
- [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""];
+ [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
[mOpenPanel beginWithCompletionHandler:^(NSInteger result){
mReturnCode = result;
@@ -240,12 +240,12 @@ static QString strippedText(QString s)
- (BOOL)runApplicationModalPanel
{
QFileInfo info(*mCurrentSelection);
- NSString *filepath = QCFString::toNSString(info.filePath());
+ NSString *filepath = info.filePath().toNSString();
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];
- [mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""];
+ [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
// Call processEvents in case the event dispatcher has been interrupted, and needs to do
// cleanup of modal sessions. Do this before showing the native dialog, otherwise it will
@@ -267,7 +267,7 @@ static QString strippedText(QString s)
- (void)showWindowModalSheet:(QWindow *)parent
{
QFileInfo info(*mCurrentSelection);
- NSString *filepath = QCFString::toNSString(info.filePath());
+ NSString *filepath = info.filePath().toNSString();
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldShowFilename:filepath];
@@ -275,7 +275,7 @@ static QString strippedText(QString s)
QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];
- [mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""];
+ [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
NSWindow *nsparent = static_cast<NSWindow *>(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent));
[mSavePanel beginSheetModalForWindow:nsparent completionHandler:^(NSInteger result){
@@ -322,7 +322,7 @@ static QString strippedText(QString s)
}
}
- QString qtFileName = QFileInfo(QCFString::toQString(filename)).fileName();
+ QString qtFileName = QFileInfo(QString::fromNSString(filename)).fileName();
// No filter means accept everything
bool nameMatches = mSelectedNameFilter->isEmpty();
// Check if the current file name filter accepts the file:
@@ -374,7 +374,7 @@ static QString strippedText(QString s)
if (filters.size() > 0){
for (int i=0; i<filters.size(); ++i) {
QString filter = hideDetails ? [self removeExtensions:filters.at(i)] : filters.at(i);
- [mPopUpButton addItemWithTitle:QCFString::toNSString(filter)];
+ [mPopUpButton addItemWithTitle:filter.toNSString()];
}
[mPopUpButton selectItemAtIndex:0];
[mSavePanel setAccessoryView:mAccessoryView];
@@ -408,13 +408,13 @@ static QString strippedText(QString s)
QList<QUrl> result;
NSArray* array = [mOpenPanel URLs];
for (NSUInteger i=0; i<[array count]; ++i) {
- QString path = QCFString::toQString([[array objectAtIndex:i] path]).normalized(QString::NormalizationForm_C);
+ QString path = QString::fromNSString([[array objectAtIndex:i] path]).normalized(QString::NormalizationForm_C);
result << QUrl::fromLocalFile(path);
}
return result;
} else {
QList<QUrl> result;
- QString filename = QCFString::toQString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
+ QString filename = QString::fromNSString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C);
result << QUrl::fromLocalFile(filename.remove(QLatin1String("___qt_very_unlikely_prefix_")));
return result;
}
@@ -437,8 +437,8 @@ static QString strippedText(QString s)
[mSavePanel setCanCreateDirectories:!(mOptions->testOption(QFileDialogOptions::ReadOnly))];
[mOpenPanel setAllowsMultipleSelection:(fileMode == QFileDialogOptions::ExistingFiles)];
[mOpenPanel setResolvesAliases:!(mOptions->testOption(QFileDialogOptions::DontResolveSymlinks))];
- [mOpenPanel setTitle:QCFString::toNSString(mOptions->windowTitle())];
- [mSavePanel setTitle:QCFString::toNSString(mOptions->windowTitle())];
+ [mOpenPanel setTitle:mOptions->windowTitle().toNSString()];
+ [mSavePanel setTitle:mOptions->windowTitle().toNSString()];
[mPopUpButton setHidden:chooseDirsOnly]; // TODO hide the whole sunken pane instead?
QStringList ext = [self acceptableExtensionsForSave];
@@ -457,7 +457,7 @@ static QString strippedText(QString s)
{
Q_UNUSED(sender);
if (mHelper && [mSavePanel isVisible]) {
- QString selection = QCFString::toQString([[mSavePanel URL] path]);
+ QString selection = QString::fromNSString([[mSavePanel URL] path]);
if (selection != mCurrentSelection) {
*mCurrentSelection = selection;
mHelper->QNSOpenSavePanelDelegate_selectionChanged(selection);
@@ -475,7 +475,7 @@ static QString strippedText(QString s)
[mCurrentDir release];
mCurrentDir = [path retain];
- mHelper->QNSOpenSavePanelDelegate_directoryEntered(QCFString::toQString(mCurrentDir));
+ mHelper->QNSOpenSavePanelDelegate_directoryEntered(QString::fromNSString(mCurrentDir));
}
/*
@@ -538,7 +538,7 @@ static QString strippedText(QString s)
(filterToUse == -1 && currentFilter.startsWith(selectedFilter)))
filterToUse = i;
QString filter = hideDetails ? [self removeExtensions:currentFilter] : currentFilter;
- [mPopUpButton addItemWithTitle:QCFString::toNSString(filter)];
+ [mPopUpButton addItemWithTitle:filter.toNSString()];
}
if (filterToUse != -1)
[mPopUpButton selectItemAtIndex:filterToUse];
@@ -610,7 +610,7 @@ void QCocoaFileDialogHelper::QNSOpenSavePanelDelegate_filterSelected(int menuInd
void QCocoaFileDialogHelper::setDirectory(const QUrl &directory)
{
if (mDelegate)
- [mDelegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory.toLocalFile())]];
+ [mDelegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:directory.toLocalFile().toNSString()]];
else
mDir = directory;
}
@@ -618,7 +618,7 @@ void QCocoaFileDialogHelper::setDirectory(const QUrl &directory)
QUrl QCocoaFileDialogHelper::directory() const
{
if (mDelegate) {
- QString path = QCFString::toQString([[mDelegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C);
+ QString path = QString::fromNSString([[mDelegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C);
return QUrl::fromLocalFile(path);
}
return mDir;
@@ -647,7 +647,7 @@ void QCocoaFileDialogHelper::setFilter()
if (!mDelegate)
return;
const SharedPointerFileDialogOptions &opts = options();
- [mDelegate->mSavePanel setTitle:QCFString::toNSString(opts->windowTitle())];
+ [mDelegate->mSavePanel setTitle:opts->windowTitle().toNSString()];
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
[mDelegate->mSavePanel setPrompt:[mDelegate strip:opts->labelText(QFileDialogOptions::Accept)]];
if (opts->isLabelExplicitlySet(QFileDialogOptions::FileName))
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index dc7dfb788f..214f44b548 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -162,7 +162,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
{
mHelper = helper;
- [mFontPanel setTitle:QCFString::toNSString(helper->options()->windowTitle())];
+ [mFontPanel setTitle:helper->options()->windowTitle().toNSString()];
if (mHelper->options()->testOption(QFontDialogOptions::NoButtons)) {
[self restoreOriginalContentView];
@@ -442,7 +442,7 @@ public:
}
QFontInfo fontInfo(font);
- nsFont = [mgr fontWithFamily:QCFString::toNSString(fontInfo.family())
+ nsFont = [mgr fontWithFamily:fontInfo.family().toNSString()
traits:mask
weight:weight
size:fontInfo.pointSize()];
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index ccb11f80f1..31b93be136 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -255,7 +255,7 @@ void QCocoaGLContext::setActiveWindow(QWindow *window)
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
cocoaWindow->setCurrentContext(this);
- [(QNSView *) cocoaWindow->contentView() setQCocoaGLContext:this];
+ [(QNSView *) cocoaWindow->view() setQCocoaGLContext:this];
}
void QCocoaGLContext::updateSurfaceFormat()
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index 536a2d2d58..1b038a6b5e 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -55,6 +55,8 @@
#include <QtGui/qpalette.h>
#include <QtGui/qscreen.h>
+Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSView));
+
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaCocoaWindow)
@@ -74,6 +76,8 @@ NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions);
Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions);
Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions);
+QT_MANGLE_NAMESPACE(QNSView) *qnsview_cast(NSView *view);
+
// Misc
void qt_mac_transformProccessToForegroundApplication();
QString qt_mac_applicationName();
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 0c7c30579e..c57567bdd6 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -40,7 +40,7 @@
#include <qpa/qplatformtheme.h>
#include "qcocoahelpers.h"
-
+#include "qnsview.h"
#include <QtCore>
#include <QtGui>
@@ -70,7 +70,7 @@ QStringList qt_mac_NSArrayToQStringList(void *nsarray)
QStringList result;
NSArray *array = static_cast<NSArray *>(nsarray);
for (NSUInteger i=0; i<[array count]; ++i)
- result << QCFString::toQString([array objectAtIndex:i]);
+ result << QString::fromNSString([array objectAtIndex:i]);
return result;
}
@@ -143,7 +143,30 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions)
return actions;
}
+/*!
+ Returns the view cast to a QNSview if possible.
+
+ If the view is not a QNSView, nil is returned, which is safe to
+ send messages to, effectivly making [qnsview_cast(view) message]
+ a no-op.
+ For extra verbosity and clearer code, please consider checking
+ that window()->type() != Qt::ForeignWindow before using this cast.
+
+ Do not use this method soley to check for foreign windows, as
+ that will make the code harder to read for people not working
+ primarily on macOS, who do not know the difference between the
+ NSView and QNSView cases.
+*/
+QNSView *qnsview_cast(NSView *view)
+{
+ if (![view isKindOfClass:[QNSView class]]) {
+ qCWarning(lcQpaCocoaWindow) << "NSView is not QNSView, consider checking for Qt::ForeignWindow";
+ return nil;
+ }
+
+ return static_cast<QNSView *>(view);
+}
//
// Misc
@@ -161,7 +184,7 @@ void qt_mac_transformProccessToForegroundApplication()
// Officially it's supposed to be a string, a boolean makes sense, so we'll check.
// A number less so, but OK.
if (valueType == CFStringGetTypeID())
- forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt());
+ forceTransform = !(QString::fromCFString(static_cast<CFStringRef>(value)).toInt());
else if (valueType == CFBooleanGetTypeID())
forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value));
else if (valueType == CFNumberGetTypeID()) {
@@ -179,7 +202,7 @@ void qt_mac_transformProccessToForegroundApplication()
if (valueType == CFBooleanGetTypeID())
forceTransform = !CFBooleanGetValue(static_cast<CFBooleanRef>(value));
else if (valueType == CFStringGetTypeID())
- forceTransform = !(QCFString::toQString(static_cast<CFStringRef>(value)).toInt());
+ forceTransform = !(QString::fromCFString(static_cast<CFStringRef>(value)).toInt());
else if (valueType == CFNumberGetTypeID()) {
int valueAsInt;
CFNumberGetValue(static_cast<CFNumberRef>(value), kCFNumberIntType, &valueAsInt);
@@ -198,7 +221,7 @@ QString qt_mac_applicationName()
QString appName;
CFTypeRef string = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("CFBundleName"));
if (string)
- appName = QCFString::toQString(static_cast<CFStringRef>(string));
+ appName = QString::fromCFString(static_cast<CFStringRef>(string));
if (appName.isEmpty()) {
QString arg0 = QGuiApplicationPrivate::instance()->appName();
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
index 04d6d6b806..9e3d747cd7 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
@@ -41,6 +41,7 @@
#include "qcocoainputcontext.h"
#include "qcocoanativeinterface.h"
#include "qcocoawindow.h"
+#include "qcocoahelpers.h"
#include <Carbon/Carbon.h>
@@ -102,7 +103,8 @@ void QCocoaInputContext::reset()
if (!mWindow)
return;
- QNSView *view = static_cast<QCocoaWindow *>(mWindow->handle())->qtView();
+ QCocoaWindow *window = static_cast<QCocoaWindow *>(mWindow->handle());
+ QNSView *view = qnsview_cast(window->view());
if (!view)
return;
@@ -131,7 +133,7 @@ void QCocoaInputContext::updateLocale()
CFArrayRef languages = (CFArrayRef) TISGetInputSourceProperty(source, kTISPropertyInputSourceLanguages);
if (CFArrayGetCount(languages) > 0) {
CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(languages, 0);
- QString name = QCFString::toQString(langRef);
+ QString name = QString::fromCFString(langRef);
QLocale locale(name);
if (m_locale != locale) {
m_locale = locale;
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
index ebe547f64b..e7952ae1f6 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
@@ -251,16 +251,20 @@ static qt_mac_enum_mapper qt_mac_private_unicode[] = {
{ 0xF72B, QT_MAC_MAP_ENUM(Qt::Key_End) }, //NSEndFunctionKey
{ 0xF72C, QT_MAC_MAP_ENUM(Qt::Key_PageUp) }, //NSPageUpFunctionKey
{ 0xF72D, QT_MAC_MAP_ENUM(Qt::Key_PageDown) }, //NSPageDownFunctionKey
+ { 0xF72E, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintScreenFunctionKey
{ 0xF72F, QT_MAC_MAP_ENUM(Qt::Key_ScrollLock) }, //NSScrollLockFunctionKey
{ 0xF730, QT_MAC_MAP_ENUM(Qt::Key_Pause) }, //NSPauseFunctionKey
{ 0xF731, QT_MAC_MAP_ENUM(Qt::Key_SysReq) }, //NSSysReqFunctionKey
{ 0xF735, QT_MAC_MAP_ENUM(Qt::Key_Menu) }, //NSMenuFunctionKey
- { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintFunctionKey
+ { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Printer) }, //NSPrintFunctionKey
{ 0xF73A, QT_MAC_MAP_ENUM(Qt::Key_Clear) }, //NSClearDisplayFunctionKey
{ 0xF73D, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertCharFunctionKey
{ 0xF73E, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteCharFunctionKey
{ 0xF741, QT_MAC_MAP_ENUM(Qt::Key_Select) }, //NSSelectFunctionKey
{ 0xF742, QT_MAC_MAP_ENUM(Qt::Key_Execute) }, //NSExecuteFunctionKey
+ { 0xF743, QT_MAC_MAP_ENUM(Qt::Key_Undo) }, //NSUndoFunctionKey
+ { 0xF744, QT_MAC_MAP_ENUM(Qt::Key_Redo) }, //NSRedoFunctionKey
+ { 0xF745, QT_MAC_MAP_ENUM(Qt::Key_Find) }, //NSFindFunctionKey
{ 0xF746, QT_MAC_MAP_ENUM(Qt::Key_Help) }, //NSHelpFunctionKey
{ 0xF747, QT_MAC_MAP_ENUM(Qt::Key_Mode_switch) }, //NSModeSwitchFunctionKey
{ 0, QT_MAC_MAP_ENUM(0) }
@@ -384,17 +388,12 @@ bool QCocoaKeyMapper::updateKeyboard()
iso639Code = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, 0)); // Actually a RFC3066bis, but it's close enough
if (iso639Code) {
- keyboardInputLocale = QLocale(QCFString::toQString(iso639Code));
+ keyboardInputLocale = QLocale(QString::fromCFString(iso639Code));
keyboardInputDirection = keyboardInputLocale.textDirection();
} else {
keyboardInputLocale = QLocale::c();
keyboardInputDirection = Qt::LeftToRight;
}
-
- const auto newMode = keyboard_mode;
- deleteLayouts();
- keyboard_mode = newMode;
-
return true;
}
@@ -417,8 +416,10 @@ void QCocoaKeyMapper::clearMappings()
void QCocoaKeyMapper::updateKeyMap(unsigned short macVirtualKey, QChar unicodeKey)
{
- updateKeyboard();
-
+ if (updateKeyboard()) {
+ // ### Qt 4 did this:
+ // QKeyMapper::changeKeyboard();
+ }
if (keyLayout[macVirtualKey])
return;
@@ -474,8 +475,9 @@ QList<int> QCocoaKeyMapper::possibleKeys(const QKeyEvent *event) const
for (int i = 1; i < 8; ++i) {
Qt::KeyboardModifiers neededMods = ModsTbl[i];
int key = kbItem->qtKey[i];
- if (key && key != baseKey && ((keyMods & neededMods) == neededMods))
- ret << int(key + neededMods);
+ if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
+ ret << int(key + (keyMods & ~neededMods));
+ }
}
return ret;
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 4260b17772..566363e01f 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -285,7 +285,7 @@ void QCocoaMenu::setText(const QString &text)
{
QMacAutoReleasePool pool;
QString stripped = qt_mac_removeAmpersandEscapes(text);
- [m_nativeMenu setTitle:QCFString::toNSString(stripped)];
+ [m_nativeMenu setTitle:stripped.toNSString()];
}
void QCocoaMenu::setMinimumWidth(int width)
@@ -296,7 +296,7 @@ void QCocoaMenu::setMinimumWidth(int width)
void QCocoaMenu::setFont(const QFont &font)
{
if (font.resolve()) {
- NSFont *customMenuFont = [NSFont fontWithName:QCFString::toNSString(font.family())
+ NSFont *customMenuFont = [NSFont fontWithName:font.family().toNSString()
size:font.pointSize()];
m_nativeMenu.font = customMenuFont;
}
@@ -495,7 +495,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect,
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
- NSView *view = cocoaWindow ? cocoaWindow->contentView() : nil;
+ NSView *view = cocoaWindow ? cocoaWindow->view() : nil;
NSMenuItem *nsItem = item ? ((QCocoaMenuItem *)item)->nsItem() : nil;
QScreen *screen = 0;
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index ea094c86ee..b8a64641a8 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -309,7 +309,7 @@ NSMenuItem *QCocoaMenuItem::sync()
}
if (!m_native) {
- m_native = [[NSMenuItem alloc] initWithTitle:QCFString::toNSString(m_text)
+ m_native = [[NSMenuItem alloc] initWithTitle:m_text.toNSString()
action:nil
keyEquivalent:@""];
[m_native setTag:reinterpret_cast<NSInteger>(this)];
@@ -331,20 +331,20 @@ NSMenuItem *QCocoaMenuItem::sync()
bool useAttributedTitle = false;
// Cocoa Font and title
if (m_font.resolve()) {
- NSFont *customMenuFont = [NSFont fontWithName:QCFString::toNSString(m_font.family())
+ NSFont *customMenuFont = [NSFont fontWithName:m_font.family().toNSString()
size:m_font.pointSize()];
if (customMenuFont) {
NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil];
NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil];
NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
- NSAttributedString *str = [[[NSAttributedString alloc] initWithString:QCFString::toNSString(finalString)
+ NSAttributedString *str = [[[NSAttributedString alloc] initWithString:finalString.toNSString()
attributes:attributes] autorelease];
[m_native setAttributedTitle: str];
useAttributedTitle = true;
}
}
if (!useAttributedTitle) {
- [m_native setTitle: QCFString::toNSString(finalString)];
+ [m_native setTitle:finalString.toNSString()];
}
#ifndef QT_NO_SHORTCUT
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
index 22e90f8dc8..01a3c04afb 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
@@ -314,13 +314,13 @@ QT_FORWARD_DECLARE_CLASS(QString)
{
#ifndef QT_NO_TRANSLATION
- [servicesItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(0))];
- [hideItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()))];
- [hideAllOthersItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(2))];
- [showAllItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(3))];
- [preferencesItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(4))];
- [quitItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()))];
- [aboutItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()))];
+ [servicesItem setTitle:qt_mac_applicationmenu_string(0).toNSString()];
+ [hideItem setTitle:qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()).toNSString()];
+ [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(2).toNSString()];
+ [showAllItem setTitle:qt_mac_applicationmenu_string(3).toNSString()];
+ [preferencesItem setTitle:qt_mac_applicationmenu_string(4).toNSString()];
+ [quitItem setTitle:qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()).toNSString()];
+ [aboutItem setTitle:qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()).toNSString()];
#endif
}
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index 7065a364bf..477165607c 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -120,9 +120,6 @@ private:
static CGImageRef qImageToCGImage(const QImage &image);
static QImage cgImageToQImage(CGImageRef image);
- // Embedding NSViews as child QWindows
- static void setWindowContentView(QPlatformWindow *window, void *nsViewContentView);
-
// Set a QWindow as a "guest" (subwindow) of a non-QWindow
static void setEmbeddedInForeignView(QPlatformWindow *window, bool embedded);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 3ff37a8463..10435d0b1d 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -96,7 +96,7 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
return 0;
if (resourceString == "nsview") {
- return static_cast<QCocoaWindow *>(window->handle())->m_contentView;
+ return static_cast<QCocoaWindow *>(window->handle())->m_view;
#ifndef QT_NO_OPENGL
} else if (resourceString == "nsopenglcontext") {
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
@@ -125,8 +125,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::qImageToCGImage);
if (resource.toLower() == "cgimagetoqimage")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::cgImageToQImage);
- if (resource.toLower() == "setwindowcontentview")
- return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setWindowContentView);
if (resource.toLower() == "registertouchwindow")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow);
if (resource.toLower() == "setembeddedinforeignview")
@@ -278,12 +276,6 @@ QImage QCocoaNativeInterface::cgImageToQImage(CGImageRef image)
return qt_mac_toQImage(image);
}
-void QCocoaNativeInterface::setWindowContentView(QPlatformWindow *window, void *contentView)
-{
- QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
- cocoaPlatformWindow->setContentView(reinterpret_cast<NSView *>(contentView));
-}
-
void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded)
{
QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
index d5fd523a37..39fcf285ed 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
@@ -71,13 +71,13 @@ QCocoaPrintDevice::QCocoaPrintDevice(const QString &id)
m_ppd(0)
{
if (!id.isEmpty()) {
- m_printer = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(id));
+ m_printer = PMPrinterCreateFromPrinterID(id.toCFString());
if (m_printer) {
- m_name = QCFString::toQString(PMPrinterGetName(m_printer));
- m_location = QCFString::toQString(PMPrinterGetLocation(m_printer));
+ m_name = QString::fromCFString(PMPrinterGetName(m_printer));
+ m_location = QString::fromCFString(PMPrinterGetLocation(m_printer));
CFStringRef cfMakeAndModel;
if (PMPrinterGetMakeAndModelName(m_printer, &cfMakeAndModel) == noErr)
- m_makeAndModel = QCFString::toQString(cfMakeAndModel);
+ m_makeAndModel = QString::fromCFString(cfMakeAndModel);
Boolean isRemote;
if (PMPrinterIsRemote(m_printer, &isRemote) == noErr)
m_isRemote = isRemote;
@@ -420,7 +420,7 @@ void QCocoaPrintDevice::loadMimeTypes() const
int count = CFArrayGetCount(mimeTypes);
for (int i = 0; i < count; ++i) {
CFStringRef mimeName = static_cast<CFStringRef>(const_cast<void *>(CFArrayGetValueAtIndex(mimeTypes, i)));
- QMimeType mimeType = db.mimeTypeForName(QCFString::toQString(mimeName));
+ QMimeType mimeType = db.mimeTypeForName(QString::fromCFString(mimeName));
if (mimeType.isValid())
m_mimeTypes.append(mimeType);
}
diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm
index f8fc23f681..c2f7d5b022 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm
@@ -82,7 +82,7 @@ QStringList QCocoaPrinterSupport::availablePrintDeviceIds() const
CFIndex count = CFArrayGetCount(printerList);
for (CFIndex i = 0; i < count; ++i) {
PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
- list.append(QCFString::toQString(PMPrinterGetID(printer)));
+ list.append(QString::fromCFString(PMPrinterGetID(printer)));
}
}
return list;
@@ -96,7 +96,7 @@ QString QCocoaPrinterSupport::defaultPrintDeviceId() const
for (CFIndex i = 0; i < count; ++i) {
PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
if (PMPrinterIsDefault(printer))
- return QCFString::toQString(PMPrinterGetID(printer));
+ return QString::fromCFString(PMPrinterGetID(printer));
}
}
return QString();
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 9a543e893e..6af22facf9 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -270,7 +270,7 @@ void QCocoaSystemTrayIcon::updateToolTip(const QString &toolTip)
{
if (!m_sys)
return;
- [[[m_sys->item item] view] setToolTip:QCFString::toNSString(toolTip)];
+ [[[m_sys->item item] view] setToolTip:toolTip.toNSString()];
}
bool QCocoaSystemTrayIcon::isSystemTrayAvailable() const
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index d0879ed457..03ad15a381 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -303,7 +303,7 @@ protected:
{
QMacAutoReleasePool pool;
- NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo().canonicalFilePath())];
+ NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:fileInfo().canonicalFilePath().toNSString()];
if (!iconImage)
return QPixmap();
return qt_mac_toQPixmap(iconImage, size);
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index b016004b23..bd7b23bc1b 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -54,32 +54,6 @@
QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
-QT_BEGIN_NAMESPACE
-
-class QCocoaWindowPointer
-{
-public:
- void assign(QCocoaWindow *w);
- void clear();
-
- QCocoaWindow *data() const
- { return watcher.isNull() ? Q_NULLPTR : window; }
- bool isNull() const
- { return watcher.isNull(); }
- operator QCocoaWindow*() const
- { return data(); }
- QCocoaWindow *operator->() const
- { return data(); }
- QCocoaWindow &operator*() const
- { return *data(); }
-
-private:
- QPointer<QObject> watcher;
- QCocoaWindow *window;
-};
-
-QT_END_NAMESPACE
-
@class QT_MANGLE_NAMESPACE(QNSWindowHelper);
@protocol QNSWindowProtocol
@@ -96,13 +70,13 @@ typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
@interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject
{
QCocoaNSWindow *_window;
- QCocoaWindowPointer _platformWindow;
+ QPointer<QCocoaWindow> _platformWindow;
BOOL _grabbingMouse;
BOOL _releaseOnMouseUp;
}
@property (nonatomic, readonly) QCocoaNSWindow *window;
-@property (nonatomic, readonly) QCocoaWindowPointer platformWindow;
+@property (nonatomic, readonly) QCocoaWindow *platformWindow;
@property (nonatomic) BOOL grabbingMouse;
@property (nonatomic) BOOL releaseOnMouseUp;
@@ -169,8 +143,9 @@ QT_BEGIN_NAMESPACE
class QCocoaMenuBar;
-class QCocoaWindow : public QPlatformWindow
+class QCocoaWindow : public QObject, public QPlatformWindow
{
+ Q_OBJECT
public:
QCocoaWindow(QWindow *tlw);
~QCocoaWindow();
@@ -207,9 +182,7 @@ public:
WId winId() const Q_DECL_OVERRIDE;
void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
- NSView *contentView() const;
- void setContentView(NSView *contentView);
- QNSView *qtView() const;
+ NSView *view() const;
NSWindow *nativeWindow() const;
void setEmbeddedInForeignView(bool subwindow);
@@ -285,14 +258,13 @@ public: // for QNSView
void removeMonitor();
- NSView *m_contentView;
- QNSView *m_qtView;
+ NSView *m_view;
QCocoaNSWindow *m_nsWindow;
- QCocoaWindowPointer m_forwardWindow;
+ QPointer<QCocoaWindow> m_forwardWindow;
// TODO merge to one variable if possible
- bool m_contentViewIsEmbedded; // true if the m_contentView is actually embedded in a "foreign" NSView hiearchy
- bool m_contentViewIsToBeEmbedded; // true if the m_contentView is intended to be embedded in a "foreign" NSView hiearchy
+ bool m_viewIsEmbedded; // true if the m_view is actually embedded in a "foreign" NSView hiearchy
+ bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy
QCocoaWindow *m_parentCocoaWindow;
bool m_isNSWindowChild; // this window is a non-top level QWindow with a NSWindow.
@@ -350,10 +322,6 @@ public: // for QNSView
};
QHash<quintptr, BorderRange> m_contentBorderAreas; // identifer -> uppper/lower
QHash<quintptr, bool> m_enabledContentBorderAreas; // identifer -> enabled state (true/false)
-
- // This object is tracked by QCocoaWindowPointer,
- // preventing the use of dangling pointers.
- QObject sentinel;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 87a0991098..f87ddab455 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -90,16 +90,20 @@ static void qt_closePopups()
@implementation QNSWindowHelper
@synthesize window = _window;
-@synthesize platformWindow = _platformWindow;
@synthesize grabbingMouse = _grabbingMouse;
@synthesize releaseOnMouseUp = _releaseOnMouseUp;
+- (QCocoaWindow *)platformWindow
+{
+ return _platformWindow.data();
+}
+
- (id)initWithNSWindow:(QCocoaNSWindow *)window platformWindow:(QCocoaWindow *)platformWindow
{
self = [super init];
if (self) {
_window = window;
- _platformWindow.assign(platformWindow);
+ _platformWindow = platformWindow;
_window.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:_platformWindow];
@@ -118,7 +122,7 @@ static void qt_closePopups()
QCocoaWindow *pw = self.platformWindow;
if (pw && pw->m_forwardWindow) {
if (theEvent.type == NSLeftMouseUp || theEvent.type == NSLeftMouseDragged) {
- QNSView *forwardView = pw->m_qtView;
+ QNSView *forwardView = qnsview_cast(pw->view());
if (theEvent.type == NSLeftMouseUp) {
[forwardView mouseUp:theEvent];
pw->m_forwardWindow.clear();
@@ -159,18 +163,14 @@ static void qt_closePopups()
NSPoint loc = [theEvent locationInWindow];
NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
NSRect contentFrame = [[self.window contentView] frame];
- if (NSMouseInRect(loc, windowFrame, NO) &&
- !NSMouseInRect(loc, contentFrame, NO))
- {
- QNSView *contentView = pw->m_qtView;
- [contentView handleFrameStrutMouseEvent: theEvent];
- }
+ if (NSMouseInRect(loc, windowFrame, NO) && !NSMouseInRect(loc, contentFrame, NO))
+ [qnsview_cast(pw->view()) handleFrameStrutMouseEvent:theEvent];
}
}
- (void)detachFromPlatformWindow
{
- self.platformWindow.clear();
+ _platformWindow.clear();
[self.window.delegate release];
self.window.delegate = nil;
}
@@ -191,7 +191,7 @@ static void qt_closePopups()
- (void)dealloc
{
_window = nil;
- self.platformWindow.clear();
+ _platformWindow.clear();
[super dealloc];
}
@@ -343,27 +343,14 @@ static void qt_closePopups()
@end
-void QCocoaWindowPointer::assign(QCocoaWindow *w)
-{
- window = w;
- watcher = &w->sentinel;
-}
-
-void QCocoaWindowPointer::clear()
-{
- window = Q_NULLPTR;
- watcher.clear();
-}
-
const int QCocoaWindow::NoAlertRequest = -1;
QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
- , m_contentView(nil)
- , m_qtView(nil)
+ , m_view(nil)
, m_nsWindow(0)
- , m_contentViewIsEmbedded(false)
- , m_contentViewIsToBeEmbedded(false)
+ , m_viewIsEmbedded(false)
+ , m_viewIsToBeEmbedded(false)
, m_parentCocoaWindow(0)
, m_isNSWindowChild(false)
, m_effectivelyMaximized(false)
@@ -399,11 +386,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
QMacAutoReleasePool pool;
if (tlw->type() == Qt::ForeignWindow) {
- NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
- setContentView(foreignView);
+ m_view = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
} else {
- m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
- m_contentView = m_qtView;
+ m_view = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
// Enable high-dpi OpenGL for retina displays. Enabling has the side
// effect that Cocoa will start calling glViewport(0, 0, width, height),
// overriding any glViewport calls in application code. This is usually not a
@@ -412,14 +397,14 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
if (tlw->supportsOpenGL()) {
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
- [m_contentView setWantsBestResolutionOpenGLSurface:enable];
+ [m_view setWantsBestResolutionOpenGLSurface:enable];
}
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
"QT_MAC_WANTS_LAYER");
- [m_contentView setWantsLayer:enable];
+ [m_view setWantsLayer:enable];
}
setGeometry(tlw->geometry());
- recreateWindow(parent());
+ recreateWindow(QPlatformWindow::parent());
tlw->setGeometry(geometry());
if (tlw->isTopLevel())
setWindowIcon(tlw->icon());
@@ -437,25 +422,23 @@ QCocoaWindow::~QCocoaWindow()
if (m_isNSWindowChild) {
if (m_parentCocoaWindow)
m_parentCocoaWindow->removeChildWindow(this);
- } else if ([m_contentView superview]) {
- [m_contentView removeFromSuperview];
+ } else if ([m_view superview]) {
+ [m_view removeFromSuperview];
}
removeMonitor();
// Make sure to disconnect observer in all case if view is valid
// to avoid notifications received when deleting when using Qt::AA_NativeWindows attribute
- if (m_qtView) {
- [[NSNotificationCenter defaultCenter] removeObserver:m_qtView];
- }
+ if (window()->type() != Qt::ForeignWindow)
+ [[NSNotificationCenter defaultCenter] removeObserver:m_view];
// The QNSView object may outlive the corresponding QCocoaWindow object,
// for example during app shutdown when the QNSView is embedded in a
// foregin NSView hiearchy. Clear the pointers to the QWindow/QCocoaWindow
// here to make sure QNSView does not dereference stale pointers.
- if (m_qtView) {
- [m_qtView clearQWindowPointers];
- }
+ if (window()->type() != Qt::ForeignWindow)
+ [qnsview_cast(m_view) clearQWindowPointers];
// While it is unlikely that this window will be in the popup stack
// during deletetion we clear any pointers here to make sure.
@@ -468,7 +451,7 @@ QCocoaWindow::~QCocoaWindow()
child->m_parentCocoaWindow = 0;
}
- [m_contentView release];
+ [m_view release];
[m_nsWindow release];
[m_windowCursor release];
}
@@ -509,12 +492,12 @@ QRect QCocoaWindow::geometry() const
// QWindows that are embedded in a NSView hiearchy may be considered
// top-level from Qt's point of view but are not from Cocoa's point
// of view. Embedded QWindows get global (screen) geometry.
- if (m_contentViewIsEmbedded) {
- NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
- NSRect screenRect = [[m_contentView window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
+ if (m_viewIsEmbedded) {
+ NSPoint windowPoint = [m_view convertPoint:NSMakePoint(0, 0) toView:nil];
+ NSRect screenRect = [[m_view window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
NSPoint screenPoint = screenRect.origin;
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
- QSize size = QRectF::fromCGRect(NSRectToCGRect([m_contentView bounds])).toRect().size();
+ QSize size = QRectF::fromCGRect(NSRectToCGRect([m_view bounds])).toRect().size();
return QRect(position, size);
}
@@ -526,9 +509,9 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setCocoaGeometry" << window() << rect;
QMacAutoReleasePool pool;
- if (m_contentViewIsEmbedded) {
- if (m_qtView) {
- [m_qtView setFrame:NSMakeRect(0, 0, rect.width(), rect.height())];
+ if (m_viewIsEmbedded) {
+ if (window()->type() != Qt::ForeignWindow) {
+ [m_view setFrame:NSMakeRect(0, 0, rect.width(), rect.height())];
} else {
QPlatformWindow::setGeometry(rect);
}
@@ -548,10 +531,10 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
NSRect bounds = qt_mac_flipRect(rect);
[m_nsWindow setFrame:[m_nsWindow frameRectForContentRect:bounds] display:YES animate:NO];
} else {
- [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
+ [m_view setFrame:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
}
- if (!m_qtView)
+ if (window()->type() == Qt::ForeignWindow)
QPlatformWindow::setGeometry(rect);
// will call QPlatformWindow::setGeometry(rect) during resize confirmation (see qnsview.mm)
@@ -576,7 +559,7 @@ void QCocoaWindow::clipWindow(const NSRect &clipRect)
// Clipping top/left offsets the content. Move it back.
NSPoint contentViewOffset = NSMakePoint(qMax(CGFloat(0), NSMinX(clippedWindowRect) - NSMinX(windowFrame)),
qMax(CGFloat(0), NSMaxY(windowFrame) - NSMaxY(clippedWindowRect)));
- [m_contentView setBoundsOrigin:contentViewOffset];
+ [m_view setBoundsOrigin:contentViewOffset];
}
if (NSIsEmptyRect(clippedWindowRect)) {
@@ -662,7 +645,7 @@ void QCocoaWindow::setVisible(bool visible)
if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating
if (m_windowModality != window()->modality() || isNativeWindowTypeInconsistent())
- recreateWindow(parent());
+ recreateWindow(QPlatformWindow::parent());
// Register popup windows. The Cocoa platform plugin will forward mouse events
// to them and close them when needed.
@@ -747,8 +730,8 @@ void QCocoaWindow::setVisible(bool visible)
// In some cases, e.g. QDockWidget, the content view is hidden before moving to its own
// Cocoa window, and then shown again. Therefore, we test for the view being hidden even
// if it's attached to an NSWindow.
- if ([m_contentView isHidden])
- [m_contentView setHidden:NO];
+ if ([m_view isHidden])
+ [m_view setHidden:NO];
} else {
// qDebug() << "close" << this;
#ifndef QT_NO_OPENGL
@@ -781,7 +764,7 @@ void QCocoaWindow::setVisible(bool visible)
[mainWindow makeKeyWindow];
}
} else {
- [m_contentView setHidden:YES];
+ [m_view setHidden:YES];
}
removeMonitor();
@@ -946,7 +929,7 @@ void QCocoaWindow::setWindowTitle(const QString &title)
if (!m_nsWindow)
return;
- CFStringRef windowTitle = QCFString::toCFStringRef(title);
+ CFStringRef windowTitle = title.toCFString();
[m_nsWindow setTitle: const_cast<NSString *>(reinterpret_cast<const NSString *>(windowTitle))];
CFRelease(windowTitle);
}
@@ -958,7 +941,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
return;
QFileInfo fi(filePath);
- [m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
+ [m_nsWindow setRepresentedFilename:fi.exists() ? filePath.toNSString() : @""];
}
void QCocoaWindow::setWindowIcon(const QIcon &icon)
@@ -969,7 +952,7 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
if (iconButton == nil) {
if (icon.isNull())
return;
- NSString *title = QCFString::toNSString(window()->title());
+ NSString *title = window()->title().toNSString();
[m_nsWindow setRepresentedURL:[NSURL fileURLWithPath:title]];
iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
}
@@ -1080,9 +1063,9 @@ bool QCocoaWindow::isOpaque() const
// When ordering below the window must be tranclucent.
static GLint openglSourfaceOrder = qt_mac_resolveOption(1, "QT_MAC_OPENGL_SURFACE_ORDER");
- bool translucent = (window()->format().alphaBufferSize() > 0
+ bool translucent = window()->format().alphaBufferSize() > 0
|| window()->opacity() < 1
- || (m_qtView && [m_qtView hasMask]))
+ || [qnsview_cast(m_view) hasMask]
|| (surface()->supportsOpenGL() && openglSourfaceOrder == -1);
return !translucent;
}
@@ -1141,8 +1124,8 @@ void QCocoaWindow::setMask(const QRegion &region)
if (m_nsWindow)
[m_nsWindow setBackgroundColor:[NSColor clearColor]];
- [m_qtView setMaskRegion:&region];
- [m_nsWindow setOpaque: isOpaque()];
+ [qnsview_cast(m_view) setMaskRegion:&region];
+ [m_nsWindow setOpaque:isOpaque()];
}
bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
@@ -1171,7 +1154,7 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab)
WId QCocoaWindow::winId() const
{
- return WId(m_contentView);
+ return WId(m_view);
}
void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
@@ -1179,38 +1162,16 @@ void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setParent" << window() << (parentWindow ? parentWindow->window() : 0);
// recreate the window for compatibility
- bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden];
+ bool unhideAfterRecreate = parentWindow && !m_viewIsToBeEmbedded && ![m_view isHidden];
recreateWindow(parentWindow);
if (unhideAfterRecreate)
- [m_contentView setHidden:NO];
+ [m_view setHidden:NO];
setCocoaGeometry(geometry());
}
-NSView *QCocoaWindow::contentView() const
+NSView *QCocoaWindow::view() const
{
- return m_contentView;
-}
-
-void QCocoaWindow::setContentView(NSView *contentView)
-{
- // Remove and release the previous content view
- if (m_nsWindow)
- [m_nsWindow setContentView:nil];
- else
- [m_contentView removeFromSuperview];
-
- [m_contentView release];
-
- // Insert and retain the new content view
- [contentView retain];
- m_contentView = contentView;
- m_qtView = 0; // The new content view is not a QNSView.
- recreateWindow(parent()); // Adds the content view to parent NSView
-}
-
-QNSView *QCocoaWindow::qtView() const
-{
- return m_qtView;
+ return m_view;
}
NSWindow *QCocoaWindow::nativeWindow() const
@@ -1220,7 +1181,7 @@ NSWindow *QCocoaWindow::nativeWindow() const
void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
{
- m_contentViewIsToBeEmbedded = embedded;
+ m_viewIsToBeEmbedded = embedded;
// Release any previosly created NSWindow.
[m_nsWindow closeAndRelease];
m_nsWindow = 0;
@@ -1237,7 +1198,7 @@ void QCocoaWindow::windowDidMove()
if (m_isNSWindowChild)
return;
- [m_qtView updateGeometry];
+ [qnsview_cast(m_view) updateGeometry];
}
void QCocoaWindow::windowDidResize()
@@ -1249,14 +1210,14 @@ void QCocoaWindow::windowDidResize()
return;
clipChildWindows();
- [m_qtView updateGeometry];
+ [qnsview_cast(m_view) updateGeometry];
}
void QCocoaWindow::windowDidEndLiveResize()
{
if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) {
m_effectivelyMaximized = false;
- [m_qtView notifyWindowStateChanged:Qt::WindowNoState];
+ [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
}
}
@@ -1332,8 +1293,8 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
bool usesNSPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
// No child QNSWindow should notify its QNSView
- if (m_nsWindow && m_qtView && m_parentCocoaWindow && !oldParentCocoaWindow)
- [[NSNotificationCenter defaultCenter] removeObserver:m_qtView
+ if (m_nsWindow && (window()->type() != Qt::ForeignWindow) && m_parentCocoaWindow && !oldParentCocoaWindow)
+ [[NSNotificationCenter defaultCenter] removeObserver:m_view
name:nil object:m_nsWindow];
// Remove current window (if any)
@@ -1351,8 +1312,8 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
// Only non-child QNSWindows should notify their QNSViews
// (but don't register more than once).
- if (m_qtView && (noPreviousWindow || (wasNSWindowChild && !m_isNSWindowChild)))
- [[NSNotificationCenter defaultCenter] addObserver:m_qtView
+ if ((window()->type() != Qt::ForeignWindow) && (noPreviousWindow || (wasNSWindowChild && !m_isNSWindowChild)))
+ [[NSNotificationCenter defaultCenter] addObserver:m_view
selector:@selector(windowNotification:)
name:nil // Get all notifications
object:m_nsWindow];
@@ -1360,13 +1321,13 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
if (oldParentCocoaWindow) {
if (!m_isNSWindowChild || oldParentCocoaWindow != m_parentCocoaWindow)
oldParentCocoaWindow->removeChildWindow(this);
- m_forwardWindow.assign(oldParentCocoaWindow);
+ m_forwardWindow = oldParentCocoaWindow;
}
setNSWindow(m_nsWindow);
}
- if (m_contentViewIsToBeEmbedded) {
+ if (m_viewIsToBeEmbedded) {
// An embedded window doesn't have its own NSWindow.
} else if (!parentWindow) {
// QPlatformWindow subclasses must sync up with QWindow on creation:
@@ -1396,18 +1357,18 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
}
} else {
// Child windows have no NSWindow, link the NSViews instead.
- if ([m_contentView superview])
- [m_contentView removeFromSuperview];
+ if ([m_view superview])
+ [m_view removeFromSuperview];
- [m_parentCocoaWindow->m_contentView addSubview : m_contentView];
+ [m_parentCocoaWindow->m_view addSubview:m_view];
QRect rect = windowGeometry();
// Prevent setting a (0,0) window size; causes opengl context
// "Invalid Drawable" warnings.
if (rect.isNull())
rect.setSize(QSize(1, 1));
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
- [m_contentView setFrame:frame];
- [m_contentView setHidden: YES];
+ [m_view setFrame:frame];
+ [m_view setHidden:!window()->isVisible()];
}
m_nsWindow.ignoresMouseEvents =
@@ -1438,9 +1399,9 @@ void QCocoaWindow::reinsertChildWindow(QCocoaWindow *child)
void QCocoaWindow::requestActivateWindow()
{
- NSWindow *window = [m_contentView window];
- [ window makeFirstResponder : m_contentView ];
- [ window makeKeyWindow ];
+ NSWindow *window = [m_view window];
+ [window makeFirstResponder:m_view];
+ [window makeKeyWindow];
}
bool QCocoaWindow::shouldUseNSPanel()
@@ -1525,14 +1486,14 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
{
- if (window.contentView != m_contentView) {
- [m_contentView setPostsFrameChangedNotifications: NO];
- [m_contentView retain];
- if (m_contentView.superview) // m_contentView comes from another NSWindow
- [m_contentView removeFromSuperview];
- [window setContentView:m_contentView];
- [m_contentView release];
- [m_contentView setPostsFrameChangedNotifications: YES];
+ if (window.contentView != m_view) {
+ [m_view setPostsFrameChangedNotifications:NO];
+ [m_view retain];
+ if (m_view.superview) // m_view comes from another NSWindow
+ [m_view removeFromSuperview];
+ [window setContentView:m_view];
+ [m_view release];
+ [m_view setPostsFrameChangedNotifications:YES];
}
}
@@ -1590,7 +1551,7 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
return;
// if content view width or height is 0 then the window animations will crash so
// do nothing except set the new state
- NSRect contentRect = [contentView() frame];
+ NSRect contentRect = m_view.frame;
if (contentRect.size.width <= 0 || contentRect.size.height <= 0) {
qWarning("invalid window content view size, check your window geometry");
m_synchedWindowState = newState;
@@ -1699,8 +1660,8 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor)
// Othervise, set the cursor if this window is under the mouse. In
// this case QNSView::cursorUpdate will set the cursor as the pointer
// moves.
- if (m_nsWindow && m_qtView) {
- [m_nsWindow invalidateCursorRectsForView : m_qtView];
+ if (m_nsWindow && window()->type() != Qt::ForeignWindow) {
+ [m_nsWindow invalidateCursorRectsForView:m_view];
} else {
if (m_windowUnderMouse)
[cursor set];
@@ -1711,9 +1672,9 @@ void QCocoaWindow::registerTouch(bool enable)
{
m_registerTouchCount += enable ? 1 : -1;
if (enable && m_registerTouchCount == 1)
- [m_contentView setAcceptsTouchEvents:YES];
+ [m_view setAcceptsTouchEvents:YES];
else if (m_registerTouchCount == 0)
- [m_contentView setAcceptsTouchEvents:NO];
+ [m_view setAcceptsTouchEvents:NO];
}
void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness)
@@ -1813,7 +1774,7 @@ qreal QCocoaWindow::devicePixelRatio() const
// methods such as [NSWindow backingScaleFacor] might not give the correct
// result, for example if setWantsBestResolutionOpenGLSurface is not set or
// or ignored by the OpenGL driver.
- NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
+ NSSize backingSize = [m_view convertSizeToBacking:NSMakeSize(1.0, 1.0)];
return backingSize.height;
}
@@ -1823,8 +1784,8 @@ bool QCocoaWindow::isWindowExposable()
{
QSize size = geometry().size();
bool validGeometry = (size.width() > 0 && size.height() > 0);
- bool validScreen = ([[m_contentView window] screen] != 0);
- bool nonHiddenSuperView = ![[m_contentView superview] isHidden];
+ bool validScreen = ([[m_view window] screen] != 0);
+ bool nonHiddenSuperView = ![[m_view superview] isHidden];
return (validGeometry && validScreen && nonHiddenSuperView);
}
@@ -1936,11 +1897,11 @@ QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffsetStatic(QWindow *window)
QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffset() const
{
- if (!m_contentView)
+ if (!m_view)
return QPoint();
- const NSPoint origin = [m_contentView isFlipped] ? NSMakePoint(0, [m_contentView frame].size.height)
+ const NSPoint origin = [m_view isFlipped] ? NSMakePoint(0, [m_view frame].size.height)
: NSMakePoint(0, 0);
- const NSRect visibleRect = [m_contentView visibleRect];
+ const NSRect visibleRect = [m_view visibleRect];
return QPoint(visibleRect.origin.x, -visibleRect.origin.y + (origin.y - visibleRect.size.height));
}
@@ -1960,3 +1921,5 @@ void QCocoaWindow::setFrameStrutEventsEnabled(bool enabled)
{
m_frameStrutEventsEnabled = enabled;
}
+
+#include "moc_qcocoawindow.cpp"
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 721b0fb4d1..e09bb1e362 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -113,7 +113,7 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt)
if (err == noErr) {
PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
} else {
- qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QCFString::toQString(name).toLatin1().constData(), (int)err);
+ qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QString::fromCFString(name).toLatin1().constData(), (int)err);
}
resolvingBeforeDestruction = false;
}
@@ -139,7 +139,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
const long promise_id = (long)id;
// Find the kept promise
- const QString flavorAsQString = QCFString::toQString(flavor);
+ const QString flavorAsQString = QString::fromCFString(flavor);
QMacPasteboard::Promise promise;
for (int i = 0; i < qpaste->promises.size(); i++){
QMacPasteboard::Promise tmp = qpaste->promises[i];
@@ -380,7 +380,7 @@ QMacPasteboard::formats() const
const int type_count = CFArrayGetCount(types);
for (int i = 0; i < type_count; ++i) {
- const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
+ const QString flavor = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(types, i));
#ifdef DEBUG_PASTEBOARD
qDebug(" -%s", qPrintable(QString(flavor)));
#endif
@@ -423,7 +423,7 @@ QMacPasteboard::hasFormat(const QString &format) const
const int type_count = CFArrayGetCount(types);
for (int i = 0; i < type_count; ++i) {
- const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
+ const QString flavor = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(types, i));
#ifdef DEBUG_PASTEBOARD
qDebug(" -%s [0x%x]", qPrintable(QString(flavor)), mime_type);
#endif
@@ -487,13 +487,13 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
const int type_count = CFArrayGetCount(types);
for (int i = 0; i < type_count; ++i) {
CFStringRef flavor = static_cast<CFStringRef>(CFArrayGetValueAtIndex(types, i));
- if (c_flavor == QCFString::toQString(flavor)) {
+ if (c_flavor == QString::fromCFString(flavor)) {
QCFType<CFDataRef> macBuffer;
if (PasteboardCopyItemFlavorData(paste, id, flavor, &macBuffer) == noErr) {
QByteArray buffer((const char *)CFDataGetBytePtr(macBuffer), CFDataGetLength(macBuffer));
if (!buffer.isEmpty()) {
#ifdef DEBUG_PASTEBOARD
- qDebug(" - %s [%s] (%s)", qPrintable(format), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
+ qDebug(" - %s [%s] (%s)", qPrintable(format), qPrintable(QString::fromNSString(flavor)), qPrintable(c->convertorName()));
#endif
buffer.detach(); //detach since we release the macBuffer
retList.append(buffer);
@@ -502,7 +502,7 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
}
} else {
#ifdef DEBUG_PASTEBOARD
- qDebug(" - NoMatch %s [%s] (%s)", qPrintable(c_flavor), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
+ qDebug(" - NoMatch %s [%s] (%s)", qPrintable(c_flavor), qPrintable(QString::fromNSString(flavor)), qPrintable(c->convertorName()));
#endif
}
}
@@ -565,7 +565,7 @@ QString qt_mac_get_pasteboardString(PasteboardRef paste)
if (pb) {
NSString *text = [pb stringForType:NSStringPboardType];
if (text)
- return QCFString::toQString(text);
+ return QString::fromNSString(text);
}
return QString();
}
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index ee0bf75606..ca4df73e6d 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -267,16 +267,16 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)viewDidMoveToSuperview
{
- if (!(m_platformWindow->m_contentViewIsToBeEmbedded))
+ if (!(m_platformWindow->m_viewIsToBeEmbedded))
return;
if ([self superview]) {
- m_platformWindow->m_contentViewIsEmbedded = true;
+ m_platformWindow->m_viewIsEmbedded = true;
QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry());
m_platformWindow->updateExposedGeometry();
QWindowSystemInterface::flushWindowSystemEvents();
} else {
- m_platformWindow->m_contentViewIsEmbedded = false;
+ m_platformWindow->m_viewIsEmbedded = false;
}
}
@@ -338,7 +338,7 @@ static bool _q_dontOverrideCtrlLMB = false;
NSRect rect = [self frame];
NSRect windowRect = [[self window] frame];
geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
- } else if (m_platformWindow->m_contentViewIsToBeEmbedded) {
+ } else if (m_platformWindow->m_viewIsToBeEmbedded) {
// embedded child window, use the frame rect ### merge with case below
geometry = QRectF::fromCGRect(NSRectToCGRect([self bounds])).toRect();
} else {
@@ -368,7 +368,7 @@ static bool _q_dontOverrideCtrlLMB = false;
// Don't send the geometry change if the QWindow is designated to be
// embedded in a foreign view hiearchy but has not actually been
// embedded yet - it's too early.
- if (m_platformWindow->m_contentViewIsToBeEmbedded && !m_platformWindow->m_contentViewIsEmbedded)
+ if (m_platformWindow->m_viewIsToBeEmbedded && !m_platformWindow->m_viewIsEmbedded)
return;
// Send a geometry change event to Qt, if it's ready to handle events
@@ -401,7 +401,7 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)windowNotification : (NSNotification *) windowNotification
{
- //qDebug() << "windowNotification" << QCFString::toQString([windowNotification name]);
+ //qDebug() << "windowNotification" << QString::fromNSString([windowNotification name]);
NSString *notificationName = [windowNotification name];
if (notificationName == NSWindowDidBecomeKeyNotification) {
@@ -739,14 +739,17 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)handleMouseEvent:(NSEvent *)theEvent
{
- bool isTabletEvent = [self handleTabletEvent: theEvent];
+ // Tablet events may come in via the mouse event handlers,
+ // check if this is a valid tablet event first.
+ if ([self handleTabletEvent: theEvent])
+ return;
QPointF qtWindowPoint;
QPointF qtScreenPoint;
QNSView *targetView = self;
if (m_platformWindow && m_platformWindow->m_forwardWindow) {
if (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp)
- targetView = m_platformWindow->m_forwardWindow->m_qtView;
+ targetView = qnsview_cast(m_platformWindow->m_forwardWindow->view());
else
m_platformWindow->m_forwardWindow.clear();
}
@@ -756,7 +759,7 @@ static bool _q_dontOverrideCtrlLMB = false;
// Tooltips must be transparent for mouse events
// The bug reference is QTBUG-46379
if (!popup->m_windowFlags.testFlag(Qt::ToolTip)) {
- if (QNSView *popupView = popup->qtView())
+ if (QNSView *popupView = qnsview_cast(popup->view()))
targetView = popupView;
}
}
@@ -768,8 +771,8 @@ static bool _q_dontOverrideCtrlLMB = false;
nativeDrag->setLastMouseEvent(theEvent, self);
Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
- QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers,
- isTabletEvent ? Qt::MouseEventSynthesizedByQt : Qt::MouseEventNotSynthesized);
+ QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint,
+ m_buttons, keyboardModifiers, Qt::MouseEventNotSynthesized);
}
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent
@@ -1582,7 +1585,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
// ignore text for the U+F700-U+F8FF range. This is used by Cocoa when
// delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.)
if (!(modifiers & (Qt::ControlModifier | Qt::MetaModifier)) && (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff))
- text = QCFString::toQString(characters);
+ text = QString::fromNSString(characters);
QWindow *window = [self topLevelWindow];
@@ -1745,9 +1748,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QString commitString;
if ([aString length]) {
if ([aString isKindOfClass:[NSAttributedString class]]) {
- commitString = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
+ commitString = QString::fromCFString(reinterpret_cast<CFStringRef>([aString string]));
} else {
- commitString = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
+ commitString = QString::fromCFString(reinterpret_cast<CFStringRef>(aString));
};
}
QObject *fo = QGuiApplication::focusObject();
@@ -1777,7 +1780,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if ([aString isKindOfClass:[NSAttributedString class]]) {
// Preedit string has attribution
- preeditString = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
+ preeditString = QString::fromCFString(reinterpret_cast<CFStringRef>([aString string]));
int composingLength = preeditString.length();
int index = 0;
// Create attributes for individual sections of preedit text
@@ -1806,7 +1809,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
} else {
// No attributes specified, take only the preedit text.
- preeditString = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
+ preeditString = QString::fromCFString(reinterpret_cast<CFStringRef>(aString));
}
if (attrs.isEmpty()) {
@@ -1989,7 +1992,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];
// Add custom types supported by the application.
for (int i = 0; i < customTypes.size(); i++) {
- [supportedTypes addObject:QCFString::toNSString(customTypes[i])];
+ [supportedTypes addObject:customTypes[i].toNSString()];
}
[self registerForDraggedTypes:supportedTypes];
}
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index b96a9491e8..cbae4fc50f 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qnswindowdelegate.h"
+#include "qcocoahelpers.h"
#include <QDebug>
#include <qpa/qwindowsysteminterface.h>
@@ -60,7 +61,7 @@
if (m_cocoaWindow->m_windowUnderMouse) {
QPointF windowPoint;
QPointF screenPoint;
- [m_cocoaWindow->m_qtView convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
+ [qnsview_cast(m_cocoaWindow->view()) convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
QWindowSystemInterface::handleEnterEvent(m_cocoaWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
}
}
@@ -110,8 +111,8 @@
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
{
Q_UNUSED(newFrame);
- if (m_cocoaWindow && m_cocoaWindow->m_qtView)
- [m_cocoaWindow->m_qtView notifyWindowWillZoom:![window isZoomed]];
+ if (m_cocoaWindow && m_cocoaWindow->window()->type() != Qt::ForeignWindow)
+ [qnsview_cast(m_cocoaWindow->view()) notifyWindowWillZoom:![window isZoomed]];
return YES;
}
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 0b5b06c44f..8098c5e829 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -673,7 +673,7 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_DocumentName: {
CFStringRef name;
PMPrintSettingsGetJobName(d->settings(), &name);
- ret = QCFString::toQString(name);
+ ret = QString::fromCFString(name);
break;
}
case PPK_Duplex: {
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
index 2d107a6e27..b5065ba380 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
@@ -80,7 +80,7 @@ public:
bitmap.Reset();
D2D1_SIZE_U size = {
- width, height
+ UINT32(width), UINT32(height)
};
HRESULT hr = deviceContext->get()->CreateBitmap(size, data, pitch,
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
index bf96a7d683..f6b58d1ba6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
@@ -86,7 +86,7 @@ int QEglFSKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorP
return -1;
}
-static const char * const connector_type_names[] = {
+static const char * const connector_type_names[] = { // must match DRM_MODE_CONNECTOR_*
"None",
"VGA",
"DVI",
@@ -102,6 +102,8 @@ static const char * const connector_type_names[] = {
"HDMI",
"TV",
"eDP",
+ "Virtual",
+ "DSI"
};
static QByteArray nameForConnector(const drmModeConnectorPtr connector)
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 9fdf021d07..966d1a7e80 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -49,6 +49,7 @@
const char kImePlatformDataInputView[] = "inputView";
const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView";
+const char kImePlatformDataHideShortcutsBar[] = "hideShortcutsBar";
const char kImePlatformDataReturnKeyType[] = "returnKeyType";
@class QIOSLocaleListener;
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 02deab59b5..01cb3badea 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -521,6 +521,7 @@ bool QIOSMenu::eventFilter(QObject *obj, QEvent *event)
QVariantMap imPlatformData = queryEvent->value(Qt::ImPlatformData).toMap();
imPlatformData.insert(kImePlatformDataInputView, QVariant::fromValue(static_cast<void *>(m_pickerView)));
imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast<void *>(m_pickerView.toolbar)));
+ imPlatformData.insert(kImePlatformDataHideShortcutsBar, true);
queryEvent->setValue(Qt::ImPlatformData, imPlatformData);
queryEvent->setValue(Qt::ImEnabled, true);
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 3c95083e45..d7b0a323ad 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -236,6 +236,17 @@
self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease];
if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>()))
self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease];
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) {
+ if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) {
+ // According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar.
+ // However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes
+ // compiler warnings. And assigning just an empty array causes layout asserts. Hence, we assign empty button groups instead.
+ UIBarButtonItemGroup *leading = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease];
+ UIBarButtonItemGroup *trailing = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease];
+ self.inputAssistantItem.leadingBarButtonGroups = @[leading];
+ self.inputAssistantItem.trailingBarButtonGroups = @[trailing];
+ }
+ }
self.undoManager.groupsByEvent = NO;
[self rebuildUndoStack];
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index 938e63d95a..2a6e059243 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -5,7 +5,7 @@ android: SUBDIRS += android
!android: SUBDIRS += minimal
-!android:if(!win32|qtConfig(freetype)): SUBDIRS += offscreen
+!android:qtConfig(freetype): SUBDIRS += offscreen
qtConfig(xcb) {
SUBDIRS += xcb
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 79b5bbae41..fd7eca9e32 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -507,7 +507,7 @@ static const uint CmdTbl[] = { // Multimedia keys mapping table
Qt::Key_Open, // 30 0x1e APPCOMMAND_OPEN
Qt::Key_Close, // 31 0x1f APPCOMMAND_CLOSE
Qt::Key_Save, // 32 0x20 APPCOMMAND_SAVE
- Qt::Key_Print, // 33 0x21 APPCOMMAND_PRINT
+ Qt::Key_Printer, // 33 0x21 APPCOMMAND_PRINT
Qt::Key_Undo, // 34 0x22 APPCOMMAND_UNDO
Qt::Key_Redo, // 35 0x23 APPCOMMAND_REDO
Qt::Key_Copy, // 36 0x24 APPCOMMAND_COPY
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
index e9938894e6..f84688f045 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.cpp
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -369,6 +369,17 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint)
return QVariant();
}
+QVariant QWinRTTheme::themeHint(ThemeHint hint) const
+{
+ qCDebug(lcQpaTheme) << __FUNCTION__ << hint;
+ switch (hint) {
+ case StyleNames:
+ return QStringList() << QStringLiteral("fusion") << QStringLiteral("windows");
+ default:
+ return QPlatformTheme::themeHint(hint);
+ }
+}
+
const QPalette *QWinRTTheme::palette(Palette type) const
{
Q_D(const QWinRTTheme);
diff --git a/src/plugins/platforms/winrt/qwinrttheme.h b/src/plugins/platforms/winrt/qwinrttheme.h
index 2b8817d014..bd244f9fdb 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.h
+++ b/src/plugins/platforms/winrt/qwinrttheme.h
@@ -60,7 +60,7 @@ public:
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
static QVariant styleHint(QPlatformIntegration::StyleHint hint);
-
+ QVariant themeHint(ThemeHint hint) const override;
private:
QScopedPointer<QWinRTThemePrivate> d_ptr;
Q_DECLARE_PRIVATE(QWinRTTheme)
diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README
index 15cf4cf241..5efc9b7f99 100644
--- a/src/plugins/platforms/xcb/README
+++ b/src/plugins/platforms/xcb/README
@@ -21,3 +21,13 @@ REDUCING RUNTIME DEPENDENCIES
The '-qt-xcb' configure option can be used to get rid of most xcb- dependencies. Only libxcb will
still be linked dynamically, since it will be most likely be pulled in via other dependencies anyway.
This should allow for binaries that are portable across most modern Linux distributions.
+
+PACKAGE VERSION REQUIREMENTS
+
+When using touch input via XInput 2.2 or higher, there is a potential issue on systems that ship with
+a libXi older than 1.7.4. This is because XIAllowTouchEvents can deadlock with libXi 1.7.3 and earlier.
+When touch events are never received, this is not an issue, so plain mouse/keyboard systems are not affected.
+See http://lists.x.org/archives/xorg-devel/2014-July/043059.html for details on the libXi patch.
+Qt versions before 5.8 attempted to recognize this scenario based on the pkg-config package version and skip
+the call. This has been removed starting from 5.8 since relying on pkg-config package versions is unsafe given
+that Qt must also support systems with limited or incomplete pkg-config setups.
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
index d82a1f2d17..e52677d091 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
@@ -10,7 +10,6 @@ qtConfig(xcb-glx) {
DEFINES += XCB_HAS_XCB_GLX
QMAKE_USE += xcb_glx
}
-QMAKE_USE += xcb
LIBS += $$QMAKE_LIBS_DYNLOAD
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index b95ad4b5c9..f9c32cd0a4 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -275,8 +275,6 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
{
Q_ASSERT(QClipboard::Clipboard == 0);
Q_ASSERT(QClipboard::Selection == 1);
- m_xClipboard[QClipboard::Clipboard] = 0;
- m_xClipboard[QClipboard::Selection] = 0;
m_clientClipboard[QClipboard::Clipboard] = 0;
m_clientClipboard[QClipboard::Selection] = 0;
m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
@@ -329,6 +327,10 @@ QXcbClipboard::~QXcbClipboard()
}
free(reply);
}
+
+ if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection])
+ delete m_clientClipboard[QClipboard::Clipboard];
+ delete m_clientClipboard[QClipboard::Selection];
}
void QXcbClipboard::incrTransactionPeeker(xcb_generic_event_t *ge, bool &accepted)
@@ -378,9 +380,9 @@ QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode)
return m_clientClipboard[mode];
} else {
if (!m_xClipboard[mode])
- m_xClipboard[mode] = new QXcbClipboardMime(mode, this);
+ m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this));
- return m_xClipboard[mode];
+ return m_xClipboard[mode].data();
}
}
@@ -730,7 +732,7 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve
// here we care only about the xfixes events that come from non Qt processes
if (event->owner != XCB_NONE && event->owner != owner()) {
if (!m_xClipboard[mode]) {
- m_xClipboard[mode] = new QXcbClipboardMime(mode, this);
+ m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this));
} else {
m_xClipboard[mode]->reset();
}
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h
index 58c7f32c4c..ffd565c56f 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.h
+++ b/src/plugins/platforms/xcb/qxcbclipboard.h
@@ -98,7 +98,7 @@ private:
QClipboard::Mode modeForAtom(xcb_atom_t atom) const;
// Selection and Clipboard
- QXcbClipboardMime *m_xClipboard[2];
+ QScopedPointer<QXcbClipboardMime> m_xClipboard[2];
QMimeData *m_clientClipboard[2];
xcb_timestamp_t m_timestamp[2];
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 1147fc82b2..93f8db92bf 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -697,26 +697,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
if (m_xiGrab) {
// XIAllowTouchEvents deadlocks with libXi < 1.7.4 (this has nothing to do with the XI2 versions like 2.2)
// http://lists.x.org/archives/xorg-devel/2014-July/043059.html
-#ifndef XCB_USE_XINPUT2
- static bool allowTouchWarningShown = false;
- if (!allowTouchWarningShown) {
- allowTouchWarningShown = true;
- qWarning("Skipping XIAllowTouchEvents() because it was not possible to detect libXi version at build time."
- " Minimum libXi version required is 1.7.4."
- " Expect issues with touch behavior.");
- }
-#elif QT_LIBRARY_VERSION(xinput2) < QT_VERSION_CHECK(1, 7, 4)
- static bool allowTouchWarningShown = false;
- if (!allowTouchWarningShown) {
- allowTouchWarningShown = true;
- qWarning("Skipping XIAllowTouchEvents() due to not having libXi >= 1.7.4."
- " libXi version at build time was %d.%d.%d."
- " Expect issues with touch behavior.",
- QT_LIBRARY_VERSION_MAJOR(xinput2),
- QT_LIBRARY_VERSION_MINOR(xinput2),
- QT_LIBRARY_VERSION_PATCH(xinput2));
- }
-#else
+#ifdef XCB_USE_XINPUT2
XIAllowTouchEvents(static_cast<Display *>(m_xlib_display), xiDeviceEvent->deviceid,
xiDeviceEvent->detail, xiDeviceEvent->event, XIAcceptTouch);
#endif
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index 11e0c998b1..4de4be43d1 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -359,17 +359,27 @@ void QXcbCursor::changeCursor(QCursor *cursor, QWindow *widget)
return;
xcb_cursor_t c = XCB_CURSOR_NONE;
+ bool isBitmapCursor = false;
+
if (cursor) {
- const QXcbCursorCacheKey key(*cursor);
- CursorHash::iterator it = m_cursorHash.find(key);
- if (it == m_cursorHash.end()) {
- const Qt::CursorShape shape = cursor->shape();
- it = m_cursorHash.insert(key, shape == Qt::BitmapCursor ? createBitmapCursor(cursor) : createFontCursor(shape));
+ const Qt::CursorShape shape = cursor->shape();
+ isBitmapCursor = shape == Qt::BitmapCursor;
+
+ if (!isBitmapCursor) {
+ const QXcbCursorCacheKey key(*cursor);
+ CursorHash::iterator it = m_cursorHash.find(key);
+ if (it == m_cursorHash.end()) {
+ it = m_cursorHash.insert(key, createFontCursor(shape));
+ }
+ c = it.value();
+ } else {
+ // Do not cache bitmap cursors, as otherwise they have unclear
+ // lifetime (we effectively leak xcb_cursor_t).
+ c = createBitmapCursor(cursor);
}
- c = it.value();
}
- w->setCursor(c);
+ w->setCursor(c, isBitmapCursor);
}
static int cursorIdForShape(int cshape)
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 802f7b85ce..b0c5ac79f9 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -61,13 +61,8 @@
#include <stdio.h>
-//this has to be included before egl, since egl pulls in X headers
#include <QtGui/private/qguiapplication_p.h>
-#ifdef XCB_USE_EGL
-# include <QtPlatformSupport/private/qt_egl_p.h>
-#endif
-
#ifdef XCB_USE_XLIB
#include <X11/Xlib.h>
#endif
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 189ec53050..b1575cbee4 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -57,10 +57,6 @@
#include <QtPlatformHeaders/qxcbintegrationfunctions.h>
#include <QtPlatformHeaders/qxcbscreenfunctions.h>
-#ifndef QT_NO_DBUS
-#include "QtPlatformSupport/private/qdbusmenuconnection_p.h"
-#endif
-
#ifdef XCB_USE_XLIB
# include <X11/Xlib.h>
#else
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index 8728b6e937..acecbf4116 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -53,7 +53,6 @@ class QWidget;
class QXcbScreen;
class QXcbConnection;
class QXcbNativeInterfaceHandler;
-class QDBusMenuConnection;
class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
{
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index c81858c408..ee7bfd6c53 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -258,7 +258,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
free_prop = true;
}
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
static const QTextCodec* mapper = QTextCodec::codecForLocale();
int errCode = 0;
if (mapper) {
@@ -274,6 +274,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
mapper = QTextCodec::codecForName("latin1");
if (!mapper || !mapper->canEncode(s))
return Q_NULLPTR;
+#endif
static QByteArray qcs;
qcs = s.toLatin1();
tp.value = (uchar*)qcs.data();
@@ -281,6 +282,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
tp.format = 8;
tp.nitems = qcs.length();
free_prop = false;
+#if QT_CONFIG(textcodec)
}
#endif
return &tp;
@@ -326,6 +328,7 @@ QXcbWindow::QXcbWindow(QWindow *window)
, m_lastWindowStateEvent(-1)
, m_syncState(NoSyncNeeded)
, m_pendingSyncRequest(0)
+ , m_currentBitmapCursor(XCB_CURSOR_NONE)
{
setConnection(xcbScreen()->connection());
}
@@ -600,6 +603,9 @@ void QXcbWindow::create()
QXcbWindow::~QXcbWindow()
{
+ if (m_currentBitmapCursor != XCB_CURSOR_NONE) {
+ xcb_free_cursor(xcb_connection(), m_currentBitmapCursor);
+ }
if (window()->type() != Qt::ForeignWindow)
destroy();
else {
@@ -2416,6 +2422,17 @@ static inline int fixed1616ToInt(FP1616 val)
return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF);
}
+void QXcbWindow::handleXIMouseButtonState(const xcb_ge_event_t *event)
+{
+ QXcbConnection *conn = connection();
+ const xXIDeviceEvent *ev = reinterpret_cast<const xXIDeviceEvent *>(event);
+ if (ev->buttons_len > 0) {
+ unsigned char *buttonMask = (unsigned char *) &ev[1];
+ for (int i = 1; i <= 15; ++i)
+ conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i));
+ }
+}
+
// With XI 2.2+ press/release/motion comes here instead of the above handlers.
void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source)
{
@@ -2431,12 +2448,6 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail);
- if (ev->buttons_len > 0) {
- unsigned char *buttonMask = (unsigned char *) &ev[1];
- for (int i = 1; i <= 15; ++i)
- conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i));
- }
-
const char *sourceName = 0;
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) {
const QMetaObject *metaObject = qt_getEnumMetaObject(source);
@@ -2446,18 +2457,23 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
switch (ev->evtype) {
case XI_ButtonPress:
+ handleXIMouseButtonState(event);
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName);
conn->setButton(button, true);
handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source);
break;
case XI_ButtonRelease:
+ handleXIMouseButtonState(event);
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName);
conn->setButton(button, false);
handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source);
break;
case XI_Motion:
+ // Here we do NOT call handleXIMouseButtonState because we don't expect button state change to be bundled with motion.
+ // When a touchscreen is pressed, an XI_Motion event occurs in which XIMaskIsSet says the left button is pressed,
+ // but we don't want QGuiApplicationPrivate::processMouseEvent() to react by generating a mouse press event.
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName);
handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source);
@@ -2669,10 +2685,22 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab)
return result;
}
-void QXcbWindow::setCursor(xcb_cursor_t cursor)
+void QXcbWindow::setCursor(xcb_cursor_t cursor, bool isBitmapCursor)
{
- xcb_change_window_attributes(xcb_connection(), m_window, XCB_CW_CURSOR, &cursor);
- xcb_flush(xcb_connection());
+ xcb_connection_t *conn = xcb_connection();
+
+ xcb_change_window_attributes(conn, m_window, XCB_CW_CURSOR, &cursor);
+ xcb_flush(conn);
+
+ if (m_currentBitmapCursor != XCB_CURSOR_NONE) {
+ xcb_free_cursor(conn, m_currentBitmapCursor);
+ }
+
+ if (isBitmapCursor) {
+ m_currentBitmapCursor = cursor;
+ } else {
+ m_currentBitmapCursor = XCB_CURSOR_NONE;
+ }
}
void QXcbWindow::windowEvent(QEvent *event)
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index f62938ba8a..92f3f7a67c 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -103,7 +103,7 @@ public:
bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE;
bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE;
- void setCursor(xcb_cursor_t cursor);
+ void setCursor(xcb_cursor_t cursor, bool isBitmapCursor);
QSurfaceFormat format() const Q_DECL_OVERRIDE;
@@ -139,6 +139,7 @@ public:
void handleFocusOutEvent(const xcb_focus_out_event_t *event) Q_DECL_OVERRIDE;
void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) Q_DECL_OVERRIDE;
#ifdef XCB_USE_XINPUT22
+ void handleXIMouseButtonState(const xcb_ge_event_t *);
void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) Q_DECL_OVERRIDE;
void handleXIEnterLeave(xcb_ge_event_t *) Q_DECL_OVERRIDE;
#endif
@@ -271,6 +272,7 @@ protected:
SyncState m_syncState;
QXcbSyncWindowRequest *m_pendingSyncRequest;
+ xcb_cursor_t m_currentBitmapCursor;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
index 20481e4834..a1dec2b0b5 100644
--- a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
+++ b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
@@ -11,8 +11,7 @@ XCB_DIR = ../../../../3rdparty/xcb
INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/include/xcb $$XCB_DIR/sysinclude
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
-QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
+QMAKE_USE += xcb/nolink
# ignore compiler warnings in 3rdparty code
QMAKE_CFLAGS_STATIC_LIB+=-w
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index ec0fa68871..246bb1f118 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -66,9 +66,6 @@ include(gl_integrations/gl_integrations.pri)
CONFIG += qpa/genericunixfontdatabase
-qtConfig(dbus-linked): \
- QT += dbus
-
!qtConfig(system-xcb) {
DEFINES += XCB_USE_RENDER
XCB_DIR = ../../../3rdparty/xcb