diff options
Diffstat (limited to 'src/plugins/platforms/windows')
6 files changed, 58 insertions, 23 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 5757bcad4e..792e79df19 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -1095,7 +1095,7 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, xform.eDx = margin; xform.eDy = margin; - HDC hdc = CreateCompatibleDC(QWindowsContext::instance()->displayContext()); + const HDC hdc = m_fontEngineData->hdc; SetGraphicsMode(hdc, GM_ADVANCED); SetWorldTransform(hdc, &xform); @@ -1107,8 +1107,16 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, memset(&mat, 0, sizeof(mat)); mat.eM11.value = mat.eM22.value = 1; - if (GetGlyphOutline(hdc, glyph, ggo_options, &tgm, 0, 0, &mat) == GDI_ERROR) { - qWarning("QWinFontEngine: unable to query transformed glyph metrics..."); + const DWORD result = GetGlyphOutline(hdc, glyph, ggo_options, &tgm, 0, 0, &mat); + + XFORM identity = {1, 0, 0, 1, 0, 0}; + SetWorldTransform(hdc, &identity); + SetGraphicsMode(hdc, GM_COMPATIBLE); + SelectObject(hdc, old_font); + + if (result == GDI_ERROR) { + const int errorCode = GetLastError(); + qErrnoWarning(errorCode, "QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error %d)...", errorCode); return 0; } @@ -1117,10 +1125,6 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph, xform.eDx -= tgm.gmptGlyphOrigin.x; xform.eDy += tgm.gmptGlyphOrigin.y; - - SetGraphicsMode(hdc, GM_COMPATIBLE); - SelectObject(hdc, old_font); - DeleteDC(hdc); } #else // else wince unsigned int options = 0; @@ -1412,5 +1416,11 @@ void QWindowsMultiFontEngine::loadEngine(int at) // TODO: increase cost in QFontCache for the font engine loaded here } +bool QWindowsFontEngine::supportsTransformation(const QTransform &transform) const +{ + // Support all transformations for ttf files, and translations for raster fonts + return ttf || transform.type() <= QTransform::TxTranslate; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h index 2bf6ead503..9e92a8fbff 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.h +++ b/src/plugins/platforms/windows/qwindowsfontengine.h @@ -123,6 +123,7 @@ public: virtual QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, const QTransform &xform); virtual QFontEngine *cloneWithSize(qreal pixelSize) const; + virtual bool supportsTransformation(const QTransform &transform) const; #ifndef Q_CC_MINGW virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index ae66ef8a3d..f6dda04c13 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -613,8 +613,12 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext, const HGLRC result = staticContext.wglCreateContextAttribsARB(hdc, shared, attributes); - if (!result) - qErrnoWarning("%s: wglCreateContextAttribsARB() failed.", __FUNCTION__); + if (!result) { + QString message; + QDebug(&message).nospace() << __FUNCTION__ << ": wglCreateContextAttribsARB() failed (GL error code: 0x" + << hex << glGetError() << dec << ") for format: " << format << ", shared context: " << shared; + qErrnoWarning("%s", qPrintable(message)); + } return result; } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index dd16ea1c6f..fd00a07d6c 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -237,8 +237,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); if (QWindowsContext::verboseEvents) qDebug() << "Automatic mouse capture " << window; - // Implement "Click to focus" for native child windows. - if (!window->isTopLevel() && QGuiApplication::focusWindow() != window) + // Implement "Click to focus" for native child windows (unless it is a native widget window). + if (!window->isTopLevel() && !window->inherits("QWidgetWindow") && QGuiApplication::focusWindow() != window) window->requestActivate(); } else if (platformWindow->hasMouseCapture() && platformWindow->testFlag(QWindowsWindow::AutoMouseCapture) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 010197d6d8..73c78f0090 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -203,10 +203,9 @@ static inline QSize clientSize(HWND hwnd) return qSizeOfRect(rect); } -// from qwidget_win.cpp -static bool shouldShowMaximizeButton(const QWindow *w) +// from qwidget_win.cpp, pass flags separately in case they have been "autofixed". +static bool shouldShowMaximizeButton(const QWindow *w, Qt::WindowFlags flags) { - const Qt::WindowFlags flags = w->flags(); if ((flags & Qt::MSWindowsFixedSizeDialogHint) || !(flags & Qt::WindowMaximizeButtonHint)) return false; // if the user explicitly asked for the maximize button, we try to add @@ -333,6 +332,25 @@ QDebug operator<<(QDebug debug, const WindowCreationData &d) return debug; } +// Fix top level window flags in case only the type flags are passed. +static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags) +{ + switch (flags) { + case Qt::Window: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + |Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint; + break; + case Qt::Dialog: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; + break; + case Qt::Tool: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; + break; + default: + break; + } +} + void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn, unsigned creationFlags) { @@ -359,10 +377,8 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag topLevel = (creationFlags & ForceTopLevel) ? true : w->isTopLevel(); } - if (topLevel && flags == 1) { - flags |= Qt::WindowTitleHint|Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint - |Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint; - } + if (topLevel) + fixTopLevelWindowFlags(flags); type = static_cast<Qt::WindowType>(int(flags) & Qt::WindowType_Mask); switch (type) { @@ -433,7 +449,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag style |= WS_SYSMENU; if (flags & Qt::WindowMinimizeButtonHint) style |= WS_MINIMIZEBOX; - if (shouldShowMaximizeButton(w)) + if (shouldShowMaximizeButton(w, flags)) style |= WS_MAXIMIZEBOX; if (tool) exStyle |= WS_EX_TOOLWINDOW; @@ -775,7 +791,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : QPlatformWindow(aWindow), m_data(data), - m_flags(0), + m_flags(WithinCreate), m_hdc(0), m_windowState(Qt::WindowNoState), m_opacity(1.0), @@ -826,6 +842,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : const qreal opacity = qt_window_private(aWindow)->opacity; if (!qFuzzyCompare(opacity, qreal(1.0))) setOpacity(opacity); + clearFlag(WithinCreate); } QWindowsWindow::~QWindowsWindow() @@ -1481,8 +1498,10 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) if (visible) newStyle |= WS_VISIBLE; setStyle(newStyle); - - const QRect r = effectiveScreen(window())->geometry(); + // Use geometry of QWindow::screen() within creation or the virtual screen the + // window is in (QTBUG-31166, QTBUG-30724). + const QScreen *screen = testFlag(WithinCreate) ? window()->screen() : effectiveScreen(window()); + const QRect r = screen->geometry(); const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE; const bool wasSync = testFlag(SynchronousGeometryChangeEvent); setFlag(SynchronousGeometryChangeEvent); diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 6c735ede7d..07f3976d87 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -134,7 +134,8 @@ public: WithinDestroy = 0x1000, TouchRegistered = 0x2000, AlertState = 0x4000, - Exposed = 0x08000 + Exposed = 0x08000, + WithinCreate = 0x10000 }; struct WindowData |