summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm15
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm8
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp75
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm7
8 files changed, 93 insertions, 23 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 00ab3409d3..07a6b52dbe 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -791,7 +791,7 @@ void QAndroidInputContext::longPress(int x, int y)
return;
}
QList<QInputMethodEvent::Attribute> imAttributes;
- imAttributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, 0, QVariant()));
+ imAttributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
imAttributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, anchor, cursor - anchor, QVariant()));
QInputMethodEvent event(QString(), imAttributes);
QGuiApplication::sendEvent(m_focusObject, &event);
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index 470da63e3d..acddc3ecc8 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -81,6 +81,7 @@ public:
QPlatformTextureList *textures, bool translucentBackground) override;
#endif
+ QImage toImage() const override;
QPlatformGraphicsBuffer *graphicsBuffer() const override;
private:
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index e786ecb5a5..cff1f96615 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -534,6 +534,21 @@ void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion &regio
}
#endif
+QImage QCALayerBackingStore::toImage() const
+{
+ if (!const_cast<QCALayerBackingStore*>(this)->prepareForFlush())
+ return QImage();
+
+ // We need to make a copy here, as the returned image could be used just
+ // for reading, in which case it won't detach, and then the underlying
+ // image data might change under the feet of the client when we re-use
+ // the buffer at a later point.
+ m_buffers.back()->lock(QPlatformGraphicsBuffer::SWReadAccess);
+ QImage imageCopy = m_buffers.back()->asImage()->copy();
+ m_buffers.back()->unlock();
+ return imageCopy;
+}
+
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
{
return m_buffers.back().get();
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 0d7eab9a94..06e3dfd3b6 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1086,9 +1086,11 @@ void QCocoaWindow::setEmbeddedInForeignView()
void QCocoaWindow::viewDidChangeFrame()
{
- if (isContentView())
- return; // Handled below
-
+ // Note: When the view is the content view, it would seem redundant
+ // to deliver geometry changes both from windowDidResize and this
+ // callback, but in some cases such as when macOS native tabbed
+ // windows are enabled we may end up with the wrong geometry in
+ // the initial windowDidResize callback when a new tab is created.
handleGeometryChange();
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 80517ffe69..6c1f5c8f93 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1325,6 +1325,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return false;
platformWindow->setFlag(QWindowsWindow::WithinDpiChanged);
const RECT *prcNewWindow = reinterpret_cast<RECT *>(lParam);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << "WM_DPICHANGED"
+ << platformWindow->window() << *prcNewWindow;
SetWindowPos(hwnd, nullptr, prcNewWindow->left, prcNewWindow->top,
prcNewWindow->right - prcNewWindow->left,
prcNewWindow->bottom - prcNewWindow->top, SWP_NOZORDER | SWP_NOACTIVATE);
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 0520f88935..94608bfd82 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -240,7 +240,8 @@ QWindow *QWindowsScreen::topLevelAt(const QPoint &point) const
QWindow *result = nullptr;
if (QWindow *child = QWindowsScreen::windowAt(point, CWP_SKIPINVISIBLE))
result = QWindowsWindow::topLevelOf(child);
- qCDebug(lcQpaWindows) <<__FUNCTION__ << point << result;
+ if (QWindowsContext::verbose > 1)
+ qCDebug(lcQpaWindows) <<__FUNCTION__ << point << result;
return result;
}
@@ -250,7 +251,8 @@ QWindow *QWindowsScreen::windowAt(const QPoint &screenPoint, unsigned flags)
if (QPlatformWindow *bw = QWindowsContext::instance()->
findPlatformWindowAt(GetDesktopWindow(), screenPoint, flags))
result = bw->window();
- qCDebug(lcQpaWindows) <<__FUNCTION__ << screenPoint << " returns " << result;
+ if (QWindowsContext::verbose > 1)
+ qCDebug(lcQpaWindows) <<__FUNCTION__ << screenPoint << " returns " << result;
return result;
}
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index a36317c70a..8ef0974c9c 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -184,6 +184,7 @@ static inline RECT RECTfromQRect(const QRect &rect)
return result;
}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const RECT &r)
{
@@ -262,6 +263,16 @@ QDebug operator<<(QDebug d, const GUID &guid)
}
#endif // !QT_NO_DEBUG_STREAM
+static void formatBriefRectangle(QDebug &d, const QRect &r)
+{
+ d << r.width() << 'x' << r.height() << forcesign << r.x() << r.y() << noforcesign;
+}
+
+static void formatBriefMargins(QDebug &d, const QMargins &m)
+{
+ d << m.left() << ", " << m.top() << ", " << m.right() << ", " << m.bottom();
+}
+
// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT
// is in workspace/available area coordinates.
static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
@@ -1676,6 +1687,51 @@ QRect QWindowsWindow::normalGeometry() const
return frame.isValid() ? frame.marginsRemoved(margins) : frame;
}
+static QString msgUnableToSetGeometry(const QWindowsWindow *platformWindow,
+ const QRect &requestedRect,
+ const QRect &obtainedRect,
+ const QMargins &fullMargins,
+ const QMargins &customMargins)
+{
+ QString result;
+ QDebug debug(&result);
+ debug.nospace();
+ debug.noquote();
+ const auto window = platformWindow->window();
+ debug << "Unable to set geometry ";
+ formatBriefRectangle(debug, requestedRect);
+ debug << " (frame: ";
+ formatBriefRectangle(debug, requestedRect + fullMargins);
+ debug << ") on " << window->metaObject()->className() << "/\""
+ << window->objectName() << "\" on \"" << window->screen()->name()
+ << "\". Resulting geometry: ";
+ formatBriefRectangle(debug, obtainedRect);
+ debug << " (frame: ";
+ formatBriefRectangle(debug, obtainedRect + fullMargins);
+ debug << ") margins: ";
+ formatBriefMargins(debug, fullMargins);
+ if (!customMargins.isNull()) {
+ debug << " custom margin: ";
+ formatBriefMargins(debug, customMargins);
+ }
+ const auto minimumSize = window->minimumSize();
+ const bool hasMinimumSize = !minimumSize.isEmpty();
+ if (hasMinimumSize)
+ debug << " minimum size: " << minimumSize.width() << 'x' << minimumSize.height();
+ const auto maximumSize = window->maximumSize();
+ const bool hasMaximumSize = maximumSize.width() != QWINDOWSIZE_MAX || maximumSize.height() != QWINDOWSIZE_MAX;
+ if (hasMaximumSize)
+ debug << " maximum size: " << maximumSize.width() << 'x' << maximumSize.height();
+ if (hasMinimumSize || hasMaximumSize) {
+ MINMAXINFO minmaxInfo;
+ memset(&minmaxInfo, 0, sizeof(minmaxInfo));
+ platformWindow->getSizeHints(&minmaxInfo);
+ debug << ' ' << minmaxInfo;
+ }
+ debug << ')';
+ return result;
+}
+
void QWindowsWindow::setGeometry(const QRect &rectIn)
{
QRect rect = rectIn;
@@ -1695,21 +1751,10 @@ void QWindowsWindow::setGeometry(const QRect &rectIn)
setGeometry_sys(rect);
clearFlag(WithinSetGeometry);
if (m_data.geometry != rect && (isVisible() || QLibraryInfo::isDebugBuild())) {
- qWarning("%s: Unable to set geometry %dx%d+%d+%d on %s/'%s'."
- " Resulting geometry: %dx%d+%d+%d "
- "(frame: %d, %d, %d, %d, custom margin: %d, %d, %d, %d"
- ", minimum size: %dx%d, maximum size: %dx%d).",
- __FUNCTION__,
- rect.width(), rect.height(), rect.x(), rect.y(),
- window()->metaObject()->className(), qPrintable(window()->objectName()),
- m_data.geometry.width(), m_data.geometry.height(),
- m_data.geometry.x(), m_data.geometry.y(),
- m_data.fullFrameMargins.left(), m_data.fullFrameMargins.top(),
- m_data.fullFrameMargins.right(), m_data.fullFrameMargins.bottom(),
- m_data.customMargins.left(), m_data.customMargins.top(),
- m_data.customMargins.right(), m_data.customMargins.bottom(),
- window()->minimumWidth(), window()->minimumHeight(),
- window()->maximumWidth(), window()->maximumHeight());
+ const auto warning =
+ msgUnableToSetGeometry(this, rectIn, m_data.geometry,
+ m_data.fullFrameMargins, m_data.customMargins);
+ qWarning("%s: %s", __FUNCTION__, qPrintable(warning));
}
} else {
QPlatformWindow::setGeometry(rect);
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 288e4cd29a..3474e82c13 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -4290,12 +4290,15 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
alpha:pc.alphaF()];
s = qt_mac_removeMnemonics(s);
- const auto textRect = CGRectMake(xpos, yPos, mi->rect.width() - xm - tabwidth + 1, mi->rect.height());
QMacCGContext cgCtx(p);
d->setupNSGraphicsContext(cgCtx, YES);
- [s.toNSString() drawInRect:textRect
+ // Draw at point instead of in rect, as the rect we've computed for the menu item
+ // is based on the font metrics we got from HarfBuzz, so we may risk having CoreText
+ // line-break the string if it doesn't fit the given rect. It's better to draw outside
+ // the rect and possibly overlap something than to have part of the text disappear.
+ [s.toNSString() drawAtPoint:CGPointMake(xpos, yPos)
withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c,
NSObliquenessAttributeName: [NSNumber numberWithDouble: myFont.italic() ? 0.3 : 0.0]}];