diff options
Diffstat (limited to 'src/plugins/platforms/windows')
51 files changed, 1628 insertions, 1424 deletions
diff --git a/src/plugins/platforms/windows/accessible/accessible.pri b/src/plugins/platforms/windows/accessible/accessible.pri index 08a37a4733..e26c6614e2 100644 --- a/src/plugins/platforms/windows/accessible/accessible.pri +++ b/src/plugins/platforms/windows/accessible/accessible.pri @@ -8,10 +8,10 @@ HEADERS += \ $$PWD/qwindowsaccessibility.h \ $$PWD/comutils.h -!win32-g++*: { +!mingw: { SOURCES += $$PWD/iaccessible2.cpp HEADERS += $$PWD/iaccessible2.h include(../../../../3rdparty/iaccessible2/iaccessible2.pri) } -win32-g++*: LIBS *= -luuid
\ No newline at end of file +mingw: LIBS *= -luuid
\ No newline at end of file diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index 66ed9d85dc..7f2ed86404 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -59,10 +59,10 @@ HRESULT STDMETHODCALLTYPE AccessibleApplication::QueryInterface(REFIID id, LPVOI { *iface = 0; if (id == IID_IUnknown) { - accessibleDebug("AccessibleApplication::QI(): IID_IUnknown"); + qCDebug(lcQpaAccessibility) << "AccessibleApplication::QI(): IID_IUnknown"; *iface = (IUnknown*)this; } else if (id == IID_IAccessibleApplication) { - accessibleDebug("AccessibleApplication::QI(): IID_IAccessibleApplication"); + qCDebug(lcQpaAccessibility) << "AccessibleApplication::QI(): IID_IAccessibleApplication"; *iface = static_cast<IAccessibleApplication*>(this); } @@ -476,7 +476,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_uniqueID(long *outUniqueID) if (!accessible) return E_FAIL; - accessibleDebug("uniqueID: %08x", id); + qCDebug(lcQpaAccessibility) << "uniqueID: " << showbase << hex << id; *outUniqueID = (long)id; return int(id) < 0 ? S_OK : S_FALSE; @@ -841,7 +841,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_cellAt( long row, long colu *cell = QWindowsAccessibility::wrap(qtCell); } } - accessibleDebug("found cell? %p", *cell); + qCDebug(lcQpaAccessibility) << "found cell? " << *cell; return *cell ? S_OK : S_FALSE; } @@ -1574,7 +1574,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryService(REFGUID guidServic return E_POINTER; Q_UNUSED(guidService); *iface = 0; - accessibleDebug("QWindowsIA2Accessible::QS(): %s", IIDToString(riid).constData()); + qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QS(): " << IIDToString(riid); if (guidService == IID_IAccessible) { diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 885bc37cff..307f2fc3bb 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -100,6 +100,25 @@ QWindowsAccessibility::QWindowsAccessibility() { } +// Retrieve sound name by checking the icon property of a message box +static inline QString messageBoxAlertSound(const QObject *messageBox) +{ + enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon + Information = 1, + Warning = 2, + Critical = 3 + }; + switch (messageBox->property("icon").toInt()) { + case Information: + return QStringLiteral("SystemAsterisk"); + case Warning: + return QStringLiteral("SystemExclamation"); + case Critical: + return QStringLiteral("SystemHand"); + } + return QString(); +} + void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { QString soundName; @@ -113,32 +132,8 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) break; case QAccessible::Alert: - { - /* ### FIXME -#ifndef QT_NO_MESSAGEBOX - QMessageBox *mb = qobject_cast<QMessageBox*>(o); - if (mb) { - switch (mb->icon()) { - case QMessageBox::Warning: - soundName = QLatin1String("SystemExclamation"); - break; - case QMessageBox::Critical: - soundName = QLatin1String("SystemHand"); - break; - case QMessageBox::Information: - soundName = QLatin1String("SystemAsterisk"); - break; - default: - break; - } - } else -#endif // QT_NO_MESSAGEBOX -*/ - { - soundName = QLatin1String("SystemAsterisk"); - } - - } + soundName = event->object()->inherits("QMessageBox") ? + messageBoxAlertSound(event->object()) : QStringLiteral("SystemAsterisk"); break; default: break; diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 7c7c33616e..bda806d102 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -185,23 +185,10 @@ HRESULT STDMETHODCALLTYPE QWindowsEnumerate::Skip(unsigned long celt) return S_OK; } -#ifndef QT_NO_DEBUG -bool debug_accessibility() -{ - static int debugging = -1; - if (debugging == -1) - debugging = qgetenv("QT_DEBUG_ACCESSIBILITY").toInt(); - return !!debugging; -} -#endif - #if defined(DEBUG_SHOW_ATCLIENT_COMMANDS) void accessibleDebugClientCalls_helper(const char* funcName, const QAccessibleInterface *iface) { - QString str; - QDebug dbg(&str); - dbg << iface << QLatin1String(funcName); - accessibleDebug("%s", qPrintable(str)); + qCDebug(lcQpaAccessibility) << iface << funcName; } #endif @@ -216,10 +203,8 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::QueryInterface(REFIID id, LPVO QByteArray strIID = IIDToString(id); if (!strIID.isEmpty()) { - QString ss; - QDebug dbg(&ss); - dbg << accessibleInterface(); - accessibleDebug("QWindowsIA2Accessible::QI() - IID:%s, iface:%s ", strIID.constData(), qPrintable(ss)); + qCDebug(lcQpaAccessibility) << "QWindowsIA2Accessible::QI() - IID:" + << strIID << ", iface:" << accessibleInterface(); } if (id == IID_IUnknown) { *iface = (IUnknown*)(IDispatch*)this; @@ -1059,7 +1044,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accValue(VARIANT varID, BS } *pszValue = 0; - accessibleDebug("return S_FALSE"); + qCDebug(lcQpaAccessibility) << "return S_FALSE"; return S_FALSE; } @@ -1198,7 +1183,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::GetWindow(HWND *phwnd) QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface(); Q_ASSERT(platform); *phwnd = (HWND)platform->nativeResourceForWindow("handle", window); - accessibleDebug("QWindowsAccessible::GetWindow(): %p", *phwnd); + qCDebug(lcQpaAccessibility) << "QWindowsAccessible::GetWindow(): " << *phwnd; return S_OK; } diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h index 5b8d08d3c8..43482da4be 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h @@ -59,13 +59,6 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_OUTPUT) -bool debug_accessibility(); -# define accessibleDebug !debug_accessibility() ? (void)0 : qDebug -#else -# define accessibleDebug while (false) qDebug -#endif - #ifndef QT_NO_DEBUG_OUTPUT #define DEBUG_SHOW_ATCLIENT_COMMANDS #endif diff --git a/src/plugins/platforms/windows/main.cpp b/src/plugins/platforms/windows/main.cpp index ffd87af193..a0057534b8 100644 --- a/src/plugins/platforms/windows/main.cpp +++ b/src/plugins/platforms/windows/main.cpp @@ -43,7 +43,7 @@ #include <qpa/qplatformintegrationplugin.h> #include <QtCore/QStringList> -#include "qwindowsintegration.h" +#include "qwindowsgdiintegration.h" QT_BEGIN_NAMESPACE @@ -113,7 +113,7 @@ public: QPlatformIntegration *QWindowsIntegrationPlugin::create(const QString& system, const QStringList& paramList, int &, char **) { if (system.compare(system, QStringLiteral("windows"), Qt::CaseInsensitive) == 0) - return new QWindowsIntegration(paramList); + return new QWindowsGdiIntegration(paramList); return 0; } diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h index 7b574b0a56..ee640224cf 100644 --- a/src/plugins/platforms/windows/qtwindowsglobal.h +++ b/src/plugins/platforms/windows/qtwindowsglobal.h @@ -73,6 +73,7 @@ enum WindowsEventType // Simplify event types ExposeEvent = WindowEventFlag + 1, ActivateWindowEvent = WindowEventFlag + 2, DeactivateWindowEvent = WindowEventFlag + 3, + MouseActivateWindowEvent = WindowEventFlag + 4, LeaveEvent = WindowEventFlag + 5, CloseEvent = WindowEventFlag + 6, ShowEvent = WindowEventFlag + 7, @@ -131,6 +132,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI case WM_ACTIVATEAPP: return (int)wParamIn ? QtWindows::ActivateApplicationEvent : QtWindows::DeactivateApplicationEvent; + case WM_MOUSEACTIVATE: + return QtWindows::MouseActivateWindowEvent; case WM_ACTIVATE: return LOWORD(wParamIn) == WA_INACTIVE ? QtWindows::DeactivateWindowEvent : QtWindows::ActivateWindowEvent; diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index 55e7b85d96..f12c828d8a 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -61,14 +61,12 @@ QT_BEGIN_NAMESPACE QWindowsBackingStore::QWindowsBackingStore(QWindow *window) : QPlatformBackingStore(window) { - if (QWindowsContext::verboseBackingStore) - qDebug() << __FUNCTION__ << this << window; + qCDebug(lcQpaBackingStore) << __FUNCTION__ << this << window; } QWindowsBackingStore::~QWindowsBackingStore() { - if (QWindowsContext::verboseBackingStore) - qDebug() << __FUNCTION__ << this; + qCDebug(lcQpaBackingStore) << __FUNCTION__ << this; } QPaintDevice *QWindowsBackingStore::paintDevice() @@ -83,8 +81,8 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, Q_ASSERT(window); const QRect br = region.boundingRect(); - if (QWindowsContext::verboseBackingStore > 1) - qDebug() << __FUNCTION__ << window << offset << br; + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaBackingStore) << __FUNCTION__ << this << window << offset << br; QWindowsWindow *rw = QWindowsWindow::baseWindowOf(window); #ifndef Q_OS_WINCE @@ -117,20 +115,23 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, } if (!BitBlt(dc, br.x(), br.y(), br.width(), br.height(), - m_image->hdc(), br.x() + offset.x(), br.y() + offset.y(), SRCCOPY)) - qErrnoWarning("%s: BitBlt failed", __FUNCTION__); + m_image->hdc(), br.x() + offset.x(), br.y() + offset.y(), SRCCOPY)) { + const DWORD lastError = GetLastError(); // QTBUG-35926, QTBUG-29716: may fail after lock screen. + if (lastError != ERROR_SUCCESS && lastError != ERROR_INVALID_HANDLE) + qErrnoWarning(lastError, "%s: BitBlt failed", __FUNCTION__); + } rw->releaseDC(); #ifndef Q_OS_WINCE } #endif // Write image for debug purposes. - if (QWindowsContext::verboseBackingStore > 2) { + if (QWindowsContext::verbose > 2 && lcQpaBackingStore().isDebugEnabled()) { static int n = 0; const QString fileName = QString::fromLatin1("win%1_%2.png"). arg(rw->winId()).arg(n++); m_image->image().save(fileName); - qDebug() << "Wrote " << m_image->image().size() << fileName; + qCDebug(lcQpaBackingStore) << "Wrote " << m_image->image().size() << fileName; } } @@ -138,16 +139,14 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion ®ion) { if (m_image.isNull() || m_image->image().size() != size) { #ifndef QT_NO_DEBUG_OUTPUT - if (QWindowsContext::verboseBackingStore) { - QDebug nsp = qDebug().nospace(); - nsp << __FUNCTION__ << ' ' << rasterWindow()->window() - << ' ' << size << ' ' << region; - if (!m_image.isNull()) - nsp << " from: " << m_image->image().size(); + if (QWindowsContext::verbose && lcQpaBackingStore().isDebugEnabled()) { + qCDebug(lcQpaBackingStore) + << __FUNCTION__ << ' ' << window() << ' ' << size << ' ' << region + << " from: " << (m_image.isNull() ? QSize() : m_image->image().size()); } #endif QImage::Format format = QWindowsNativeImage::systemFormat(); - if (format == QImage::Format_RGB32 && rasterWindow()->window()->format().hasAlpha()) + if (format == QImage::Format_RGB32 && window()->format().hasAlpha()) format = QImage::Format_ARGB32_Premultiplied; QWindowsNativeImage *oldwni = m_image.data(); @@ -185,8 +184,8 @@ bool QWindowsBackingStore::scroll(const QRegion &area, int dx, int dy) void QWindowsBackingStore::beginPaint(const QRegion ®ion) { - if (QWindowsContext::verboseBackingStore > 1) - qDebug() << __FUNCTION__; + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaBackingStore) <<__FUNCTION__ << region; if (m_image->image().hasAlphaChannel()) { QPainter p(&m_image->image()); @@ -197,14 +196,6 @@ void QWindowsBackingStore::beginPaint(const QRegion ®ion) } } -QWindowsWindow *QWindowsBackingStore::rasterWindow() const -{ - if (const QWindow *w = window()) - if (QPlatformWindow *pw = w->handle()) - return static_cast<QWindowsWindow *>(pw); - return 0; -} - HDC QWindowsBackingStore::getDC() const { if (!m_image.isNull()) diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.h b/src/plugins/platforms/windows/qwindowsbackingstore.h index d50570dd2c..b655aca835 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.h +++ b/src/plugins/platforms/windows/qwindowsbackingstore.h @@ -68,8 +68,6 @@ public: HDC getDC() const; private: - QWindowsWindow *rasterWindow() const; - QScopedPointer<QWindowsNativeImage> m_image; }; diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 51e0d0e803..5370d556fd 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -164,9 +164,7 @@ void QWindowsClipboard::registerViewer() qClipboardViewerWndProc, WS_OVERLAPPED); m_nextClipboardViewer = SetClipboardViewer(m_clipboardViewer); - if (QWindowsContext::verboseOLE) - qDebug("%s m_clipboardViewer: %p next=%p", __FUNCTION__, - m_clipboardViewer, m_nextClipboardViewer); + qCDebug(lcQpaMime) << __FUNCTION__ << "m_clipboardViewer: " << m_clipboardViewer << "next: " << m_nextClipboardViewer; } void QWindowsClipboard::unregisterViewer() @@ -219,9 +217,8 @@ void QWindowsClipboard::propagateClipboardMessage(UINT message, WPARAM wParam, L bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result) { *result = 0; - if (QWindowsContext::verboseOLE) - qDebug("%s HWND=%p 0x%x %s", __FUNCTION__, hwnd, message, - QWindowsGuiEventDispatcher::windowsMessageName(message)); + if (QWindowsContext::verbose) + qCDebug(lcQpaMime) << __FUNCTION__ << hwnd << message << QWindowsGuiEventDispatcher::windowsMessageName(message); switch (message) { case WM_CHANGECBCHAIN: { @@ -235,8 +232,7 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w return true; case WM_DRAWCLIPBOARD: { const bool owned = ownsClipboard(); - if (QWindowsContext::verboseOLE) - qDebug("Clipboard changed owned %d", owned); + qCDebug(lcQpaMime) << "Clipboard changed owned " << owned; emitChanged(QClipboard::Clipboard); // clean up the clipboard object if we no longer own the clipboard if (!owned && m_data) @@ -247,8 +243,7 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w case WM_DESTROY: // Recommended shutdown if (ownsClipboard()) { - if (QWindowsContext::verboseOLE) - qDebug("Clipboard owner on shutdown, releasing."); + qCDebug(lcQpaMime) << "Clipboard owner on shutdown, releasing."; OleFlushClipboard(); releaseIData(); } @@ -259,8 +254,7 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w QMimeData *QWindowsClipboard::mimeData(QClipboard::Mode mode) { - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << mode; + qCDebug(lcQpaMime) << __FUNCTION__ << mode; if (mode != QClipboard::Clipboard) return 0; if (ownsClipboard()) @@ -270,8 +264,7 @@ QMimeData *QWindowsClipboard::mimeData(QClipboard::Mode mode) void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) { - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << mode << *mimeData; + qCDebug(lcQpaMime) << __FUNCTION__ << mode << *mimeData; if (mode != QClipboard::Clipboard) return; @@ -316,8 +309,7 @@ bool QWindowsClipboard::ownsMode(QClipboard::Mode mode) const { const bool result = mode == QClipboard::Clipboard ? ownsClipboard() : false; - if (QWindowsContext::verboseOLE) - qDebug("%s %d returns %d", __FUNCTION__, mode, result); + qCDebug(lcQpaMime) << __FUNCTION__ << mode << result; return result; } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 77cac647ba..08f3ab4dbd 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -79,18 +79,18 @@ QT_BEGIN_NAMESPACE -// Verbosity of components -int QWindowsContext::verboseIntegration = 0; -int QWindowsContext::verboseWindows = 0; -int QWindowsContext::verboseEvents = 0; -int QWindowsContext::verboseBackingStore = 0; -int QWindowsContext::verboseFonts = 0; -int QWindowsContext::verboseGL = 0; -int QWindowsContext::verboseOLE = 0; -int QWindowsContext::verboseInputMethods = 0; -int QWindowsContext::verboseDialogs = 0; -int QWindowsContext::verboseTheming = 0; -int QWindowsContext::verboseTablet = 0; +Q_LOGGING_CATEGORY(lcQpaWindows, "qt.qpa.windows") +Q_LOGGING_CATEGORY(lcQpaBackingStore, "qt.qpa.backingstore") +Q_LOGGING_CATEGORY(lcQpaEvents, "qt.qpa.events") +Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts") +Q_LOGGING_CATEGORY(lcQpaGl, "qt.qpa.gl") +Q_LOGGING_CATEGORY(lcQpaMime, "qt.qpa.mime") +Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.inputmethods") +Q_LOGGING_CATEGORY(lcQpaDialogs, "qt.qpa.dialogs") +Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.tabletsupport") +Q_LOGGING_CATEGORY(lcQpaAccessibility, "qt.qpa.accessibility") + +int QWindowsContext::verbose = 0; // Get verbosity of components from "foo:2,bar:3" static inline int componentVerbose(const char *v, const char *keyWord) @@ -318,30 +318,21 @@ QWindowsContext::QWindowsContext() : # pragma warning( disable : 4996 ) #endif m_instance = this; + // ### FIXME: Remove this once the logging system has other options of configurations. const QByteArray bv = qgetenv("QT_QPA_VERBOSE"); - if (!bv.isEmpty()) { - const char *v = bv.data(); - QWindowsContext::verboseIntegration = componentVerbose(v, "integration"); - QWindowsContext::verboseWindows = componentVerbose(v, "windows"); - QWindowsContext::verboseEvents = componentVerbose(v, "events"); - QWindowsContext::verboseBackingStore = componentVerbose(v, "backingstore"); - QWindowsContext::verboseFonts = componentVerbose(v, "fonts"); - QWindowsContext::verboseGL = componentVerbose(v, "gl"); - QWindowsContext::verboseOLE = componentVerbose(v, "ole"); - QWindowsContext::verboseInputMethods = componentVerbose(v, "im"); - QWindowsContext::verboseDialogs = componentVerbose(v, "dialogs"); - QWindowsContext::verboseTheming = componentVerbose(v, "theming"); - QWindowsContext::verboseTablet = componentVerbose(v, "tablet"); - } + if (!bv.isEmpty()) + QLoggingCategory::setFilterRules(QString::fromLocal8Bit(bv)); #if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE) d->m_tabletSupport.reset(QWindowsTabletSupport::create()); - if (QWindowsContext::verboseTablet) - qDebug() << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description()); + qCDebug(lcQpaTablet) << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description()); #endif } QWindowsContext::~QWindowsContext() { +#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE) + d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes. +#endif unregisterWindowClasses(); if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE) OleUninitialize(); @@ -407,7 +398,7 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) bool icon = true; if (isGL || (flags & Qt::MSWindowsOwnDC)) style |= CS_OWNDC; - if ((QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) + if (!(flags & Qt::NoDropShadowWindowHint) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) && (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) { style |= CS_DROPSHADOW; } @@ -519,8 +510,7 @@ QString QWindowsContext::registerWindowClass(QString cname, qPrintable(cname)); d->m_registeredWindowClassNames.insert(cname); - if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) - qDebug().nospace() << __FUNCTION__ << ' ' << cname + qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << cname << " style=0x" << QString::number(style, 16) << " brush=" << brush << " icon=" << icon << " atom=" << atom; return cname; @@ -531,9 +521,8 @@ void QWindowsContext::unregisterWindowClasses() const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0); foreach (const QString &name, d->m_registeredWindowClassNames) { - if (QWindowsContext::verboseIntegration) - qDebug() << __FUNCTION__ << name; - UnregisterClass((wchar_t*)name.utf16(), appInstance); + if (!UnregisterClass((wchar_t*)name.utf16(), appInstance) && QWindowsContext::verbose) + qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name)); } d->m_registeredWindowClassNames.clear(); } @@ -750,8 +739,20 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, msg.message = message; // time and pt fields ignored msg.wParam = wParam; msg.lParam = lParam; - msg.pt.x = GET_X_LPARAM(lParam); - msg.pt.y = GET_Y_LPARAM(lParam); + msg.pt.x = msg.pt.y = 0; + if (et != QtWindows::CursorEvent && (et & (QtWindows::MouseEventFlag | QtWindows::NonClientEventFlag))) { + msg.pt.x = GET_X_LPARAM(lParam); + msg.pt.y = GET_Y_LPARAM(lParam); + // For non-client-area messages, these are screen coordinates (as expected + // in the MSG structure), otherwise they are client coordinates. + if (!(et & QtWindows::NonClientEventFlag)) { + ClientToScreen(msg.hwnd, &msg.pt); + } + } else { +#ifndef Q_OS_WINCE + GetCursorPos(&msg.pt); +#endif + } // Run the native event filters. long filterResult = 0; @@ -834,8 +835,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, // Suppress events sent during DestroyWindow() for native children. if (platformWindow->testFlag(QWindowsWindow::WithinDestroy)) return false; - if (QWindowsContext::verboseEvents > 1) - qDebug().nospace() << "Event window: " << platformWindow->window(); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaEvents) << "Event window: " << platformWindow->window(); } else { qWarning("%s: No Qt Window found for event 0x%x (%s), hwnd=0x%p.", __FUNCTION__, message, @@ -928,6 +929,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return true; #ifndef Q_OS_WINCE case QtWindows::ActivateWindowEvent: + if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) { + *result = LRESULT(MA_NOACTIVATE); + return true; + } #ifndef QT_NO_TABLETEVENT if (!d->m_tabletSupport.isNull()) d->m_tabletSupport->notifyActivate(); @@ -936,6 +941,12 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, if (const QWindow *modalWindow = QGuiApplication::modalWindow()) QWindowsWindow::baseWindowOf(modalWindow)->alertWindow(); break; + case QtWindows::MouseActivateWindowEvent: + if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) { + *result = LRESULT(MA_NOACTIVATE); + return true; + } + break; #endif #ifndef QT_NO_CONTEXTMENU case QtWindows::ContextMenu: @@ -963,7 +974,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, if (lParam & ENDSESSION_LOGOFF) fflush(NULL); - return !sessionManager->wasCanceled(); + *result = sessionManager->wasCanceled() ? 0 : 1; + return true; } case QtWindows::EndSessionApplicationEvent: { QWindowsSessionManager *sessionManager = platformSessionManager(); @@ -1071,11 +1083,13 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPAR LRESULT result; const QtWindows::WindowsEventType et = windowsEventType(message, wParam); const bool handled = QWindowsContext::instance()->windowsProc(hwnd, message, et, wParam, lParam, &result); - if (QWindowsContext::verboseEvents > 1) - if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message)) - qDebug("EVENT: hwd=%p %s msg=0x%x et=0x%x wp=%d at %d,%d handled=%d", - hwnd, eventName, message, et, int(wParam), - GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), handled); + if (QWindowsContext::verbose > 1 && lcQpaEvents().isDebugEnabled()) { + if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message)) { + qCDebug(lcQpaEvents) << "EVENT: hwd=" << hwnd << eventName << hex << "msg=0x" << message + << "et=0x" << et << dec << "wp=" << int(wParam) << "at" + << GET_X_LPARAM(lParam) << GET_Y_LPARAM(lParam) << "handled=" << handled; + } + } if (!handled) result = DefWindowProc(hwnd, message, wParam, lParam); return result; diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 173df58570..1fea059ed9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -47,12 +47,24 @@ #include <QtCore/QScopedPointer> #include <QtCore/QSharedPointer> +#include <QtCore/QLoggingCategory> struct IBindCtx; struct _SHSTOCKICONINFO; QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcQpaWindows) +Q_DECLARE_LOGGING_CATEGORY(lcQpaBackingStore) +Q_DECLARE_LOGGING_CATEGORY(lcQpaEvents) +Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts) +Q_DECLARE_LOGGING_CATEGORY(lcQpaGl) +Q_DECLARE_LOGGING_CATEGORY(lcQpaMime) +Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods) +Q_DECLARE_LOGGING_CATEGORY(lcQpaDialogs) +Q_DECLARE_LOGGING_CATEGORY(lcQpaTablet) +Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility) + class QWindow; class QPlatformScreen; class QWindowsScreenManager; @@ -128,17 +140,7 @@ public: }; // Verbose flag set by environment variable QT_QPA_VERBOSE - static int verboseIntegration; - static int verboseWindows; - static int verboseBackingStore; - static int verboseEvents; - static int verboseFonts; - static int verboseGL; - static int verboseOLE; - static int verboseInputMethods; - static int verboseDialogs; - static int verboseTheming; - static int verboseTablet; + static int verbose; explicit QWindowsContext(); ~QWindowsContext(); diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 5e7944a4cf..d8fb104b3c 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -186,32 +186,6 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar phand_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, - 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, - 0x80, 0x1c, 0x00, 0x00, 0x80, 0xe4, 0x00, 0x00, 0x80, 0x24, 0x03, 0x00, - 0x80, 0x24, 0x05, 0x00, 0xb8, 0x24, 0x09, 0x00, 0xc8, 0x00, 0x09, 0x00, - 0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0xa0, 0x00, 0x08, 0x00, - 0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00, - 0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x00, 0x01, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - static const uchar phandm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, - 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, - 0x80, 0x1f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x03, 0x00, - 0x80, 0xff, 0x07, 0x00, 0xb8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00, - 0xf8, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00, - 0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00, - 0x80, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00, - 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar openhand_bits[] = { 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, @@ -229,11 +203,6 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c) 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; - static const uchar * const cursor_bits32[] = { - vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, - phand_bits, phandm_bits - }; - wchar_t *sh = 0; switch (c.shape()) { // map to windows cursor case Qt::ArrowCursor: @@ -300,23 +269,18 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c) mbits = cm.toImage().convertToFormat(QImage::Format_Mono); hx = hy = 8; invb = invm = false; - } else if (cshape != Qt::BitmapCursor) { - int i = cshape - Qt::SplitVCursor; - QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]); - QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]); - bbits = cb.toImage().convertToFormat(QImage::Format_Mono); - mbits = cm.toImage().convertToFormat(QImage::Format_Mono); - if (cshape == Qt::PointingHandCursor) { - hx = 7; - hy = 0; - } else - hx = hy = 16; - invb = invm = false; - } else { + } else if (cshape == Qt::BitmapCursor) { bbits = c.bitmap()->toImage().convertToFormat(QImage::Format_Mono); mbits = c.mask()->toImage().convertToFormat(QImage::Format_Mono); invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); + } else { // Qt::SplitVCursor, Qt::SplitHCursor + const QBitmap cb = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplit_bits : hsplit_bits); + const QBitmap cm = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplitm_bits : hsplitm_bits); + bbits = cb.toImage().convertToFormat(QImage::Format_Mono); + mbits = cm.toImage().convertToFormat(QImage::Format_Mono); + hx = hy = 16; + invb = invm = false; } const int n = qMax(1, bbits.width() / 8); const int h = bbits.height(); @@ -441,9 +405,6 @@ QWindowsWindowCursor QWindowsCursor::pixmapWindowCursor(const QCursor &c) void QWindowsCursor::changeCursor(QCursor *cursorIn, QWindow *window) { - - if (QWindowsContext::verboseWindows > 1) - qDebug() << __FUNCTION__ << cursorIn << window; if (!window) return; if (!cursorIn) { @@ -468,10 +429,24 @@ QPoint QWindowsCursor::mousePosition() return QPoint(p.x, p.y); } +QWindowsCursor::CursorState QWindowsCursor::cursorState() +{ +#ifndef Q_OS_WINCE + enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; // Windows 8: CURSOR_SUPPRESSED + CURSORINFO cursorInfo; + cursorInfo.cbSize = sizeof(CURSORINFO); + if (GetCursorInfo(&cursorInfo)) { + if (cursorInfo.flags & CursorShowing) + return CursorShowing; + if (cursorInfo.flags & cursorSuppressed) + return CursorSuppressed; + } +#endif // !Q_OS_WINCE + return CursorHidden; +} + void QWindowsCursor::setPos(const QPoint &pos) { - if (QWindowsContext::verboseWindows) - qDebug("%s %d,%d", __FUNCTION__, pos.x(), pos.y()); SetCursorPos(pos.x(), pos.y()); } diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index b366d9a06a..31da4e367d 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -93,6 +93,12 @@ private: class QWindowsCursor : public QPlatformCursor { public: + enum CursorState { + CursorShowing, + CursorHidden, + CursorSuppressed // Cursor suppressed by touch interaction (Windows 8). + }; + QWindowsCursor() {} virtual void changeCursor(QCursor * widgetCursor, QWindow * widget); @@ -102,6 +108,7 @@ public: static HCURSOR createPixmapCursor(const QPixmap &pixmap, int hotX, int hotY); static HCURSOR createSystemCursor(const QCursor &c); static QPoint mousePosition(); + static CursorState cursorState(); QWindowsWindowCursor standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor); QWindowsWindowCursor pixmapWindowCursor(const QCursor &c); diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 8ebfd018d0..7307d52cf9 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -422,8 +422,7 @@ void eatMouseMove() ; if (msg.message == WM_MOUSEMOVE) PostMessage(msg.hwnd, msg.message, 0, msg.lParam); - if (QWindowsContext::verboseDialogs) - qDebug("%s triggered=%d" , __FUNCTION__, msg.message == WM_MOUSEMOVE); + qCDebug(lcQpaDialogs) << __FUNCTION__ << "triggered=" << (msg.message == WM_MOUSEMOVE); } } // namespace QWindowsDialogs @@ -503,11 +502,31 @@ template <class BaseClass> QWindowsDialogHelperBase<BaseClass>::QWindowsDialogHelperBase() : m_nativeDialog(0), m_ownerWindow(0), - m_timerId(0) + m_timerId(0), + m_thread(0) { } template <class BaseClass> +void QWindowsDialogHelperBase<BaseClass>::cleanupThread() +{ + if (m_thread) { // Thread may be running if the dialog failed to close. + if (m_thread->isRunning()) + m_thread->wait(500); + if (m_thread->isRunning()) { + m_thread->terminate(); + m_thread->wait(300); + if (m_thread->isRunning()) + qCCritical(lcQpaDialogs) <<__FUNCTION__ << "Failed to terminate thread."; + else + qCWarning(lcQpaDialogs) << __FUNCTION__ << "Thread terminated."; + } + delete m_thread; + m_thread = 0; + } +} + +template <class BaseClass> QWindowsNativeDialogBase *QWindowsDialogHelperBase<BaseClass>::nativeDialog() const { if (m_nativeDialog.isNull()) { @@ -558,12 +577,9 @@ private: void QWindowsDialogThread::run() { - if (QWindowsContext::verboseDialogs) - qDebug(">%s" , __FUNCTION__); + qCDebug(lcQpaDialogs) << '>' << __FUNCTION__; m_dialog->exec(m_owner); - deleteLater(); - if (QWindowsContext::verboseDialogs) - qDebug("<%s" , __FUNCTION__); + qCDebug(lcQpaDialogs) << '<' << __FUNCTION__; } template <class BaseClass> @@ -579,9 +595,9 @@ bool QWindowsDialogHelperBase<BaseClass>::show(Qt::WindowFlags, } else { m_ownerWindow = 0; } - if (QWindowsContext::verboseDialogs) - qDebug("%s modal=%d modal supported? %d native=%p parent=%p" , - __FUNCTION__, modal, supportsNonModalDialog(parent), m_nativeDialog.data(), m_ownerWindow); + qCDebug(lcQpaDialogs) << __FUNCTION__ << "modal=" << modal + << " modal supported? " << supportsNonModalDialog(parent) + << "native=" << m_nativeDialog.data() << "owner" << m_ownerWindow; if (!modal && !supportsNonModalDialog(parent)) return false; // Was it changed in-between? if (!ensureNativeDialog()) @@ -590,6 +606,7 @@ bool QWindowsDialogHelperBase<BaseClass>::show(Qt::WindowFlags, // a subsequent call to exec() may follow. So, start an idle timer // which will start the dialog thread. If exec() is then called, the // timer is stopped and dialog->exec() is called directly. + cleanupThread(); if (modal) { m_timerId = this->startTimer(0); } else { @@ -602,8 +619,9 @@ template <class BaseClass> void QWindowsDialogHelperBase<BaseClass>::startDialogThread() { Q_ASSERT(!m_nativeDialog.isNull()); - QWindowsDialogThread *thread = new QWindowsDialogThread(m_nativeDialog, m_ownerWindow); - thread->start(); + Q_ASSERT(!m_thread); + m_thread = new QWindowsDialogThread(m_nativeDialog, m_ownerWindow); + m_thread->start(); stopTimer(); } @@ -630,7 +648,7 @@ struct FindDialogContext HWND hwnd; // contains the HWND of the window found. }; -static BOOL CALLBACK findDialogEnumWindowsProc(HWND hwnd, LPARAM lParam) +static BOOL QT_WIN_CALLBACK findDialogEnumWindowsProc(HWND hwnd, LPARAM lParam) { FindDialogContext *context = reinterpret_cast<FindDialogContext *>(lParam); DWORD winPid = 0; @@ -665,8 +683,7 @@ void QWindowsDialogHelperBase<BaseClass>::hide() template <class BaseClass> void QWindowsDialogHelperBase<BaseClass>::exec() { - if (QWindowsContext::verboseDialogs) - qDebug("%s" , __FUNCTION__); + qCDebug(lcQpaDialogs) << __FUNCTION__; stopTimer(); if (QWindowsNativeDialogBase *nd = nativeDialog()) { nd->exec(m_ownerWindow); @@ -956,8 +973,7 @@ bool QWindowsNativeFileDialogBase::init(const CLSID &clsId, const IID &iid) qErrnoWarning("IFileDialog::Advise failed"); return false; } - if (QWindowsContext::verboseDialogs) - qDebug("%s %p %p cookie=%lu" , __FUNCTION__, m_fileDialog, m_dialogEvents, m_cookie); + qCDebug(lcQpaDialogs) << __FUNCTION__ << m_fileDialog << m_dialogEvents << m_cookie; return true; } @@ -1008,14 +1024,12 @@ QString QWindowsNativeFileDialogBase::directory() const void QWindowsNativeFileDialogBase::doExec(HWND owner) { - if (QWindowsContext::verboseDialogs) - qDebug(">%s on %p", __FUNCTION__, (void *)owner); + qCDebug(lcQpaDialogs) << '>' << __FUNCTION__; // Show() blocks until the user closes the dialog, the dialog window // gets a WM_CLOSE or the parent window is destroyed. const HRESULT hr = m_fileDialog->Show(owner); QWindowsDialogs::eatMouseMove(); - if (QWindowsContext::verboseDialogs) - qDebug("<%s returns 0x%lx", __FUNCTION__, hr); + qCDebug(lcQpaDialogs) << '<' << __FUNCTION__ << " returns " << hex << hr; if (hr == S_OK) { emit accepted(); } else { @@ -1045,10 +1059,8 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode, QF flags |= FOS_FILEMUSTEXIST | FOS_ALLOWMULTISELECT; break; } - if (QWindowsContext::verboseDialogs) - qDebug().nospace() - << __FUNCTION__ << " mode=" << mode << " options" - << options << " results in 0x" << flags; + qCDebug(lcQpaDialogs) << __FUNCTION__ << " mode=" << mode << " options" + << options << " results in 0x" << flags; if (FAILED(m_fileDialog->SetOptions(flags))) qErrnoWarning("%s: SetOptions() failed", __FUNCTION__); @@ -1352,8 +1364,7 @@ void QWindowsNativeFileDialogBase::close() // IFileDialog::Close() does not work unless invoked from a callback. // Try to find the window and send it a WM_CLOSE in addition. const HWND hwnd = findDialogWindow(m_title); - if (QWindowsContext::verboseDialogs) - qDebug() << __FUNCTION__ << "closing" << hwnd; + qCDebug(lcQpaDialogs) << __FUNCTION__ << "closing" << hwnd; if (hwnd && IsWindowVisible(hwnd)) PostMessageW(hwnd, WM_CLOSE, 0, 0); #endif // !Q_OS_WINCE @@ -1617,8 +1628,7 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog() void QWindowsFileDialogHelper::setDirectory(const QUrl &directory) { - if (QWindowsContext::verboseDialogs) - qDebug("%s %s" , __FUNCTION__, qPrintable(directory.toString())); + qCDebug(lcQpaDialogs) << __FUNCTION__ << directory.toString(); m_data.setDirectory(directory); if (hasNativeDialog()) @@ -1632,8 +1642,7 @@ QUrl QWindowsFileDialogHelper::directory() const void QWindowsFileDialogHelper::selectFile(const QUrl &fileName) { - if (QWindowsContext::verboseDialogs) - qDebug("%s %s" , __FUNCTION__, qPrintable(fileName.toString())); + qCDebug(lcQpaDialogs) << __FUNCTION__ << fileName.toString(); if (hasNativeDialog()) // Might be invoked from the QFileDialog constructor. nativeFileDialog()->selectFile(fileName.toLocalFile()); // ## should use QUrl::fileName() once it exists @@ -1646,8 +1655,7 @@ QList<QUrl> QWindowsFileDialogHelper::selectedFiles() const void QWindowsFileDialogHelper::setFilter() { - if (QWindowsContext::verboseDialogs) - qDebug("%s" , __FUNCTION__); + qCDebug(lcQpaDialogs) << __FUNCTION__; } void QWindowsFileDialogHelper::selectNameFilter(const QString &filter) @@ -1762,7 +1770,7 @@ void QWindowsXpNativeFileDialog::doExec(HWND owner) // Callback for QWindowsNativeXpFileDialog directory dialog. // MFC Directory Dialog. Contrib: Steve Williams (minor parts from Scott Powers) -static int CALLBACK xpFileDialogGetExistingDirCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) +static int QT_WIN_CALLBACK xpFileDialogGetExistingDirCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { QWindowsXpNativeFileDialog *dialog = reinterpret_cast<QWindowsXpNativeFileDialog *>(lpData); return dialog->existingDirCallback(hwnd, uMsg, lParam); @@ -2039,8 +2047,6 @@ void QWindowsNativeColorDialog::doExec(HWND owner) typedef BOOL (WINAPI *ChooseColorWType)(LPCHOOSECOLORW); CHOOSECOLOR chooseColor; - if (QWindowsContext::verboseDialogs) - qDebug() << '>' << __FUNCTION__ << " on " << owner; ZeroMemory(&chooseColor, sizeof(chooseColor)); chooseColor.lStructSize = sizeof(chooseColor); chooseColor.hwndOwner = owner; @@ -2069,8 +2075,6 @@ void QWindowsNativeColorDialog::doExec(HWND owner) for (int c= 0; c < customColorCount; ++c) qCustomColors[c] = COLORREFToQColor(m_customColors[c]).rgb(); emit accepted(); - if (QWindowsContext::verboseDialogs) - qDebug() << '<' << __FUNCTION__ << *m_color; } else { emit rejected(); } diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h index 1501b02bd9..bcf9f544b5 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE class QFileDialog; class QDialog; +class QThread; class QWindowsNativeDialogBase; namespace QWindowsDialogs @@ -68,6 +69,7 @@ class QWindowsDialogHelperBase : public BaseClass Q_DISABLE_COPY(QWindowsDialogHelperBase) public: typedef QSharedPointer<QWindowsNativeDialogBase> QWindowsNativeDialogBasePtr; + ~QWindowsDialogHelperBase() { cleanupThread(); } virtual void exec(); virtual bool show(Qt::WindowFlags windowFlags, @@ -88,10 +90,12 @@ private: inline QWindowsNativeDialogBase *ensureNativeDialog(); inline void startDialogThread(); inline void stopTimer(); + void cleanupThread(); QWindowsNativeDialogBasePtr m_nativeDialog; HWND m_ownerWindow; int m_timerId; + QThread *m_thread; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index fedda750d9..60c3daff23 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -54,6 +54,9 @@ #include <QtGui/QMouseEvent> #include <QtGui/QPixmap> #include <QtGui/QPainter> +#include <QtGui/QPaintDevice> +#include <QtGui/QBackingStore> +#include <QtGui/QWindow> #include <QtGui/QGuiApplication> #include <qpa/qwindowsysteminterface_p.h> #include <QtGui/private/qguiapplication_p.h> @@ -207,6 +210,77 @@ static const char * const ignoreDragCursorXpmC[] = { "...............XXXX....."}; /*! + \class QWindowsDragCursorWindow + \brief A toplevel window showing the drag icon in case of touch drag. + + \sa QWindowsOleDropSource + \internal + \ingroup qt-lighthouse-win +*/ + +class QWindowsDragCursorWindow : public QWindow +{ +public: + explicit QWindowsDragCursorWindow(QWindow *parent = 0); + + void setPixmap(const QPixmap &p); + +protected: + void exposeEvent(QExposeEvent *); + +private: + void render(); + + QBackingStore m_backingStore; + QPixmap m_pixmap; +}; + +QWindowsDragCursorWindow::QWindowsDragCursorWindow(QWindow *parent) + : QWindow(parent) + , m_backingStore(this) +{ + QSurfaceFormat windowFormat = format(); + windowFormat.setAlphaBufferSize(8); + setFormat(windowFormat); + setObjectName(QStringLiteral("QWindowsDragCursorWindow")); + setFlags(Qt::Popup | Qt::NoDropShadowWindowHint + | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint + | Qt::WindowDoesNotAcceptFocus | Qt::WindowTransparentForInput); +} + +void QWindowsDragCursorWindow::setPixmap(const QPixmap &p) +{ + if (p.cacheKey() == m_pixmap.cacheKey()) + return; + const QSize oldSize = m_pixmap.size(); + const QSize newSize = p.size(); + qCDebug(lcQpaMime) << __FUNCTION__ << p.cacheKey() << newSize; + m_pixmap = p; + if (oldSize != newSize) { + resize(newSize); + m_backingStore.resize(newSize); + } + if (isVisible()) + render(); +} + +void QWindowsDragCursorWindow::exposeEvent(QExposeEvent *) +{ + Q_ASSERT(!m_pixmap.isNull()); + render(); +} + +void QWindowsDragCursorWindow::render() +{ + const QRect rect(QPoint(0, 0), m_pixmap.size()); + m_backingStore.beginPaint(rect); + QPainter painter(m_backingStore.paintDevice()); + painter.drawPixmap(0, 0, m_pixmap); + m_backingStore.endPaint(); + m_backingStore.flush(rect); +} + +/*! \class QWindowsDropMimeData \brief Special mime data class for data retrieval from Drag operations. @@ -286,6 +360,11 @@ static inline Qt::KeyboardModifiers toQtKeyboardModifiers(DWORD keyState) class QWindowsOleDropSource : public IDropSource { public: + enum Mode { + MouseDrag, + TouchDrag // Mouse cursor suppressed, use window as cursor. + }; + explicit QWindowsOleDropSource(QWindowsDrag *drag); virtual ~QWindowsOleDropSource(); @@ -304,35 +383,65 @@ private: class DragCursorHandle { Q_DISABLE_COPY(DragCursorHandle) public: - DragCursorHandle(HCURSOR c, qint64 k) : cursor(c), cacheKey(k) {} + DragCursorHandle(HCURSOR c) : cursor(c) {} ~DragCursorHandle() { DestroyCursor(cursor); } - HCURSOR cursor; - qint64 cacheKey; + const HCURSOR cursor; }; - typedef QMap <Qt::DropAction, QSharedPointer<DragCursorHandle> > ActionCursorMap; + typedef QSharedPointer<DragCursorHandle> DragCursorHandlePtr; + struct CursorEntry { + CursorEntry() : cacheKey(0) {} + CursorEntry(const QPixmap &p, qint64 cK, const DragCursorHandlePtr &c, const QPoint &h) : + pixmap(p), cacheKey(cK), cursor(c), hotSpot(h) {} + + QPixmap pixmap; + qint64 cacheKey; // Cache key of cursor + DragCursorHandlePtr cursor; + QPoint hotSpot; + }; + + typedef QMap<Qt::DropAction, CursorEntry> ActionCursorMap; + typedef ActionCursorMap::Iterator ActionCursorMapIt; + typedef ActionCursorMap::ConstIterator ActionCursorMapConstIt; + + const Mode m_mode; QWindowsDrag *m_drag; Qt::MouseButtons m_currentButtons; ActionCursorMap m_cursors; + QWindowsDragCursorWindow *m_touchDragWindow; ULONG m_refs; +#ifndef QT_NO_DEBUG_OUTPUT + friend QDebug operator<<(QDebug, const QWindowsOleDropSource::CursorEntry &); +#endif }; -QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag) : - m_drag(drag), m_currentButtons(Qt::NoButton), - m_refs(1) +QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag) + : m_mode(QWindowsCursor::cursorState() != QWindowsCursor::CursorSuppressed ? MouseDrag : TouchDrag) + , m_drag(drag) + , m_currentButtons(Qt::NoButton) + , m_touchDragWindow(0) + , m_refs(1) { - if (QWindowsContext::verboseOLE) - qDebug("%s", __FUNCTION__); + qCDebug(lcQpaMime) << __FUNCTION__ << m_mode; } QWindowsOleDropSource::~QWindowsOleDropSource() { m_cursors.clear(); - if (QWindowsContext::verboseOLE) - qDebug("%s", __FUNCTION__); + delete m_touchDragWindow; + qCDebug(lcQpaMime) << __FUNCTION__; } +#ifndef QT_NO_DEBUG_OUTPUT +QDebug operator<<(QDebug d, const QWindowsOleDropSource::CursorEntry &e) +{ + d << "CursorEntry:" << e.pixmap.size() << '#' << e.cacheKey + << "HCURSOR" << e.cursor->cursor << "hotspot:" << e.hotSpot; + return d; +} +#endif // !QT_NO_DEBUG_OUTPUT + /*! \brief Blend custom pixmap with cursors. */ @@ -343,59 +452,56 @@ void QWindowsOleDropSource::createCursors() const QPixmap pixmap = drag->pixmap(); const bool hasPixmap = !pixmap.isNull(); - QList<Qt::DropAction> actions; - actions << Qt::MoveAction << Qt::CopyAction << Qt::LinkAction; - if (hasPixmap) - actions << Qt::IgnoreAction; + Qt::DropAction actions[] = { Qt::MoveAction, Qt::CopyAction, Qt::LinkAction, Qt::IgnoreAction }; + int actionCount = int(sizeof(actions) / sizeof(actions[0])); + if (!hasPixmap) + --actionCount; // No Qt::IgnoreAction unless pixmap const QPoint hotSpot = drag->hotSpot(); - for (int cnum = 0; cnum < actions.size(); ++cnum) { - const Qt::DropAction action = actions.at(cnum); - QPixmap cpm = drag->dragCursor(action); - if (cpm.isNull()) - cpm = m_drag->defaultCursor(action); - QSharedPointer<DragCursorHandle> cursorHandler = m_cursors.value(action); - if (!cursorHandler.isNull() && cpm.cacheKey() == cursorHandler->cacheKey) + for (int cnum = 0; cnum < actionCount; ++cnum) { + const Qt::DropAction action = actions[cnum]; + QPixmap cursorPixmap = drag->dragCursor(action); + if (cursorPixmap.isNull()) + cursorPixmap = m_drag->defaultCursor(action); + const qint64 cacheKey = cursorPixmap.cacheKey(); + const ActionCursorMapIt it = m_cursors.find(action); + if (it != m_cursors.end() && it.value().cacheKey == cacheKey) continue; - if (cpm.isNull()) { + if (cursorPixmap.isNull()) { qWarning("%s: Unable to obtain drag cursor for %d.", __FUNCTION__, action); continue; } - int w = cpm.width(); - int h = cpm.height(); + QPoint newHotSpot(0, 0); + QPixmap newPixmap = cursorPixmap; if (hasPixmap) { const int x1 = qMin(-hotSpot.x(), 0); - const int x2 = qMax(pixmap.width() - hotSpot.x(), cpm.width()); + const int x2 = qMax(pixmap.width() - hotSpot.x(), cursorPixmap.width()); const int y1 = qMin(-hotSpot.y(), 0); - const int y2 = qMax(pixmap.height() - hotSpot.y(), cpm.height()); - - w = x2 - x1 + 1; - h = y2 - y1 + 1; - } - - const QPoint newHotSpot = hotSpot; - QPixmap newCursor(w, h); - if (hasPixmap) { + const int y2 = qMax(pixmap.height() - hotSpot.y(), cursorPixmap.height()); + QPixmap newCursor(x2 - x1 + 1, y2 - y1 + 1); newCursor.fill(Qt::transparent); QPainter p(&newCursor); const QRect srcRect = pixmap.rect(); const QPoint pmDest = QPoint(qMax(0, -hotSpot.x()), qMax(0, -hotSpot.y())); p.drawPixmap(pmDest, pixmap, srcRect); - p.drawPixmap(qMax(0,newHotSpot.x()),qMax(0,newHotSpot.y()),cpm); - } else { - newCursor = cpm; + p.drawPixmap(qMax(0, hotSpot.x()),qMax(0, hotSpot.y()), cursorPixmap); + newPixmap = newCursor; + newHotSpot = QPoint(qMax(0, hotSpot.x()), qMax(0, hotSpot.y())); } - const int hotX = hasPixmap ? qMax(0,newHotSpot.x()) : 0; - const int hotY = hasPixmap ? qMax(0,newHotSpot.y()) : 0; - - if (const HCURSOR sysCursor = QWindowsCursor::createPixmapCursor(newCursor, hotX, hotY)) { - m_cursors.insert(action, QSharedPointer<DragCursorHandle>(new DragCursorHandle(sysCursor, cpm.cacheKey()))); + if (const HCURSOR sysCursor = QWindowsCursor::createPixmapCursor(newPixmap, newHotSpot.x(), newHotSpot.y())) { + const CursorEntry entry(newPixmap, cacheKey, DragCursorHandlePtr(new DragCursorHandle(sysCursor)), newHotSpot); + if (it == m_cursors.end()) + m_cursors.insert(action, entry); + else + it.value() = entry; } } - if (QWindowsContext::verboseOLE) - qDebug("%s %d cursors", __FUNCTION__, m_cursors.size()); +#ifndef QT_NO_DEBUG_OUTPUT + if (lcQpaMime().isDebugEnabled()) + qCDebug(lcQpaMime) << __FUNCTION__ << "pixmap" << pixmap.size() << m_cursors.size() << "cursors:\n" << m_cursors; +#endif // !QT_NO_DEBUG_OUTPUT } //--------------------------------------------------------------------- @@ -468,11 +574,11 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) } while (false); - if (QWindowsContext::verboseOLE - && (QWindowsContext::verboseOLE > 1 || hr != S_OK)) - qDebug("%s fEscapePressed=%d, grfKeyState=%lu buttons=%d returns 0x%x", - __FUNCTION__, fEscapePressed,grfKeyState, int(m_currentButtons), - int(hr)); + if (QWindowsContext::verbose > 1 || hr != S_OK) { + qCDebug(lcQpaMime) << __FUNCTION__ << "fEscapePressed=" << fEscapePressed + << "grfKeyState=" << grfKeyState << "buttons" << m_currentButtons + << "returns 0x" << hex <<int(hr) << dec; + } return hr; } @@ -486,17 +592,29 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) const Qt::DropAction action = translateToQDragDropAction(dwEffect); m_drag->updateAction(action); - if (QWindowsContext::verboseOLE > 2) - qDebug("%s dwEffect=%lu, action=%d", __FUNCTION__, dwEffect, action); - - QSharedPointer<DragCursorHandle> cursorHandler = m_cursors.value(action); - qint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey(); - if (cursorHandler.isNull() || currentCacheKey != cursorHandler->cacheKey) + const qint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey(); + ActionCursorMapConstIt it = m_cursors.constFind(action); + // If a custom drag cursor is set, check its cache key to detect changes. + if (it == m_cursors.constEnd() || (currentCacheKey && currentCacheKey != it.value().cacheKey)) { createCursors(); + it = m_cursors.constFind(action); + } - const ActionCursorMap::const_iterator it = m_cursors.constFind(action); if (it != m_cursors.constEnd()) { - SetCursor(it.value()->cursor); + const CursorEntry &e = it.value(); + switch (m_mode) { + case MouseDrag: + SetCursor(e.cursor->cursor); + break; + case TouchDrag: + if (!m_touchDragWindow) + m_touchDragWindow = new QWindowsDragCursorWindow; + m_touchDragWindow->setPixmap(e.pixmap); + m_touchDragWindow->setFramePosition(QWindowsCursor::mousePosition() - e.hotSpot); + if (!m_touchDragWindow->isVisible()) + m_touchDragWindow->show(); + break; + } return ResultFromScode(S_OK); } @@ -519,14 +637,12 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) QWindowsOleDropTarget::QWindowsOleDropTarget(QWindow *w) : m_refs(1), m_window(w), m_chosenEffect(0), m_lastKeyState(0) { - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << this << w; + qCDebug(lcQpaMime) << __FUNCTION__ << this << w; } QWindowsOleDropTarget::~QWindowsOleDropTarget() { - if (QWindowsContext::verboseOLE) - qDebug("%s %p", __FUNCTION__, this); + qCDebug(lcQpaMime) << __FUNCTION__ << this; } STDMETHODIMP @@ -557,14 +673,6 @@ QWindowsOleDropTarget::Release(void) return m_refs; } -QWindow *QWindowsOleDropTarget::findDragOverWindow(const POINTL &pt) const -{ - if (QWindowsWindow *child = - QWindowsWindow::baseWindowOf(m_window)->childAtScreenPoint(QPoint(pt.x, pt.y))) - return child->window(); - return m_window; -} - void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState, const QPoint &point, LPDWORD pdwEffect) { @@ -588,13 +696,12 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState, m_chosenEffect = DROPEFFECT_NONE; } *pdwEffect = m_chosenEffect; - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << m_window - << windowsDrag->dropData() << " supported actions=" << actions - << " mods=" << QGuiApplicationPrivate::modifier_buttons - << " mouse=" << QGuiApplicationPrivate::mouse_buttons - << " accepted: " << response.isAccepted() << action - << m_answerRect << " effect" << *pdwEffect; + qCDebug(lcQpaMime) << __FUNCTION__ << m_window + << windowsDrag->dropData() << " supported actions=" << actions + << " mods=" << QGuiApplicationPrivate::modifier_buttons + << " mouse=" << QGuiApplicationPrivate::mouse_buttons + << " accepted: " << response.isAccepted() << action + << m_answerRect << " effect" << *pdwEffect; } QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP @@ -604,8 +711,8 @@ QWindowsOleDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) dh->DragEnter(reinterpret_cast<HWND>(m_window->winId()), pDataObj, reinterpret_cast<POINT*>(&pt), *pdwEffect); - if (QWindowsContext::verboseOLE) - qDebug("%s widget=%p key=%lu, pt=%ld,%ld", __FUNCTION__, m_window, grfKeyState, pt.x, pt.y); + qCDebug(lcQpaMime) << __FUNCTION__ << "widget=" << m_window << " key=" << grfKeyState + << "pt=" << pt.x << pt.y; QWindowsDrag::instance()->setDropDataObject(pDataObj); pDataObj->AddRef(); @@ -620,20 +727,18 @@ QWindowsOleDropTarget::DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) dh->DragOver(reinterpret_cast<POINT*>(&pt), *pdwEffect); - QWindow *dragOverWindow = findDragOverWindow(pt); - if (QWindowsContext::verboseOLE) - qDebug("%s widget=%p key=%lu, pt=%ld,%ld", __FUNCTION__, dragOverWindow, grfKeyState, pt.x, pt.y); - const QPoint tmpPoint = QWindowsGeometryHint::mapFromGlobal(dragOverWindow, QPoint(pt.x,pt.y)); + qCDebug(lcQpaMime) << __FUNCTION__ << "m_window" << m_window << "key=" << grfKeyState + << "pt=" << pt.x << pt.y; + const QPoint tmpPoint = QWindowsGeometryHint::mapFromGlobal(m_window, QPoint(pt.x,pt.y)); // see if we should compress this event if ((tmpPoint == m_lastPoint || m_answerRect.contains(tmpPoint)) && m_lastKeyState == grfKeyState) { *pdwEffect = m_chosenEffect; - if (QWindowsContext::verboseOLE) - qDebug("%s: compressed event", __FUNCTION__); + qCDebug(lcQpaMime) << __FUNCTION__ << "compressed event"; return NOERROR; } - handleDrag(dragOverWindow, grfKeyState, tmpPoint, pdwEffect); + handleDrag(m_window, grfKeyState, tmpPoint, pdwEffect); return NOERROR; } @@ -643,8 +748,7 @@ QWindowsOleDropTarget::DragLeave() if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) dh->DragLeave(); - if (QWindowsContext::verboseOLE) - qDebug().nospace() <<__FUNCTION__ << ' ' << m_window; + qCDebug(lcQpaMime) << __FUNCTION__ << ' ' << m_window; QWindowSystemInterface::handleDrag(m_window, 0, QPoint(), Qt::IgnoreAction); QWindowsDrag::instance()->releaseDropDataObject(); @@ -661,15 +765,10 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, if (IDropTargetHelper* dh = QWindowsDrag::instance()->dropHelper()) dh->Drop(pDataObj, reinterpret_cast<POINT*>(&pt), *pdwEffect); - QWindow *dropWindow = findDragOverWindow(pt); - - if (QWindowsContext::verboseOLE) - qDebug().nospace() << __FUNCTION__ << ' ' << m_window - << " on " << dropWindow - << " keys=" << grfKeyState << " pt=" - << pt.x << ',' << pt.y; + qCDebug(lcQpaMime) << __FUNCTION__ << ' ' << m_window + << "keys=" << grfKeyState << "pt=" << pt.x << ',' << pt.y; - m_lastPoint = QWindowsGeometryHint::mapFromGlobal(dropWindow, QPoint(pt.x,pt.y)); + m_lastPoint = QWindowsGeometryHint::mapFromGlobal(m_window, QPoint(pt.x,pt.y)); // grfKeyState does not all ways contain button state in the drop so if // it doesn't then use the last known button state; if ((grfKeyState & KEY_STATE_BUTTON_MASK) == 0) @@ -679,7 +778,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, QWindowsDrag *windowsDrag = QWindowsDrag::instance(); const QPlatformDropQtResponse response = - QWindowSystemInterface::handleDrop(dropWindow, windowsDrag->dropData(), m_lastPoint, + QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(), m_lastPoint, translateToQDragDropActions(*pdwEffect)); if (response.isAccepted()) { @@ -796,9 +895,8 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) QWindowsOleDataObject *dropDataObject = new QWindowsOleDataObject(dropData); const Qt::DropActions possibleActions = drag->supportedActions(); const DWORD allowedEffects = translateToWinDragEffects(possibleActions); - if (QWindowsContext::verboseOLE) - qDebug(">%s possible Actions=%x, effects=0x%lx", __FUNCTION__, - int(possibleActions), allowedEffects); + qCDebug(lcQpaMime) << '>' << __FUNCTION__ << "possible Actions=0x" + << hex << int(possibleActions) << "effects=0x" << allowedEffects << dec; const HRESULT r = DoDragDrop(dropDataObject, windowDropSource, allowedEffects, &resultEffect); const DWORD reportedPerformedEffect = dropDataObject->reportedPerformedEffect(); if (r == DRAGDROP_S_DROP) { @@ -819,10 +917,9 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) dropDataObject->releaseQt(); dropDataObject->Release(); // Will delete obj if refcount becomes 0 windowDropSource->Release(); // Will delete src if refcount becomes 0 - if (QWindowsContext::verboseOLE) - qDebug("<%s allowedEffects=0x%lx, reportedPerformedEffect=0x%lx, resultEffect=0x%lx, hr=0x%x, dropAction=%d", - __FUNCTION__, allowedEffects, reportedPerformedEffect, - resultEffect, int(r), dragResult); + qCDebug(lcQpaMime) << '<' << __FUNCTION__ << hex << "allowedEffects=0x" << allowedEffects + << "reportedPerformedEffect=0x" << reportedPerformedEffect + << " resultEffect=0x" << resultEffect << "hr=0x" << int(r) << dec << "dropAction=" << dragResult; return dragResult; } @@ -833,8 +930,7 @@ QWindowsDrag *QWindowsDrag::instance() void QWindowsDrag::releaseDropDataObject() { - if (QWindowsContext::verboseOLE) - qDebug("%s %p", __FUNCTION__, m_dropDataObject); + qCDebug(lcQpaMime) << __FUNCTION__ << m_dropDataObject; if (m_dropDataObject) { m_dropDataObject->Release(); m_dropDataObject = 0; diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index 33da4d6cc5..4f758fbf3f 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -74,7 +74,6 @@ public: STDMETHOD(Drop)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect); private: - inline QWindow *findDragOverWindow(const POINTL &pt) const; void handleDrag(QWindow *window, DWORD grfKeyState, const QPoint &, LPDWORD pdwEffect); ULONG m_refs; diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index d029249eeb..e025d7e513 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -89,16 +89,14 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create() Q_FUNC_INFO, eglGetError()); return 0; } - if (QWindowsContext::verboseGL) - qDebug("%s: Created EGL display %p v%d.%d", - __FUNCTION__, display, major, minor); + + qCDebug(lcQpaGl) << __FUNCTION__ << "Created EGL display" << display << 'v' <<major << '.' << minor; return new QWindowsEGLStaticContext(display, (major << 8) | minor); } QWindowsEGLStaticContext::~QWindowsEGLStaticContext() { - if (QWindowsContext::verboseGL) - qDebug("%s: Releasing EGL display %p", __FUNCTION__, m_display); + qCDebug(lcQpaGl) << __FUNCTION__ << "Releasing EGL display " << m_display; eglTerminate(m_display); } @@ -137,11 +135,7 @@ QWindowsEGLContext::~QWindowsEGLContext() bool QWindowsEGLContext::hasThreadedOpenGLCapability() { -#ifdef QT_OPENGL_ES_2_ANGLE return false; -#else - return true; -#endif } EGLSurface QWindowsEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 3a6f9f72e3..96659c505f 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -841,7 +841,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, int type) { // the "@family" fonts are just the same as "family". Ignore them. - if (familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QStringLiteral("WST_"))) + if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QStringLiteral("WST_"))) return false; static const int SMOOTH_SCALABLE = 0xffff; @@ -857,19 +857,20 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, const QFont::Stretch stretch = QFont::Unstretched; #ifndef QT_NO_DEBUG_OUTPUT - if (QWindowsContext::verboseFonts > 2) { - QDebug nospace = qDebug().nospace(); - nospace << __FUNCTION__ << familyName << charSet - << "TTF=" << ttf; + if (QWindowsContext::verbose > 2) { + QString message; + QTextStream str(&message); + str << __FUNCTION__ << ' ' << familyName << ' ' << charSet << " TTF=" << ttf; if (type & DEVICE_FONTTYPE) - nospace << " DEVICE"; + str << " DEVICE"; if (type & RASTER_FONTTYPE) - nospace << " RASTER"; + str << " RASTER"; if (type & TRUETYPE_FONTTYPE) - nospace << " TRUETYPE"; - nospace << " scalable=" << scalable << " Size=" << size + str << " TRUETYPE"; + str << " scalable=" << scalable << " Size=" << size << " Style=" << style << " Weight=" << weight << " stretch=" << stretch; + qCDebug(lcQpaFonts) << message; } #endif @@ -932,8 +933,8 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, return true; } -static int CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) +static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, + int type, LPARAM namesSetIn) { typedef QSet<QString> StringSet; const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); @@ -973,8 +974,7 @@ void QWindowsFontDatabase::populateFontDatabase() void QWindowsFontDatabase::populate(const QString &family) { - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << m_families.size() << family; + qCDebug(lcQpaFonts) << __FUNCTION__ << m_families.size() << family; HDC dummy = GetDC(0); LOGFONT lf; @@ -1026,11 +1026,10 @@ QWindowsFontDatabase::QWindowsFontDatabase() Q_UNUSED(hfontMetaTypeId) Q_UNUSED(logFontMetaTypeId) - if (QWindowsContext::verboseFonts) { + if (lcQpaFonts().isDebugEnabled()) { const QWindowsFontEngineDataPtr data = sharedFontData(); - qDebug() << __FUNCTION__ << "Clear type: " - << data->clearTypeEnabled << "gamma: " - << data->fontSmoothingGamma; + qCDebug(lcQpaFonts) << __FUNCTION__ << "Clear type: " + << data->clearTypeEnabled << "gamma: " << data->fontSmoothingGamma; } } @@ -1039,13 +1038,12 @@ QWindowsFontDatabase::~QWindowsFontDatabase() removeApplicationFonts(); } -QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle) +QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, void *handle) { - QFontEngine *fe = QWindowsFontDatabase::createEngine(script, fontDef, + QFontEngine *fe = QWindowsFontDatabase::createEngine(QChar::Script_Common, fontDef, 0, QWindowsContext::instance()->defaultDPI(), false, QStringList(), sharedFontData()); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << "FONTDEF" << fontDef << script << fe << handle; + qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef << fe << handle; return fe; } @@ -1200,8 +1198,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal } } - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << "FONTDATA" << fontData << pixelSize << hintingPreference << fontEngine; + qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDATA" << fontData << pixelSize << hintingPreference << fontEngine; return fontEngine; } @@ -1361,17 +1358,14 @@ void QWindowsFontDatabase::removeApplicationFonts() m_applicationFonts.clear(); } -void QWindowsFontDatabase::releaseHandle(void *handle) +void QWindowsFontDatabase::releaseHandle(void * /* handle */) { - if (handle && QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << handle; } QString QWindowsFontDatabase::fontDir() const { const QString result = QPlatformFontDatabase::fontDir(); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << result; + qCDebug(lcQpaFonts) << __FUNCTION__ << result; return result; } @@ -1550,7 +1544,7 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request) return lf; } -static QStringList extraTryFontsForFamily(const QString& family) +QStringList QWindowsFontDatabase::extraTryFontsForFamily(const QString &family) { QStringList result; QFontDatabase db; @@ -1620,11 +1614,11 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFon result << QString::fromLatin1("Arial"); } - result.append(extraTryFontsForFamily(family)); + if (script == QChar::Script_Common || script == QChar::Script_Han) + result.append(QWindowsFontDatabase::extraTryFontsForFamily(family)); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << family << style << styleHint - << script << result << m_families.size(); + qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint + << script << result << m_families.size(); return result; } @@ -1752,14 +1746,6 @@ QFontEngine *QWindowsFontDatabase::createEngine(int script, const QFontDef &requ QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, stockFont, lf, data); if (preferClearTypeAA) few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask; - - // Also check for OpenType tables when using complex scripts - if (!few->supportsScript(QChar::Script(script))) { - qWarning(" OpenType support missing for script %d", int(script)); - delete few; - return 0; - } - few->initFontInfo(request, fontHdc, dpi); fe = few; } @@ -1785,7 +1771,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(int script, const QFontDef &requ if ((script == QChar::Script_Common || script == QChar::Script_Han) && !(request.styleStrategy & QFont::NoFontMerging)) { - QStringList extraFonts = extraTryFontsForFamily(request.family); + const QStringList extraFonts = QWindowsFontDatabase::extraTryFontsForFamily(request.family); if (extraFonts.size()) { QStringList list = family_list; list.append(extraFonts); @@ -1810,8 +1796,7 @@ QFont QWindowsFontDatabase::systemDefaultFont() // "MS Shell Dlg 2" is the correct system font >= Win2k if (systemFont.family() == QStringLiteral("MS Shell Dlg")) systemFont.setFamily(QStringLiteral("MS Shell Dlg 2")); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << systemFont; + qCDebug(lcQpaFonts) << __FUNCTION__ << systemFont; return systemFont; } @@ -1825,9 +1810,9 @@ QFont QWindowsFontDatabase::LOGFONT_to_QFont(const LOGFONT& logFont, int vertica qFont.setWeight(weightFromInteger(logFont.lfWeight)); const qreal logFontHeight = qAbs(logFont.lfHeight); qFont.setPointSizeF(logFontHeight * 72.0 / qreal(verticalDPI_In)); - qFont.setUnderline(false); + qFont.setUnderline(logFont.lfUnderline); qFont.setOverline(false); - qFont.setStrikeOut(false); + qFont.setStrikeOut(logFont.lfStrikeOut); return qFont; } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index b9e6c38eaa..1e13fc2559 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -78,7 +78,7 @@ public: ~QWindowsFontDatabase(); virtual void populateFontDatabase(); - virtual QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle); + virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle); virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); @@ -103,6 +103,8 @@ public: static qreal fontSmoothingGamma(); static LOGFONT fontDefToLOGFONT(const QFontDef &fontDef); + static QStringList extraTryFontsForFamily(const QString &family); + private: void populate(const QString &family = QString()); void removeApplicationFonts(); diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 51f79736f2..51961014d9 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -130,7 +130,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, typedef QPair<QString, QStringList> FontKey; // the "@family" fonts are just the same as "family". Ignore them. - if (familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QStringLiteral("WST_"))) + if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QStringLiteral("WST_"))) return false; const int separatorPos = familyName.indexOf(QStringLiteral("::")); @@ -151,19 +151,20 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, const QFont::Stretch stretch = QFont::Unstretched; #ifndef QT_NO_DEBUG_OUTPUT - if (QWindowsContext::verboseFonts > 2) { - QDebug nospace = qDebug().nospace(); - nospace << __FUNCTION__ << familyName << faceName << fullName << charSet - << "TTF=" << ttf; + if (QWindowsContext::verbose > 2) { + QString message; + QTextStream str(&message); + str << __FUNCTION__ << ' ' << familyName << ' ' << charSet << " TTF=" << ttf; if (type & DEVICE_FONTTYPE) - nospace << " DEVICE"; + str << " DEVICE"; if (type & RASTER_FONTTYPE) - nospace << " RASTER"; + str << " RASTER"; if (type & TRUETYPE_FONTTYPE) - nospace << " TRUETYPE"; - nospace << " scalable=" << scalable << " Size=" << size + str << " TRUETYPE"; + str << " scalable=" << scalable << " Size=" << size << " Style=" << style << " Weight=" << weight << " stretch=" << stretch; + qCDebug(lcQpaFonts) << message; } #endif @@ -335,8 +336,8 @@ static QByteArray getFntTable(HFONT hfont, uint tag) } #endif -static int CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) +static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, + int type, LPARAM namesSetIn) { typedef QSet<QString> StringSet; const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName) @@ -403,8 +404,7 @@ void QWindowsFontDatabaseFT::populateFontDatabase() void QWindowsFontDatabaseFT::populate(const QString &family) { - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << m_families.size() << family; + qCDebug(lcQpaFonts) << __FUNCTION__ << m_families.size() << family; HDC dummy = GetDC(0); LOGFONT lf; @@ -422,111 +422,22 @@ void QWindowsFontDatabaseFT::populate(const QString &family) ReleaseDC(0, dummy); } -QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle) +QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle) { - QFontEngine *fe = QBasicFontDatabase::fontEngine(fontDef, script, handle); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << "FONTDEF" << /*fontDef <<*/ script << fe << handle; + QFontEngine *fe = QBasicFontDatabase::fontEngine(fontDef, handle); + qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef.family << fe << handle; return fe; } QFontEngine *QWindowsFontDatabaseFT::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { QFontEngine *fe = QBasicFontDatabase::fontEngine(fontData, pixelSize, hintingPreference); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << "FONTDATA" << fontData << pixelSize << hintingPreference << fe; + qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDATA" << fontData << pixelSize << hintingPreference << fe; return fe; } -static const char *other_tryFonts[] = { - "Arial", - "MS UI Gothic", - "Gulim", - "SimSun", - "PMingLiU", - "Arial Unicode MS", - 0 -}; - -static const char *jp_tryFonts [] = { - "MS UI Gothic", - "Arial", - "Gulim", - "SimSun", - "PMingLiU", - "Arial Unicode MS", - 0 -}; - -static const char *ch_CN_tryFonts [] = { - "SimSun", - "Arial", - "PMingLiU", - "Gulim", - "MS UI Gothic", - "Arial Unicode MS", - 0 -}; - -static const char *ch_TW_tryFonts [] = { - "PMingLiU", - "Arial", - "SimSun", - "Gulim", - "MS UI Gothic", - "Arial Unicode MS", - 0 -}; - -static const char *kr_tryFonts[] = { - "Gulim", - "Arial", - "PMingLiU", - "SimSun", - "MS UI Gothic", - "Arial Unicode MS", - 0 -}; - -static const char **tryFonts = 0; - QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { - if (script == QChar::Script_Common || script == QChar::Script_Han) { -// && !(request.styleStrategy & QFont::NoFontMerging)) { - QFontDatabase db; - if (!db.writingSystems(family).contains(QFontDatabase::Symbol)) { - if(!tryFonts) { - LANGID lid = GetUserDefaultLangID(); - switch( lid&0xff ) { - case LANG_CHINESE: // Chinese (Taiwan) - if ( lid == 0x0804 ) // Taiwan - tryFonts = ch_TW_tryFonts; - else - tryFonts = ch_CN_tryFonts; - break; - case LANG_JAPANESE: - tryFonts = jp_tryFonts; - break; - case LANG_KOREAN: - tryFonts = kr_tryFonts; - break; - default: - tryFonts = other_tryFonts; - break; - } - } - QStringList list; - const char **tf = tryFonts; - while(tf && *tf) { - if(m_families.contains(QLatin1String(*tf))) - list << QLatin1String(*tf); - ++tf; - } - if (!list.isEmpty()) - return list; - } - } QStringList result = QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script); if (!result.isEmpty()) return result; @@ -566,51 +477,24 @@ QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QF } #endif - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << family << style << styleHint - << script << result << m_families; + if (script == QChar::Script_Common || script == QChar::Script_Han) + result.append(QWindowsFontDatabase::extraTryFontsForFamily(family)); + + qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint + << script << result << m_families; + return result; } QString QWindowsFontDatabaseFT::fontDir() const { const QString result = QLatin1String(qgetenv("windir")) + QLatin1String("/Fonts");//QPlatformFontDatabase::fontDir(); - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << result; + qCDebug(lcQpaFonts) << __FUNCTION__ << result; return result; } -HFONT QWindowsFontDatabaseFT::systemFont() -{ - static const HFONT stock_sysfont = (HFONT)GetStockObject(SYSTEM_FONT); - return stock_sysfont; -} - -// Creation functions - -static inline int verticalDPI() -{ - return GetDeviceCaps(QWindowsContext::instance()->displayContext(), LOGPIXELSY); -} - QFont QWindowsFontDatabaseFT::defaultFont() const { return QWindowsFontDatabase::systemDefaultFont(); } -QFont QWindowsFontDatabaseFT::LOGFONT_to_QFont(const LOGFONT& logFont, int verticalDPI_In) -{ - if (verticalDPI_In <= 0) - verticalDPI_In = verticalDPI(); - QFont qFont(QString::fromWCharArray(logFont.lfFaceName)); - qFont.setItalic(logFont.lfItalic); - if (logFont.lfWeight != FW_DONTCARE) - qFont.setWeight(weightFromInteger(logFont.lfWeight)); - const qreal logFontHeight = qAbs(logFont.lfHeight); - qFont.setPointSizeF(logFontHeight * 72.0 / qreal(verticalDPI_In)); - qFont.setUnderline(logFont.lfUnderline); - qFont.setOverline(false); - qFont.setStrikeOut(logFont.lfStrikeOut); - return qFont; -} - QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h index d3cbc0210a..bad6c54bf4 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h @@ -52,7 +52,7 @@ class QWindowsFontDatabaseFT : public QBasicFontDatabase { public: void populateFontDatabase(); - QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle); + QFontEngine *fontEngine(const QFontDef &fontDef, void *handle); QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; @@ -60,9 +60,6 @@ public: virtual QString fontDir() const; virtual QFont defaultFont() const; - static HFONT systemFont(); - static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0); - private: void populate(const QString &family = QString()); diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 6c928119b3..1676b73658 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -219,44 +219,11 @@ inline unsigned int getChar(const QChar *str, int &i, const int len) return uc; } -int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout *glyphs, bool mirrored) const +int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLayout *glyphs) const { int i = 0; int glyph_pos = 0; - if (mirrored) { -#if defined(Q_OS_WINCE) - { -#else - if (symbol) { - for (; i < numChars; ++i, ++glyph_pos) { - unsigned int uc = getChar(str, i, numChars); - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc); - if (!glyphs->glyphs[glyph_pos] && uc < 0x100) - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000); - } - } else if (ttf) { - for (; i < numChars; ++i, ++glyph_pos) { - unsigned int uc = getChar(str, i, numChars); - glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, QChar::mirroredChar(uc)); - } - } else { -#endif - wchar_t first = tm.tmFirstChar; - wchar_t last = tm.tmLastChar; - - for (; i < numChars; ++i, ++glyph_pos) { - uint ucs = QChar::mirroredChar(getChar(str, i, numChars)); - if ( -#ifdef Q_WS_WINCE - tm.tmFirstChar > 60000 || -#endif - ucs >= first && ucs <= last) - glyphs->glyphs[glyph_pos] = ucs; - else - glyphs->glyphs[glyph_pos] = 0; - } - } - } else { + { #if defined(Q_OS_WINCE) { #else @@ -325,8 +292,7 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name, designAdvances(0), designAdvancesSize(0) { - if (QWindowsContext::verboseFonts) - qDebug("%s: font='%s', size=%ld", __FUNCTION__, qPrintable(name), lf.lfHeight); + qCDebug(lcQpaFonts) << __FUNCTION__ << name << lf.lfHeight; HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); fontDef.pixelSize = -lf.lfHeight; @@ -366,9 +332,7 @@ QWindowsFontEngine::~QWindowsFontEngine() if (!DeleteObject(hfont)) qErrnoWarning("%s: QFontEngineWin: failed to delete non-stock font... failed", __FUNCTION__); } - if (QWindowsContext::verboseFonts) - if (QWindowsContext::verboseFonts) - qDebug("%s: font='%s", __FUNCTION__, qPrintable(_name)); + qCDebug(lcQpaFonts) << __FUNCTION__ << _name; if (!uniqueFamilyName.isEmpty()) { QPlatformFontDatabase *pfdb = QWindowsIntegration::instance()->fontDatabase(); @@ -393,7 +357,7 @@ bool QWindowsFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *g } glyphs->numGlyphs = *nglyphs; - *nglyphs = getGlyphIndexes(str, len, glyphs, flags & RightToLeft); + *nglyphs = getGlyphIndexes(str, len, glyphs); if (!(flags & GlyphIndicesOnly)) recalcAdvances(glyphs, flags); @@ -434,8 +398,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape calculateTTFGlyphWidth(hdc, glyph, width); designAdvances[glyph] = QFixed(width) / designToDevice; } - glyphs->advances_x[i] = designAdvances[glyph]; - glyphs->advances_y[i] = 0; + glyphs->advances[i] = designAdvances[glyph]; } if(oldFont) DeleteObject(SelectObject(hdc, oldFont)); @@ -443,8 +406,6 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape for(int i = 0; i < glyphs->numGlyphs; i++) { unsigned int glyph = glyphs->glyphs[i]; - glyphs->advances_y[i] = 0; - if (glyph >= widthCacheSize) { int newSize = (glyph + 256) >> 8 << 8; widthCache = q_check_ptr((unsigned char *)realloc(widthCache, @@ -452,9 +413,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize); widthCacheSize = newSize; } - glyphs->advances_x[i] = widthCache[glyph]; + glyphs->advances[i] = widthCache[glyph]; // font-width cache failed - if (glyphs->advances_x[i] == 0) { + if (glyphs->advances[i].value() == 0) { int width = 0; if (!oldFont) oldFont = SelectObject(hdc, hfont); @@ -473,7 +434,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape } else { calculateTTFGlyphWidth(hdc, glyph, width); } - glyphs->advances_x[i] = width; + glyphs->advances[i] = width; // if glyph's within cache range, store it for later if (width > 0 && width < 0x100) widthCache[glyph] = width; @@ -1347,8 +1308,7 @@ QWindowsMultiFontEngine::QWindowsMultiFontEngine(QFontEngine *first, const QStri : QFontEngineMulti(fallbacks.size()+1), fallbacks(fallbacks) { - if (QWindowsContext::verboseFonts) - qDebug() << __FUNCTION__ << engines.size() << first << first->fontDef.family << fallbacks; + qCDebug(lcQpaFonts) << __FUNCTION__ << engines.size() << first << first->fontDef.family << fallbacks; engines[0] = first; first->ref.ref(); fontDef = engines[0]->fontDef; @@ -1357,8 +1317,7 @@ QWindowsMultiFontEngine::QWindowsMultiFontEngine(QFontEngine *first, const QStri QWindowsMultiFontEngine::~QWindowsMultiFontEngine() { - if (QWindowsContext::verboseFonts) - qDebug("%s", __FUNCTION__); + qCDebug(lcQpaFonts) << __FUNCTION__; } void QWindowsMultiFontEngine::loadEngine(int at) @@ -1409,9 +1368,7 @@ void QWindowsMultiFontEngine::loadEngine(int at) fedw->ref.ref(); engines[at] = fedw; - if (QWindowsContext::verboseFonts) - qDebug("%s %d %s", __FUNCTION__, at, qPrintable(fam)); - + qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam; return; } else { qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__); @@ -1433,9 +1390,7 @@ void QWindowsMultiFontEngine::loadEngine(int at) engines[at] = new QWindowsFontEngine(fam, hfont, stockFont, lf, data); engines[at]->ref.ref(); engines[at]->fontDef = fontDef; - if (QWindowsContext::verboseFonts) - qDebug("%s %d %s", __FUNCTION__, at, qPrintable(fam)); - + qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam; // TODO: increase cost in QFontCache for the font engine loaded here } diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h index acf84d270c..e3fb3281a3 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.h +++ b/src/plugins/platforms/windows/qwindowsfontengine.h @@ -127,7 +127,7 @@ public: virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); #endif - int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const; + int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs) const; void getCMap(); bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const; diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index d81848fcc7..ce5ea8167f 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -212,8 +212,7 @@ QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *di , m_xHeight(-1) , m_lineGap(-1) { - if (QWindowsContext::verboseFonts) - qDebug("%s %g", __FUNCTION__, pixelSize); + qCDebug(lcQpaFonts) << __FUNCTION__ << pixelSize; Q_ASSERT(m_directWriteFontFace); @@ -227,8 +226,7 @@ QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *di QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite() { - if (QWindowsContext::verboseFonts) - qDebug("%s", __FUNCTION__); + qCDebug(lcQpaFonts) << __FUNCTION__; m_fontEngineData->directWriteFactory->Release(); m_directWriteFontFace->Release(); @@ -327,13 +325,8 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly QVarLengthArray<UINT32> codePoints(len); int actualLength = 0; - if (flags & QFontEngine::RightToLeft) { - for (int i = 0; i < len; ++i) - codePoints[actualLength++] = QChar::mirroredChar(getChar(str, i, len)); - } else { - for (int i = 0; i < len; ++i) - codePoints[actualLength++] = getChar(str, i, len); - } + for (int i = 0; i < len; ++i) + codePoints[actualLength++] = getChar(str, i, len); QVarLengthArray<UINT16> glyphIndices(actualLength); HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), actualLength, @@ -368,13 +361,11 @@ void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEn glyphIndices.size(), glyphMetrics.data()); if (SUCCEEDED(hr)) { - for (int i=0; i<glyphs->numGlyphs; ++i) { - glyphs->advances_x[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth); - glyphs->advances_y[i] = 0; - } + for (int i = 0; i < glyphs->numGlyphs; ++i) + glyphs->advances[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth); if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { for (int i = 0; i < glyphs->numGlyphs; ++i) - glyphs->advances_x[i] = glyphs->advances_x[i].round(); + glyphs->advances[i] = glyphs->advances[i].round(); } } else { qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__); diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h index 57a6a3ba1d..399bb5f5ad 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h @@ -105,6 +105,8 @@ public: static QString fontNameSubstitute(const QString &familyName); + IDWriteFontFace *directWriteFontFace() const { return m_directWriteFontFace; } + private: QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform); void collectMetrics(); diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp new file mode 100644 index 0000000000..9c8b5ed620 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsgdiintegration.h" +#include "qwindowscontext.h" +#include "qwindowsbackingstore.h" +#include "qwindowsgdinativeinterface.h" + +#include <QtCore/QDebug> +#include <QtGui/private/qpixmap_raster_p.h> + +QT_BEGIN_NAMESPACE + +class QWindowsGdiIntegrationPrivate +{ +public: + QWindowsGdiNativeInterface m_nativeInterface; +}; + +QWindowsGdiIntegration::QWindowsGdiIntegration(const QStringList ¶mList) + : QWindowsIntegration(paramList) + , d(new QWindowsGdiIntegrationPrivate) +{} + +QWindowsGdiIntegration::~QWindowsGdiIntegration() +{} + +QPlatformNativeInterface *QWindowsGdiIntegration::nativeInterface() const +{ + return &d->m_nativeInterface; +} + +QPlatformPixmap *QWindowsGdiIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const +{ + return new QRasterPlatformPixmap(type); +} + +QPlatformBackingStore *QWindowsGdiIntegration::createPlatformBackingStore(QWindow *window) const +{ + return new QWindowsBackingStore(window); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.h b/src/plugins/platforms/windows/qwindowsgdiintegration.h new file mode 100644 index 0000000000..0bf44d5439 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsgdiintegration.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSGDIINTEGRATION_H +#define QWINDOWSGDIINTEGRATION_H + +#include "qwindowsintegration.h" + +QT_BEGIN_NAMESPACE + +class QWindowsGdiIntegrationPrivate; +class QWindowsGdiIntegration : public QWindowsIntegration +{ +public: + explicit QWindowsGdiIntegration(const QStringList ¶mList); + virtual ~QWindowsGdiIntegration(); + + QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE; + QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const Q_DECL_OVERRIDE; + QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE; + +private: + QScopedPointer<QWindowsGdiIntegrationPrivate> d; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSGDIINTEGRATION_H diff --git a/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp b/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp new file mode 100644 index 0000000000..c1b0c139c9 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsgdinativeinterface.h" +#include "qwindowsbackingstore.h" + +#include <QtGui/QBackingStore> + +QT_BEGIN_NAMESPACE + +void *QWindowsGdiNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs) +{ + if (!bs || !bs->handle()) { + qWarning("%s: '%s' requested for null backingstore or backingstore without handle.", __FUNCTION__, resource.constData()); + return 0; + } + QWindowsBackingStore *wbs = static_cast<QWindowsBackingStore *>(bs->handle()); + if (resource == "getDC") + return wbs->getDC(); + qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); + return 0; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsgdinativeinterface.h b/src/plugins/platforms/windows/qwindowsgdinativeinterface.h new file mode 100644 index 0000000000..3aa3a0b175 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsgdinativeinterface.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSGDINATIVEINTERFACE_H +#define QWINDOWSGDINATIVEINTERFACE_H + +#include "qwindowsnativeinterface.h" + +QT_BEGIN_NAMESPACE + +class QWindowsGdiNativeInterface : public QWindowsNativeInterface +{ + Q_OBJECT +public: + void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSGDINATIVEINTERFACE_H diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 82deb0f473..9bfe4e6e26 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -223,7 +223,7 @@ static void describeFormats(HDC hdc) PIXELFORMATDESCRIPTOR pfd; initPixelFormatDescriptor(&pfd); DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - qDebug() << '#' << i << '/' << pfiMax << ':' << pfd; + qCDebug(lcQpaGl) << '#' << i << '/' << pfiMax << ':' << pfd; } } @@ -341,10 +341,8 @@ static int choosePixelFormat(HDC hdc, const QSurfaceFormat &format, bestPfi = pfi; *obtainedPfd = checkPfd; } - if (QWindowsContext::verboseGL) - qDebug() << __FUNCTION__ << " checking " << pfi << '/' << pfiMax - << " score=" << score << " (best " << bestPfi << '/' << bestScore - << ") " << checkPfd; + qCDebug(lcQpaGl) << __FUNCTION__ << " checking " << pfi << '/' << pfiMax + << " score=" << score << " (best " << bestPfi << '/' << bestScore << ") " << checkPfd; } } // for if (bestPfi > 0) @@ -471,15 +469,15 @@ static int choosePixelFormat(HDC hdc, initPixelFormatDescriptor(obtainedPfd); DescribePixelFormat(hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), obtainedPfd); if (!isAcceptableFormat(additional, *obtainedPfd, true)) { - if (QWindowsContext::verboseGL) - qDebug() << __FUNCTION__ << " obtained px #" << pixelFormat - << " not acceptable=" << *obtainedPfd; + qCDebug(lcQpaGl) << __FUNCTION__ << " obtained px #" << pixelFormat + << " not acceptable=" << *obtainedPfd; pixelFormat = 0; } #ifndef QT_NO_DEBUG_OUTPUT - if (QWindowsContext::verboseGL) { - QDebug nsp = qDebug().nospace(); + if (lcQpaGl().isDebugEnabled()) { + QString message; + QDebug nsp(&message); nsp << __FUNCTION__; if (sampleBuffersRequested) nsp << " samples=" << iAttributes[samplesValuePosition]; @@ -488,6 +486,7 @@ static int choosePixelFormat(HDC hdc, nsp << iAttributes[ii] << ','; nsp << noshowbase << dec << "\n obtained px #" << pixelFormat << " of " << numFormats << "\n " << *obtainedPfd; + qCDebug(lcQpaGl) << message; } // Debug #endif @@ -611,9 +610,8 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext, break; } } - if (QWindowsContext::verboseGL) - qDebug("%s: Creating context version %d.%d with %d attributes", - __FUNCTION__, majorVersion, minorVersion, attribIndex / 2); + qCDebug(lcQpaGl) << __FUNCTION__ << "Creating context version" + << majorVersion << '.' << minorVersion << attribIndex / 2 << "attributes"; const HGLRC result = staticContext.wglCreateContextAttribsARB(hdc, shared, attributes); @@ -842,8 +840,7 @@ QOpenGLStaticContext *QOpenGLStaticContext::create() if (!wglGetCurrentContext()) temporaryContext.reset(new QOpenGLTemporaryContext); QOpenGLStaticContext *result = new QOpenGLStaticContext; - if (QWindowsContext::verboseGL) - qDebug() << __FUNCTION__ << *result; + qCDebug(lcQpaGl) << __FUNCTION__ << *result; return result; } @@ -857,7 +854,7 @@ QDebug operator<<(QDebug d, const QOpenGLStaticContext &s) if (s.hasExtensions()) nsp << ", Extension-API present"; nsp << "\nExtensions: " << (s.extensionNames.count(' ') + 1); - if (QWindowsContext::verboseGL > 1) + if (QWindowsContext::verbose > 1) nsp << s.extensionNames; return d; } @@ -882,7 +879,9 @@ QWindowsGLContext::QWindowsGLContext(const QOpenGLStaticContextPtr &staticContex m_staticContext(staticContext), m_context(context), m_renderingContext(0), - m_pixelFormat(0), m_extensionsUsed(false) + m_pixelFormat(0), + m_extensionsUsed(false), + m_swapInterval(-1) { QSurfaceFormat format = context->format(); if (format.renderableType() == QSurfaceFormat::DefaultRenderableType) @@ -915,7 +914,7 @@ QWindowsGLContext::QWindowsGLContext(const QOpenGLStaticContextPtr &staticContex if (!hdc) break; - if (QWindowsContext::verboseGL > 1) + if (QWindowsContext::verbose > 1) describeFormats(hdc); // Preferably use direct rendering and ARB extensions (unless pixmap // or explicitly turned off on command line). @@ -979,11 +978,9 @@ QWindowsGLContext::QWindowsGLContext(const QOpenGLStaticContextPtr &staticContex QWindowsOpenGLContextFormat::current().apply(&m_obtainedFormat); - if (requestedAdditional.swapInterval != -1 && m_staticContext->wglSwapInternalExt) { - m_staticContext->wglSwapInternalExt(requestedAdditional.swapInterval); - if (m_staticContext->wglGetSwapInternalExt) - obtainedSwapInternal = m_staticContext->wglGetSwapInternalExt(); - } + if (m_staticContext->wglGetSwapInternalExt) + obtainedSwapInternal = m_staticContext->wglGetSwapInternalExt(); + wglMakeCurrent(0, 0); } while (false); if (hdc) @@ -991,14 +988,12 @@ QWindowsGLContext::QWindowsGLContext(const QOpenGLStaticContextPtr &staticContex if (dummyWindow) DestroyWindow(dummyWindow); - if (QWindowsContext::verboseGL) - qDebug() << __FUNCTION__ << this << (tryExtensions ? "ARB" : "GDI") - << " requested: " << context->format() - << "\n obtained #" << m_pixelFormat << (m_extensionsUsed ? "ARB" : "GDI") - << m_obtainedFormat << "\n " << m_obtainedPixelFormatDescriptor - << " swap interval: " << obtainedSwapInternal - << "\n default: " << m_staticContext->defaultFormat - << "\n HGLRC=" << m_renderingContext; + qCDebug(lcQpaGl) << __FUNCTION__ << this << (tryExtensions ? "ARB" : "GDI") + << " requested: " << context->format() + << "\n obtained #" << m_pixelFormat << (m_extensionsUsed ? "ARB" : "GDI") << m_obtainedFormat + << "\n " << m_obtainedPixelFormatDescriptor << " swap interval: " << obtainedSwapInternal + << "\n default: " << m_staticContext->defaultFormat + << "\n HGLRC=" << m_renderingContext; } QWindowsGLContext::~QWindowsGLContext() @@ -1039,8 +1034,8 @@ static inline const QOpenGLContextData * void QWindowsGLContext::swapBuffers(QPlatformSurface *surface) { - if (QWindowsContext::verboseGL > 1) - qDebug() << __FUNCTION__ << surface; + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaGl) << __FUNCTION__ << surface; if (const QOpenGLContextData *contextData = findByHWND(m_windowContexts, handleOf(surface))) { SwapBuffers(contextData->hdc); } else { @@ -1051,8 +1046,8 @@ void QWindowsGLContext::swapBuffers(QPlatformSurface *surface) bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) { #ifdef DEBUG_GL - if (QWindowsContext::verboseGL > 1) - qDebug("%s context=%p contexts=%d", __FUNCTION__, this, m_windowContexts.size()); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaGl) << __FUNCTION__ << this << m_windowContexts.size() << "contexts"; #endif // DEBUG_GL Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface); @@ -1087,14 +1082,26 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) window->setFlag(QWindowsWindow::OpenGLDoubleBuffered); } m_windowContexts.append(newContext); - return wglMakeCurrent(newContext.hdc, newContext.renderingContext); + + bool success = wglMakeCurrent(newContext.hdc, newContext.renderingContext); + + // Set the swap interval + if (m_staticContext->wglSwapInternalExt) { + const int interval = surface->format().swapInterval(); + if (interval >= 0 && m_swapInterval != interval) { + m_swapInterval = interval; + m_staticContext->wglSwapInternalExt(interval); + } + } + + return success; } void QWindowsGLContext::doneCurrent() { #ifdef DEBUG_GL - if (QWindowsContext::verboseGL > 1) - qDebug("%s context=%p %d contexts", __FUNCTION__, this, m_windowContexts.size()); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaGl) << __FUNCTION__ << this << m_windowContexts.size() << "contexts"; #endif // DEBUG_GL wglMakeCurrent(0, 0); releaseDCs(); @@ -1104,10 +1111,8 @@ QWindowsGLContext::GL_Proc QWindowsGLContext::getProcAddress(const QByteArray &p { // TODO: Will that work with the calling conventions? GL_Proc procAddress = reinterpret_cast<GL_Proc>(wglGetProcAddress(procName.constData())); - if (QWindowsContext::verboseGL > 1) - qDebug("%s('%s') with current_hglrc=%p returns %p", - __FUNCTION__, procName.constData(), - wglGetCurrentContext(), procAddress); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaGl) << __FUNCTION__ << procName << wglGetCurrentContext() << "returns" << procAddress; if (!procAddress) qWarning("%s: Unable to resolve '%s'", __FUNCTION__, procName.constData()); return procAddress; diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index 730e90bf70..c6b477128a 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -64,11 +64,10 @@ enum QWindowsGLFormatFlags // Additional format information for Windows. struct QWindowsOpenGLAdditionalFormat { - QWindowsOpenGLAdditionalFormat(unsigned formatFlagsIn = 0, unsigned pixmapDepthIn = 0, unsigned swapIntervalIn = -1) : - formatFlags(formatFlagsIn), pixmapDepth(pixmapDepthIn), swapInterval(swapIntervalIn) {} + QWindowsOpenGLAdditionalFormat(unsigned formatFlagsIn = 0, unsigned pixmapDepthIn = 0) : + formatFlags(formatFlagsIn), pixmapDepth(pixmapDepthIn) { } unsigned formatFlags; // QWindowsGLFormatFlags. unsigned pixmapDepth; // for QWindowsGLRenderToPixmap - int swapInterval; }; // Per-window data for active OpenGL contexts. @@ -178,6 +177,7 @@ private: PIXELFORMATDESCRIPTOR m_obtainedPixelFormatDescriptor; int m_pixelFormat; bool m_extensionsUsed; + int m_swapInterval; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp index e7cd0bc6c8..878db7185d 100644 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp +++ b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp @@ -75,11 +75,11 @@ QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { m_flags = flags; - if (QWindowsContext::verboseEvents > 2) - qDebug(">%s %s %d", __FUNCTION__, qPrintable(objectName()), int(flags)); + if (QWindowsContext::verbose > 2 && lcQpaEvents().isDebugEnabled()) + qCDebug(lcQpaEvents) << '>' << __FUNCTION__ << objectName() << flags; const bool rc = QEventDispatcherWin32::processEvents(flags); - if (QWindowsContext::verboseEvents > 2) - qDebug("<%s %s returns %d", __FUNCTION__, qPrintable(objectName()), rc); + if (QWindowsContext::verbose > 2 && lcQpaEvents().isDebugEnabled()) + qCDebug(lcQpaEvents) << '<' << __FUNCTION__ << "returns" << rc; return rc; } diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index a84d30de0f..2429e8a4fa 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -188,8 +188,7 @@ void QWindowsInputContext::reset() if (!m_compositionContext.hwnd) return; QObject *fo = qApp->focusObject(); - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__<< fo; + qCDebug(lcQpaInputMethods) << __FUNCTION__<< fo; if (!fo) return; if (m_compositionContext.isComposing) { @@ -221,8 +220,7 @@ void QWindowsInputContext::cursorRectChanged() if (!cursorRectangle.isValid()) return; - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__<< cursorRectangle; + qCDebug(lcQpaInputMethods) << __FUNCTION__<< cursorRectangle; const HIMC himc = ImmGetContext(m_compositionContext.hwnd); if (!himc) @@ -259,8 +257,7 @@ void QWindowsInputContext::invokeAction(QInputMethod::Action action, int cursorP return; } - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__ << cursorPosition << action; + qCDebug(lcQpaInputMethods) << __FUNCTION__ << cursorPosition << action; if (cursorPosition < 0 || cursorPosition > m_compositionContext.composition.size()) reset(); @@ -339,8 +336,7 @@ bool QWindowsInputContext::startComposition(HWND hwnd) QWindow *window = qApp->focusWindow(); if (!window) return false; - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__ << fo << window; + qCDebug(lcQpaInputMethods) << __FUNCTION__ << fo << window; if (!fo || QWindowsWindow::handleOf(window) != hwnd) return false; initContext(hwnd); @@ -402,9 +398,8 @@ bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn) { QObject *fo = qApp->focusObject(); const int lParam = int(lParamIn); - if (QWindowsContext::verboseInputMethods) - qDebug() << '>' << __FUNCTION__ << fo << debugComposition(lParam) - << " composing=" << m_compositionContext.isComposing; + qCDebug(lcQpaInputMethods) << '>' << __FUNCTION__ << fo << debugComposition(lParam) + << " composing=" << m_compositionContext.isComposing; if (!fo || m_compositionContext.hwnd != hwnd || !lParam) return false; const HIMC himc = ImmGetContext(m_compositionContext.hwnd); @@ -443,11 +438,9 @@ bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn) endContextComposition(); } const bool result = QCoreApplication::sendEvent(fo, event.data()); - if (QWindowsContext::verboseInputMethods) - qDebug() << '<' << __FUNCTION__ << "sending markup=" - << event->attributes().size() - << " commit=" << event->commitString() - << " to " << fo << " returns " << result; + qCDebug(lcQpaInputMethods) << '<' << __FUNCTION__ << "sending markup=" + << event->attributes().size() << " commit=" << event->commitString() + << " to " << fo << " returns " << result; update(Qt::ImQueryAll); ImmReleaseContext(m_compositionContext.hwnd, himc); return result; @@ -455,8 +448,7 @@ bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn) bool QWindowsInputContext::endComposition(HWND hwnd) { - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__ << m_endCompositionRecursionGuard << hwnd; + qCDebug(lcQpaInputMethods) << __FUNCTION__ << m_endCompositionRecursionGuard << hwnd; // Googles Pinyin Input Method likes to call endComposition again // when we call notifyIME with CPS_CANCEL, so protect ourselves // against that. @@ -549,10 +541,8 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) return -1; const DWORD memSize = sizeof(RECONVERTSTRING) + (surroundingText.length() + 1) * sizeof(ushort); - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__ << " reconv=" << reconv - << " surroundingText=" << surroundingText - << " size=" << memSize; + qCDebug(lcQpaInputMethods) << __FUNCTION__ << " reconv=" << reconv + << " surroundingText=" << surroundingText << " size=" << memSize; // If memory is not allocated, return the required size. if (!reconv) return surroundingText.isEmpty() ? -1 : int(memSize); @@ -567,8 +557,7 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv) const int startPos = bounds.position(); bounds.toNextBoundary(); const int endPos = bounds.position(); - if (QWindowsContext::verboseInputMethods) - qDebug() << __FUNCTION__ << " boundary=" << startPos << endPos; + qCDebug(lcQpaInputMethods) << __FUNCTION__ << " boundary=" << startPos << endPos; // Select the text, this will be overwritten by following IME events. QList<QInputMethodEvent::Attribute> attributes; attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, startPos, endPos-startPos, QVariant()); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index b6e75929f8..e5d9444966 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -41,15 +41,22 @@ ****************************************************************************/ #include "qwindowsintegration.h" -#include "qwindowsbackingstore.h" #include "qwindowswindow.h" #include "qwindowscontext.h" -#if defined(QT_OPENGL_ES_2) + +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) # include "qwindowseglcontext.h" # include <QtGui/QOpenGLContext> -#elif !defined(QT_NO_OPENGL) +#endif + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) # include "qwindowsglcontext.h" #endif + +#if !defined(QT_NO_OPENGL) +# include <QtGui/QOpenGLFunctions> +#endif + #include "qwindowsscreen.h" #include "qwindowstheme.h" #include "qwindowsservices.h" @@ -75,8 +82,6 @@ #if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER) # include "qwindowssessionmanager.h" #endif -#include <QtGui/QBackingStore> -#include <QtGui/private/qpixmap_raster_p.h> #include <QtGui/private/qguiapplication_p.h> #include <QtCore/private/qeventdispatcher_win_p.h> @@ -86,174 +91,6 @@ QT_BEGIN_NAMESPACE /*! - \class QWindowsNativeInterface - \brief Provides access to native handles. - - Currently implemented keys - \list - \li handle (HWND) - \li getDC (DC) - \li releaseDC Releases the previously acquired DC and returns 0. - \endlist - - \internal - \ingroup qt-lighthouse-win -*/ - -class QWindowsNativeInterface : public QPlatformNativeInterface -{ - Q_OBJECT - Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose) -public: -#ifndef QT_NO_OPENGL - virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); -#endif - virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); - virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs); - - Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate, - const QString &windowName, - void *eventProc) const; - - Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const; - - Q_INVOKABLE void beep() { MessageBeep(MB_OK); } // For QApplication - - bool asyncExpose() const; - void setAsyncExpose(bool value); - - QVariantMap windowProperties(QPlatformWindow *window) const; - QVariant windowProperty(QPlatformWindow *window, const QString &name) const; - QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; - void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); -}; - -void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) -{ - if (!window || !window->handle()) { - qWarning("%s: '%s' requested for null window or window without handle.", __FUNCTION__, resource.constData()); - return 0; - } - QWindowsWindow *bw = static_cast<QWindowsWindow *>(window->handle()); - if (resource == "handle") - return bw->handle(); - if (window->surfaceType() == QWindow::RasterSurface) { - if (resource == "getDC") - return bw->getDC(); - if (resource == "releaseDC") { - bw->releaseDC(); - return 0; - } - } - qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); - return 0; -} - -void *QWindowsNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs) -{ - if (!bs || !bs->handle()) { - qWarning("%s: '%s' requested for null backingstore or backingstore without handle.", __FUNCTION__, resource.constData()); - return 0; - } - QWindowsBackingStore *wbs = static_cast<QWindowsBackingStore *>(bs->handle()); - if (resource == "getDC") - return wbs->getDC(); - qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); - return 0; -} - -static const char customMarginPropertyC[] = "WindowsCustomMargins"; - -QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const -{ - QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window); - if (name == QLatin1String(customMarginPropertyC)) - return qVariantFromValue(platformWindow->customMargins()); - return QVariant(); -} - -QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const -{ - const QVariant result = windowProperty(window, name); - return result.isValid() ? result : defaultValue; -} - -void QWindowsNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) -{ - QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window); - if (name == QLatin1String(customMarginPropertyC)) - platformWindow->setCustomMargins(qvariant_cast<QMargins>(value)); -} - -QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) const -{ - QVariantMap result; - const QString customMarginProperty = QLatin1String(customMarginPropertyC); - result.insert(customMarginProperty, windowProperty(window, customMarginProperty)); - return result; -} - -#ifndef QT_NO_OPENGL -void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) -{ - if (!context || !context->handle()) { - qWarning("%s: '%s' requested for null context or context without handle.", __FUNCTION__, resource.constData()); - return 0; - } -#ifdef QT_OPENGL_ES_2 - QWindowsEGLContext *windowsEglContext = static_cast<QWindowsEGLContext *>(context->handle()); - if (resource == QByteArrayLiteral("eglDisplay")) - return windowsEglContext->eglDisplay(); - if (resource == QByteArrayLiteral("eglContext")) - return windowsEglContext->eglContext(); - if (resource == QByteArrayLiteral("eglConfig")) - return windowsEglContext->eglConfig(); -#else // QT_OPENGL_ES_2 - QWindowsGLContext *windowsContext = static_cast<QWindowsGLContext *>(context->handle()); - if (resource == QByteArrayLiteral("renderingContext")) - return windowsContext->renderingContext(); -#endif // !QT_OPENGL_ES_2 - - qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); - return 0; -} -#endif // !QT_NO_OPENGL - -/*! - \brief Creates a non-visible window handle for filtering messages. -*/ - -void *QWindowsNativeInterface::createMessageWindow(const QString &classNameTemplate, - const QString &windowName, - void *eventProc) const -{ - QWindowsContext *ctx = QWindowsContext::instance(); - const HWND hwnd = ctx->createDummyWindow(classNameTemplate, - (wchar_t*)windowName.utf16(), - (WNDPROC)eventProc); - return hwnd; -} - -/*! - \brief Registers a unique window class with a callback function based on \a classNameIn. -*/ - -QString QWindowsNativeInterface::registerWindowClass(const QString &classNameIn, void *eventProc) const -{ - return QWindowsContext::instance()->registerWindowClass(classNameIn, (WNDPROC)eventProc); -} - -bool QWindowsNativeInterface::asyncExpose() const -{ - return QWindowsContext::instance()->asyncExpose(); -} - -void QWindowsNativeInterface::setAsyncExpose(bool value) -{ - QWindowsContext::instance()->setAsyncExpose(value); -} - -/*! \class QWindowsIntegration \brief QPlatformIntegration implementation for Windows. \internal @@ -296,9 +133,10 @@ void QWindowsNativeInterface::setAsyncExpose(bool value) struct QWindowsIntegrationPrivate { -#if defined(QT_OPENGL_ES_2) +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) typedef QSharedPointer<QWindowsEGLStaticContext> QEGLStaticContextPtr; -#elif !defined(QT_NO_OPENGL) +#endif +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) typedef QSharedPointer<QOpenGLStaticContext> QOpenGLStaticContextPtr; #endif @@ -308,16 +146,16 @@ struct QWindowsIntegrationPrivate const unsigned m_options; QWindowsContext m_context; QPlatformFontDatabase *m_fontDatabase; - QWindowsNativeInterface m_nativeInterface; #ifndef QT_NO_CLIPBOARD QWindowsClipboard m_clipboard; # ifndef QT_NO_DRAGANDDROP QWindowsDrag m_drag; # endif #endif -#if defined(QT_OPENGL_ES_2) +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) QEGLStaticContextPtr m_staticEGLContext; -#elif !defined(QT_NO_OPENGL) +#endif +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) QOpenGLStaticContextPtr m_staticOpenGLContext; #endif QWindowsInputContext m_inputContext; @@ -345,8 +183,10 @@ static inline unsigned parseOptions(const QStringList ¶mList) } } else if (param == QLatin1String("gl=gdi")) { options |= QWindowsIntegration::DisableArb; - } else if (param == QLatin1String("mousefromtouch")) { - options |= QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch; + } else if (param == QLatin1String("nomousefromtouch")) { + options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch; + } else if (param.startsWith(QLatin1String("verbose="))) { + QWindowsContext::verbose = param.right(param.size() - 8).toInt(); } } return options; @@ -375,8 +215,6 @@ QWindowsIntegration::QWindowsIntegration(const QStringList ¶mList) : QWindowsIntegration::~QWindowsIntegration() { - if (QWindowsContext::verboseIntegration) - qDebug("%s", __FUNCTION__); } bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) const @@ -388,8 +226,8 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co case OpenGL: return true; case ThreadedOpenGL: -# ifdef QT_OPENGL_ES_2 - return QWindowsEGLContext::hasThreadedOpenGLCapability(); +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) + return QOpenGLFunctions::isES() ? QWindowsEGLContext::hasThreadedOpenGLCapability() : true; # else return true; # endif // QT_OPENGL_ES_2 @@ -406,14 +244,9 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co return false; } -QPlatformPixmap *QWindowsIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const -{ - return new QRasterPlatformPixmap(type); -} - -QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const +QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const { - QWindowsWindow::WindowData requested; + QWindowsWindowData requested; requested.flags = window->flags(); requested.geometry = window->geometry(); // Apply custom margins (see QWindowsWindow::setCustomMargins())). @@ -421,59 +254,61 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons if (customMarginsV.isValid()) requested.customMargins = qvariant_cast<QMargins>(customMarginsV); - const QWindowsWindow::WindowData obtained - = QWindowsWindow::WindowData::create(window, requested, window->title()); - if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) - qDebug().nospace() - << __FUNCTION__ << '<' << window << '\n' - << " Requested: " << requested.geometry << "frame incl.: " - << QWindowsGeometryHint::positionIncludesFrame(window) - << " Flags=" - << QWindowsWindow::debugWindowFlags(requested.flags) << '\n' - << " Obtained : " << obtained.geometry << " Margins " - << obtained.frame << " Flags=" - << QWindowsWindow::debugWindowFlags(obtained.flags) - << " Handle=" << obtained.hwnd << '\n'; - if (!obtained.hwnd) - return 0; - if (requested.flags != obtained.flags) - window->setFlags(obtained.flags); - // Trigger geometry change signals of QWindow. - if ((obtained.flags & Qt::Desktop) != Qt::Desktop && requested.geometry != obtained.geometry) - QWindowSystemInterface::handleGeometryChange(window, obtained.geometry); - return new QWindowsWindow(window, obtained); + const QWindowsWindowData obtained + = QWindowsWindowData::create(window, requested, window->title()); + qCDebug(lcQpaWindows).nospace() + << __FUNCTION__ << '<' << window + << "\n Requested: " << requested.geometry << "frame incl.: " + << QWindowsGeometryHint::positionIncludesFrame(window) + << " Flags=" << QWindowsWindow::debugWindowFlags(requested.flags) + << "\n Obtained : " << obtained.geometry << " Margins "<< obtained.frame + << " Flags=" << QWindowsWindow::debugWindowFlags(obtained.flags) + << " Handle=" << obtained.hwnd << '\n'; + + if (obtained.hwnd) { + if (requested.flags != obtained.flags) + window->setFlags(obtained.flags); + // Trigger geometry change signals of QWindow. + if ((obtained.flags & Qt::Desktop) != Qt::Desktop && requested.geometry != obtained.geometry) + QWindowSystemInterface::handleGeometryChange(window, obtained.geometry); + } + + return obtained; } -QPlatformBackingStore *QWindowsIntegration::createPlatformBackingStore(QWindow *window) const +QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const { - if (QWindowsContext::verboseIntegration) - qDebug() << __FUNCTION__ << window; - return new QWindowsBackingStore(window); + QWindowsWindowData data = createWindowData(window); + return data.hwnd ? new QWindowsWindow(window, data) + : Q_NULLPTR; } #ifndef QT_NO_OPENGL QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - if (QWindowsContext::verboseIntegration) - qDebug() << __FUNCTION__ << context->format(); -#ifdef QT_OPENGL_ES_2 - if (d->m_staticEGLContext.isNull()) { - QWindowsEGLStaticContext *staticContext = QWindowsEGLStaticContext::create(); - if (!staticContext) - return 0; - d->m_staticEGLContext = QSharedPointer<QWindowsEGLStaticContext>(staticContext); + qCDebug(lcQpaGl) << __FUNCTION__ << context->format(); +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) + if (QOpenGLFunctions::isES()){ + if (d->m_staticEGLContext.isNull()) { + QWindowsEGLStaticContext *staticContext = QWindowsEGLStaticContext::create(); + if (!staticContext) + return 0; + d->m_staticEGLContext = QSharedPointer<QWindowsEGLStaticContext>(staticContext); + } + return new QWindowsEGLContext(d->m_staticEGLContext, context->format(), context->shareHandle()); + } +#endif +#if !defined(QT_OPENGL_ES_2) + if (!QOpenGLFunctions::isES()) { + if (d->m_staticOpenGLContext.isNull()) + d->m_staticOpenGLContext = + QSharedPointer<QOpenGLStaticContext>(QOpenGLStaticContext::create()); + QScopedPointer<QWindowsGLContext> result(new QWindowsGLContext(d->m_staticOpenGLContext, context)); + return result->isValid() ? result.take() : 0; } - return new QWindowsEGLContext(d->m_staticEGLContext, context->format(), context->shareHandle()); -#else // QT_OPENGL_ES_2 - if (d->m_staticOpenGLContext.isNull()) - d->m_staticOpenGLContext = - QSharedPointer<QOpenGLStaticContext>(QOpenGLStaticContext::create()); - QScopedPointer<QWindowsGLContext> result(new QWindowsGLContext(d->m_staticOpenGLContext, context)); - if (result->isValid()) - return result.take(); - return 0; #endif // !QT_OPENGL_ES_2 + return 0; } #endif // !QT_NO_OPENGL @@ -510,9 +345,7 @@ QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const d->m_fontDatabase = new QWindowsFontDatabase; #else if (isQMLApplication()) { - if (QWindowsContext::verboseIntegration) { - qDebug() << "QML application detected, using FreeType rendering"; - } + qCDebug(lcQpaFonts) << "QML application detected, using FreeType rendering"; d->m_fontDatabase = new QWindowsFontDatabaseFT; } else @@ -563,11 +396,9 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co case QPlatformIntegration::SynthesizeMouseFromTouchEvents: #ifdef Q_OS_WINCE // We do not want Qt to synthesize mouse events as Windows also does that. - // Alternatively, Windows-generated touch mouse events can be identified and - // ignored by checking GetMessageExtraInfo() for MI_WP_SIGNATURE (0xFF515700). return false; #else // Q_OS_WINCE - return QVariant(!(d->m_options & PassOsMouseEventsSynthesizedFromTouch)); + return QVariant(bool(d->m_options & DontPassOsMouseEventsSynthesizedFromTouch)); #endif // !Q_OS_WINCE default: break; @@ -585,11 +416,6 @@ QList<int> QWindowsIntegration::possibleKeys(const QKeyEvent *e) const return d->m_context.possibleKeys(e); } -QPlatformNativeInterface *QWindowsIntegration::nativeInterface() const -{ - return &d->m_nativeInterface; -} - #ifndef QT_NO_CLIPBOARD QPlatformClipboard * QWindowsIntegration::clipboard() const { @@ -655,5 +481,3 @@ QPlatformServices *QWindowsIntegration::services() const } QT_END_NAMESPACE - -#include "qwindowsintegration.moc" diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 97916a479b..2202ebd39e 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE struct QWindowsIntegrationPrivate; +struct QWindowsWindowData; +class QWindowsWindow; class QWindowsIntegration : public QPlatformIntegration { @@ -60,7 +62,7 @@ public: DisableArb = 0x4, NoNativeDialogs = 0x8, XpNativeDialogs = 0x10, - PassOsMouseEventsSynthesizedFromTouch = 0x20 // Pass OS-generated mouse events from touch. + DontPassOsMouseEventsSynthesizedFromTouch = 0x20 // Do not pass OS-generated mouse events from touch. }; explicit QWindowsIntegration(const QStringList ¶mList); @@ -68,9 +70,8 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; - virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; + QWindowsWindowData createWindowData(QWindow *window) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; - QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; #ifndef QT_NO_OPENGL virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; #endif @@ -85,7 +86,6 @@ public: #ifndef QT_NO_ACCESSIBILITY virtual QPlatformAccessibility *accessibility() const; #endif - virtual QPlatformNativeInterface *nativeInterface() const; virtual QPlatformFontDatabase *fontDatabase() const; virtual QStringList themeNames() const; virtual QPlatformTheme *createPlatformTheme(const QString &name) const; diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp index 5d22ea1a83..75686182cf 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp @@ -75,8 +75,7 @@ bool QWindowsInternalMimeData::hasFormat_sys(const QString &mime) const const QWindowsMimeConverter &mc = QWindowsContext::instance()->mimeConverter(); const bool has = mc.converterToMime(mime, pDataObj) != 0; releaseDataObject(pDataObj); - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << mime << has; + qCDebug(lcQpaMime) << __FUNCTION__ << mime << has; return has; } @@ -89,8 +88,7 @@ QStringList QWindowsInternalMimeData::formats_sys() const const QWindowsMimeConverter &mc = QWindowsContext::instance()->mimeConverter(); const QStringList fmts = mc.allMimesForFormats(pDataObj); releaseDataObject(pDataObj); - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << fmts; + qCDebug(lcQpaMime) << __FUNCTION__ << fmts; return fmts; } @@ -106,12 +104,10 @@ QVariant QWindowsInternalMimeData::retrieveData_sys(const QString &mimeType, if (const QWindowsMime *converter = mc.converterToMime(mimeType, pDataObj)) result = converter->convertToMime(mimeType, pDataObj, type); releaseDataObject(pDataObj); - if (QWindowsContext::verboseOLE) { - QDebug nospace = qDebug().nospace(); - nospace << __FUNCTION__ << ' ' << mimeType << ' ' << type - << " returns " << result.type(); - if (result.type() != QVariant::ByteArray) - nospace << ' ' << result; + if (QWindowsContext::verbose) { + qCDebug(lcQpaMime) <<__FUNCTION__ << ' ' << mimeType << ' ' << type + << " returns " << result.type() + << (result.type() != QVariant::ByteArray ? result.toString() : QStringLiteral("<data>")); } return result; } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 334df17026..0b257cc48f 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -653,16 +653,20 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 ::ToAscii(VK_SPACE, 0, emptyBuffer, reinterpret_cast<LPWORD>(&buffer), 0); ::ToAscii(vk_key, scancode, kbdBuffer, reinterpret_cast<LPWORD>(&buffer), 0); } - - if (QWindowsContext::verboseEvents > 1) { - qDebug("updatePossibleKeyCodes for virtual key = 0x%02x!", vk_key); + if (QWindowsContext::verbose > 1 && lcQpaEvents().isDebugEnabled()) { + QString message; + QDebug debug(&message); + debug <<__FUNCTION__ << " for virtual key = 0x" << hex << vk_key << dec<< '\n'; for (size_t i = 0; i < NumMods; ++i) { - qDebug(" [%d] (%d,0x%02x,'%c') %s", int(i), - keyLayout[vk_key].qtKey[i], - keyLayout[vk_key].qtKey[i], - keyLayout[vk_key].qtKey[i] ? keyLayout[vk_key].qtKey[i] : 0x03, - keyLayout[vk_key].deadkeys & (1<<i) ? "deadkey" : ""); + const quint32 qtKey = keyLayout[vk_key].qtKey[i]; + debug << " [" << i << "] (" << qtKey << ',' + << hex << showbase << qtKey << noshowbase << dec + << ",'" << char(qtKey ? qtKey : 0x03) << "')"; + if (keyLayout[vk_key].deadkeys & (1<<i)) + debug << " deadkey"; + debug << '\n'; } + qCDebug(lcQpaEvents) << message; } } diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index f62b8a6139..3af2cff9a0 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -675,8 +675,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData else ret = str.toUtf8(); } - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << ret; + qCDebug(lcQpaMime) << __FUNCTION__ << ret; return ret; } @@ -1490,8 +1489,7 @@ QStringList QWindowsMimeConverter::allMimesForFormats(IDataObject *pDataObj) con } fmtenum->Release(); } - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << pDataObj << formats; + qCDebug(lcQpaMime) << __FUNCTION__ << pDataObj << formats; return formats; } @@ -1541,9 +1539,8 @@ QVariant QWindowsMimeConverter::convertToMime(const QStringList &mimeTypes, if (converter->canConvertToMime(format, pDataObj)) { const QVariant dataV = converter->convertToMime(format, pDataObj, preferredType); if (dataV.isValid()) { - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << mimeTypes << "\nFormat: " - << format << pDataObj << " returns " << dataV; + qCDebug(lcQpaMime) << __FUNCTION__ << mimeTypes << "\nFormat: " + << format << pDataObj << " returns " << dataV; if (formatIn) *formatIn = format; return dataV; @@ -1551,8 +1548,7 @@ QVariant QWindowsMimeConverter::convertToMime(const QStringList &mimeTypes, } } } - if (QWindowsContext::verboseOLE) - qDebug() << __FUNCTION__ << "fails" << mimeTypes << pDataObj << preferredType; + qCDebug(lcQpaMime) << __FUNCTION__ << "fails" << mimeTypes << pDataObj << preferredType; return QVariant(); } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 3dd8c5a0cd..d8c0a9e426 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -167,8 +167,12 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, if (et == QtWindows::MouseWheelEvent) return translateMouseWheelEvent(window, hwnd, msg, result); + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized; + #ifndef Q_OS_WINCE - static const bool passSynthesizedMouseEvents = QWindowsIntegration::instance()->options() & QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch; + // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. + static const bool passSynthesizedMouseEvents = + !(QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch); if (!passSynthesizedMouseEvents) { // Check for events synthesized from touch. Lower 7 bits are touch/pen index, bit 8 indicates touch. // However, when tablet support is active, extraInfo is a packet serial number. This is not a problem @@ -177,6 +181,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0x80); if (fromTouch) return false; + source = Qt::MouseEventSynthesizedBySystem; } #endif // !Q_OS_WINCE @@ -187,22 +192,21 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, const Qt::MouseButtons buttons = QWindowsMouseHandler::queryMouseButtons(); QWindowSystemInterface::handleFrameStrutMouseEvent(window, clientPosition, globalPosition, buttons, - QWindowsKeyMapper::queryKeyboardModifiers()); + QWindowsKeyMapper::queryKeyboardModifiers(), + source); return false; // Allow further event processing (dragging of windows). } *result = 0; if (msg.message == WM_MOUSELEAVE) { - if (QWindowsContext::verboseEvents) - qDebug() << "WM_MOUSELEAVE for " << window << " previous window under mouse = " << m_windowUnderMouse << " tracked window =" << m_trackedWindow; + qCDebug(lcQpaEvents) << "WM_MOUSELEAVE for " << window << " previous window under mouse = " << m_windowUnderMouse << " tracked window =" << m_trackedWindow; // When moving out of a window, WM_MOUSEMOVE within the moved-to window is received first, // so if m_trackedWindow is not the window here, it means the cursor has left the // application. if (window == m_trackedWindow) { QWindow *leaveTarget = m_windowUnderMouse ? m_windowUnderMouse : m_trackedWindow; - if (QWindowsContext::verboseEvents) - qDebug() << "Generating leave event for " << leaveTarget; + qCDebug(lcQpaEvents) << "Generating leave event for " << leaveTarget; QWindowSystemInterface::handleLeaveEvent(leaveTarget); m_trackedWindow = 0; m_windowUnderMouse = 0; @@ -231,8 +235,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QWindowsWindow::baseWindowOf(window)->applyCursor(); platformWindow->setMouseGrabEnabled(true); platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); - if (QWindowsContext::verboseEvents) - qDebug() << "Automatic mouse capture for missing buttondown event" << window; + qCDebug(lcQpaEvents) << "Automatic mouse capture for missing buttondown event" << window; } m_previousCaptureWindow = window; return true; @@ -257,8 +260,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, || msg.message == WM_RBUTTONDBLCLK || msg.message == WM_XBUTTONDBLCLK)) { platformWindow->setMouseGrabEnabled(true); platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); - if (QWindowsContext::verboseEvents) - qDebug() << "Automatic mouse capture " << window; + qCDebug(lcQpaEvents) << "Automatic mouse capture " << 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(); @@ -268,8 +270,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, || msg.message == WM_RBUTTONUP || msg.message == WM_XBUTTONUP) && !buttons) { platformWindow->setMouseGrabEnabled(false); - if (QWindowsContext::verboseEvents) - qDebug() << "Releasing automatic mouse capture " << window; + qCDebug(lcQpaEvents) << "Releasing automatic mouse capture " << window; } const bool hasCapture = platformWindow->hasMouseCapture(); @@ -301,8 +302,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, && (!hasCapture || window == m_windowUnderMouse)) || (hasCapture && m_previousCaptureWindow != window && m_windowUnderMouse && m_windowUnderMouse != window)) { - if (QWindowsContext::verboseEvents) - qDebug() << "Synthetic leave for " << m_windowUnderMouse; + qCDebug(lcQpaEvents) << "Synthetic leave for " << m_windowUnderMouse; QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse); if (currentNotCapturing) { // Clear tracking if capturing and current window is not the capturing window @@ -321,8 +321,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, && (!hasCapture || currentWindowUnderMouse == window)) || (m_previousCaptureWindow && window != m_previousCaptureWindow && currentWindowUnderMouse && currentWindowUnderMouse != m_previousCaptureWindow)) { - if (QWindowsContext::verboseEvents) - qDebug() << "Entering " << currentWindowUnderMouse; + qCDebug(lcQpaEvents) << "Entering " << currentWindowUnderMouse; QWindowsWindow::baseWindowOf(currentWindowUnderMouse)->applyCursor(); QWindowSystemInterface::handleEnterEvent(currentWindowUnderMouse, currentWindowUnderMouse->mapFromGlobal(globalPosition), @@ -335,7 +334,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, } QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons, - QWindowsKeyMapper::queryKeyboardModifiers()); + QWindowsKeyMapper::queryKeyboardModifiers(), + source); m_previousCaptureWindow = hasCapture ? window : 0; return true; } diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp new file mode 100644 index 0000000000..fb1b63084f --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsnativeinterface.h" +#include "qwindowswindow.h" +#include "qwindowscontext.h" + +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) +# include "qwindowseglcontext.h" +# include <QtGui/QOpenGLContext> +#endif + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) +# include "qwindowsglcontext.h" +#endif + +#if !defined(QT_NO_OPENGL) +# include <QtGui/QOpenGLFunctions> +#endif + +#include <QtGui/QWindow> + +QT_BEGIN_NAMESPACE + +void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) +{ + if (!window || !window->handle()) { + qWarning("%s: '%s' requested for null window or window without handle.", __FUNCTION__, resource.constData()); + return 0; + } + QWindowsWindow *bw = static_cast<QWindowsWindow *>(window->handle()); + if (resource == "handle") + return bw->handle(); + if (window->surfaceType() == QWindow::RasterSurface) { + if (resource == "getDC") + return bw->getDC(); + if (resource == "releaseDC") { + bw->releaseDC(); + return 0; + } + } + qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); + return 0; +} + +static const char customMarginPropertyC[] = "WindowsCustomMargins"; + +QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const +{ + QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window); + if (name == QLatin1String(customMarginPropertyC)) + return qVariantFromValue(platformWindow->customMargins()); + return QVariant(); +} + +QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const +{ + const QVariant result = windowProperty(window, name); + return result.isValid() ? result : defaultValue; +} + +void QWindowsNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) +{ + QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window); + if (name == QLatin1String(customMarginPropertyC)) + platformWindow->setCustomMargins(qvariant_cast<QMargins>(value)); +} + +QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) const +{ + QVariantMap result; + const QString customMarginProperty = QLatin1String(customMarginPropertyC); + result.insert(customMarginProperty, windowProperty(window, customMarginProperty)); + return result; +} + +#ifndef QT_NO_OPENGL +void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) +{ + if (!context || !context->handle()) { + qWarning("%s: '%s' requested for null context or context without handle.", __FUNCTION__, resource.constData()); + return 0; + } +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) + if (QOpenGLFunctions::isES()) { + QWindowsEGLContext *windowsEglContext = static_cast<QWindowsEGLContext *>(context->handle()); + if (resource == QByteArrayLiteral("eglDisplay")) + return windowsEglContext->eglDisplay(); + if (resource == QByteArrayLiteral("eglContext")) + return windowsEglContext->eglContext(); + if (resource == QByteArrayLiteral("eglConfig")) + return windowsEglContext->eglConfig(); + } +#endif // QT_OPENGL_ES_2 || QT_OPENGL_DYNAMIC +#if !defined(QT_OPENGL_ES_2) + if (!QOpenGLFunctions::isES()) { + QWindowsGLContext *windowsContext = static_cast<QWindowsGLContext *>(context->handle()); + if (resource == QByteArrayLiteral("renderingContext")) + return windowsContext->renderingContext(); + } +#endif // QT_OPENGL_ES_2 || QT_OPENGL_DYNAMIC + + qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); + return 0; +} +#endif // !QT_NO_OPENGL + +/*! + \brief Creates a non-visible window handle for filtering messages. +*/ + +void *QWindowsNativeInterface::createMessageWindow(const QString &classNameTemplate, + const QString &windowName, + void *eventProc) const +{ + QWindowsContext *ctx = QWindowsContext::instance(); + const HWND hwnd = ctx->createDummyWindow(classNameTemplate, + (wchar_t*)windowName.utf16(), + (WNDPROC)eventProc); + return hwnd; +} + +/*! + \brief Registers a unique window class with a callback function based on \a classNameIn. +*/ + +QString QWindowsNativeInterface::registerWindowClass(const QString &classNameIn, void *eventProc) const +{ + return QWindowsContext::instance()->registerWindowClass(classNameIn, (WNDPROC)eventProc); +} + +bool QWindowsNativeInterface::asyncExpose() const +{ + return QWindowsContext::instance()->asyncExpose(); +} + +void QWindowsNativeInterface::setAsyncExpose(bool value) +{ + QWindowsContext::instance()->setAsyncExpose(value); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h new file mode 100644 index 0000000000..20100d0f49 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSNATIVEINTERFACE_H +#define QWINDOWSNATIVEINTERFACE_H + +#include "qtwindows_additional.h" +#include <QtGui/qpa/qplatformnativeinterface.h> + +QT_BEGIN_NAMESPACE + +/*! + \class QWindowsNativeInterface + \brief Provides access to native handles. + + Currently implemented keys + \list + \li handle (HWND) + \li getDC (DC) + \li releaseDC Releases the previously acquired DC and returns 0. + \endlist + + \internal + \ingroup qt-lighthouse-win +*/ + +class QWindowsNativeInterface : public QPlatformNativeInterface +{ + Q_OBJECT + Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose) +public: +#ifndef QT_NO_OPENGL + virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); +#endif + virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); + + Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate, + const QString &windowName, + void *eventProc) const; + + Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const; + + Q_INVOKABLE void beep() { MessageBeep(MB_OK); } // For QApplication + + bool asyncExpose() const; + void setAsyncExpose(bool value); + + QVariantMap windowProperties(QPlatformWindow *window) const; + QVariant windowProperty(QPlatformWindow *window, const QString &name) const; + QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; + void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSNATIVEINTERFACE_H diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp index 0cea691f39..4f641d781d 100644 --- a/src/plugins/platforms/windows/qwindowsole.cpp +++ b/src/plugins/platforms/windows/qwindowsole.cpp @@ -80,14 +80,11 @@ QWindowsOleDataObject::QWindowsOleDataObject(QMimeData *mimeData) : CF_PERFORMEDDROPEFFECT(RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT)), performedEffect(DROPEFFECT_NONE) { - if (QWindowsContext::verboseOLE) - qDebug("%s '%s'", __FUNCTION__, qPrintable(mimeData->formats().join(QStringLiteral(", ")))); + qCDebug(lcQpaMime) << __FUNCTION__ << mimeData->formats(); } QWindowsOleDataObject::~QWindowsOleDataObject() { - if (QWindowsContext::verboseOLE) - qDebug("%s", __FUNCTION__); } void QWindowsOleDataObject::releaseQt() @@ -143,10 +140,10 @@ QWindowsOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium) { HRESULT hr = ResultFromScode(DATA_E_FORMATETC); - if (QWindowsContext::verboseOLE) { + if (QWindowsContext::verbose > 1 && lcQpaMime().isDebugEnabled()) { wchar_t buf[256] = {0}; GetClipboardFormatName(pformatetc->cfFormat, buf, 255); - qDebug("%s CF = %d : %s", __FUNCTION__, pformatetc->cfFormat, qPrintable(QString::fromWCharArray(buf))); + qCDebug(lcQpaMime) <<__FUNCTION__ << "CF = " << pformatetc->cfFormat << QString::fromWCharArray(buf); } if (data) { @@ -156,11 +153,10 @@ QWindowsOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium) hr = ResultFromScode(S_OK); } - if (QWindowsContext::verboseOLE) { + if (QWindowsContext::verbose > 1) { wchar_t buf[256] = {0}; GetClipboardFormatName(pformatetc->cfFormat, buf, 255); - qDebug("%s CF = %d : %s returns 0x%x", __FUNCTION__, pformatetc->cfFormat, - qPrintable(QString::fromWCharArray(buf)), int(hr)); + qCDebug(lcQpaMime) <<__FUNCTION__ << "CF = " << pformatetc->cfFormat << " returns 0x" << int(hr) << dec; } return hr; @@ -177,16 +173,16 @@ QWindowsOleDataObject::QueryGetData(LPFORMATETC pformatetc) { HRESULT hr = ResultFromScode(DATA_E_FORMATETC); - if (QWindowsContext::verboseOLE > 1) - qDebug("%s", __FUNCTION__); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__; if (data) { const QWindowsMimeConverter &mc = QWindowsContext::instance()->mimeConverter(); hr = mc.converterFromMime(*pformatetc, data) ? ResultFromScode(S_OK) : ResultFromScode(S_FALSE); } - if (QWindowsContext::verboseOLE > 1) - qDebug("%s returns 0x%x", __FUNCTION__, int(hr)); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__ << " returns 0x" << hex << int(hr); return hr; } @@ -200,8 +196,8 @@ QWindowsOleDataObject::GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC pformatetc STDMETHODIMP QWindowsOleDataObject::SetData(LPFORMATETC pFormatetc, STGMEDIUM *pMedium, BOOL fRelease) { - if (QWindowsContext::verboseOLE > 1) - qDebug("%s", __FUNCTION__); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__; HRESULT hr = ResultFromScode(E_NOTIMPL); @@ -213,8 +209,8 @@ QWindowsOleDataObject::SetData(LPFORMATETC pFormatetc, STGMEDIUM *pMedium, BOOL ReleaseStgMedium(pMedium); hr = ResultFromScode(S_OK); } - if (QWindowsContext::verboseOLE > 1) - qDebug("%s returns 0x%x", __FUNCTION__, int(hr)); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__ << " returns 0x" << hex << int(hr); return hr; } @@ -222,8 +218,8 @@ QWindowsOleDataObject::SetData(LPFORMATETC pFormatetc, STGMEDIUM *pMedium, BOOL STDMETHODIMP QWindowsOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc) { - if (QWindowsContext::verboseOLE > 1) - qDebug("%s", __FUNCTION__); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__; if (!data) return ResultFromScode(DATA_E_FORMATETC); @@ -285,8 +281,8 @@ QWindowsOleDataObject::EnumDAdvise(LPENUMSTATDATA FAR*) QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs) : m_dwRefs(1), m_nIndex(0), m_isNull(false) { - if (QWindowsContext::verboseOLE > 1) - qDebug("%s", __FUNCTION__); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__; m_lpfmtetcs.reserve(fmtetcs.count()); for (int idx = 0; idx < fmtetcs.count(); ++idx) { LPFORMATETC destetc = new FORMATETC(); @@ -303,8 +299,8 @@ QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs) QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs) : m_dwRefs(1), m_nIndex(0), m_isNull(false) { - if (QWindowsContext::verboseOLE > 1) - qDebug("%s", __FUNCTION__); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__; m_lpfmtetcs.reserve(lpfmtetcs.count()); for (int idx = 0; idx < lpfmtetcs.count(); ++idx) { LPFORMATETC srcetc = lpfmtetcs.at(idx); diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 1fc1be53c7..a6e2aabaf0 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -201,8 +201,6 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const { - if (QWindowsContext::verboseIntegration) - qDebug() << __FUNCTION__ << window << x << y << width << height; RECT r; HWND hwnd = window ? (HWND)window : GetDesktopWindow(); GetClientRect(hwnd, &r); @@ -243,8 +241,7 @@ QWindow *QWindowsScreen::findTopLevelAt(const QPoint &point, unsigned flags) if (QPlatformWindow *bw = QWindowsContext::instance()-> findPlatformWindowAt(GetDesktopWindow(), point, flags)) result = QWindowsWindow::topLevelOf(bw->window()); - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << point << flags << result; + qCDebug(lcQpaWindows) <<__FUNCTION__ << point << flags << result; return result; } @@ -254,8 +251,7 @@ QWindow *QWindowsScreen::windowAt(const QPoint &screenPoint, unsigned flags) if (QPlatformWindow *bw = QWindowsContext::instance()-> findPlatformWindowAt(GetDesktopWindow(), screenPoint, flags)) result = bw->window(); - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << screenPoint << " returns " << result; + qCDebug(lcQpaWindows) <<__FUNCTION__ << screenPoint << " returns " << result; return result; } @@ -366,9 +362,8 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam) m_lastDepth = newDepth; m_lastHorizontalResolution = newHorizontalResolution; m_lastVerticalResolution = newVerticalResolution; - if (QWindowsContext::verboseWindows) - qDebug("%s: Depth=%d, resolution=%hux%hu", - __FUNCTION__, newDepth, newHorizontalResolution, newVerticalResolution); + qCDebug(lcQpaWindows) << __FUNCTION__ << "Depth=" << newDepth + << ", resolution " << newHorizontalResolution << 'x' << newVerticalResolution; handleScreenChanges(); } return false; @@ -410,8 +405,7 @@ bool QWindowsScreenManager::handleScreenChanges() QWindowsScreen *newScreen = new QWindowsScreen(newData); m_screens.push_back(newScreen); QWindowsIntegration::instance()->emitScreenAdded(newScreen); - if (QWindowsContext::verboseWindows) - qDebug() << "New Monitor: " << newData; + qCDebug(lcQpaWindows) << "New Monitor: " << newData; } // exists } // for new screens. // Remove deleted ones but keep main monitors if we get only the @@ -419,8 +413,7 @@ bool QWindowsScreenManager::handleScreenChanges() if (!lockScreen) { for (int i = m_screens.size() - 1; i >= 0; --i) { if (indexOfMonitor(newDataList, m_screens.at(i)->data().name) == -1) { - if (QWindowsContext::verboseWindows) - qDebug() << "Removing Monitor: " << m_screens.at(i) ->data(); + qCDebug(lcQpaWindows) << "Removing Monitor: " << m_screens.at(i) ->data(); delete m_screens.takeAt(i); } // not found } // for existing screens diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 1a5c1a2e0c..8b863ec43d 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -182,8 +182,7 @@ QWindowsTabletSupport *QWindowsTabletSupport::create() L"TabletDummyWindow", qWindowsTabletSupportWndProc); if (!window) { - if (QWindowsContext::verboseTablet) - qWarning() << __FUNCTION__ << "Unable to create window for tablet."; + qCWarning(lcQpaTablet) << __FUNCTION__ << "Unable to create window for tablet."; return 0; } LOGCONTEXT lcMine; @@ -199,8 +198,7 @@ QWindowsTabletSupport *QWindowsTabletSupport::create() lcMine.lcOutExtY = -lcMine.lcInExtY; const HCTX context = QWindowsTabletSupport::m_winTab32DLL.wTOpen(window, &lcMine, true); if (!context) { - if (QWindowsContext::verboseTablet) - qWarning() << __FUNCTION__ << "Unable to open tablet."; + qCDebug(lcQpaTablet) << __FUNCTION__ << "Unable to open tablet."; DestroyWindow(window); return 0; @@ -217,9 +215,9 @@ QWindowsTabletSupport *QWindowsTabletSupport::create() } // cannot restore old size } // cannot set } // mismatch - if (QWindowsContext::verboseTablet) - qDebug("Opened tablet context %p on window %p, changed packet queue size %d -> %d", - context, window, currentQueueSize, TabletPacketQSize); + qCDebug(lcQpaTablet) << "Opened tablet context " << context << " on window " + << window << "changed packet queue size " << currentQueueSize + << "->" << TabletPacketQSize; return new QWindowsTabletSupport(window, context); } @@ -261,8 +259,7 @@ void QWindowsTabletSupport::notifyActivate() // Cooperate with other tablet applications, but when we get focus, I want to use the tablet. const bool result = QWindowsTabletSupport::m_winTab32DLL.wTEnable(m_context, true) && QWindowsTabletSupport::m_winTab32DLL.wTOverlap(m_context, true); - if (QWindowsContext::verboseTablet) - qDebug() << __FUNCTION__ << result; + qCDebug(lcQpaTablet) << __FUNCTION__ << result; } static inline int indexOfDevice(const QVector<QWindowsTabletDeviceData> &devices, qint64 uniqueId) @@ -369,10 +366,8 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L m_devices.push_back(tabletInit(uniqueId, cursorType)); } m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor); - if (QWindowsContext::verboseTablet) - qDebug() << __FUNCTION__ << (enteredProximity ? "enter" : "leave") - << " proximity for device #" - << m_currentDevice << m_devices.at(m_currentDevice); + qCDebug(lcQpaTablet) << __FUNCTION__ << (enteredProximity ? "enter" : "leave") + << " proximity for device #" << m_currentDevice << m_devices.at(m_currentDevice); if (enteredProximity) { QWindowSystemInterface::handleTabletEnterProximityEvent(m_devices.at(m_currentDevice).currentDevice, m_devices.at(m_currentDevice).currentPointerType, @@ -410,9 +405,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() enum { absoluteRange = 20 }; const QRect virtualDesktopArea = QGuiApplication::primaryScreen()->virtualGeometry(); - if (QWindowsContext::verboseTablet) - qDebug() << __FUNCTION__ << "processing " << packetCount - << "target:" << QGuiApplicationPrivate::tabletPressTarget; + qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount + << "target:" << QGuiApplicationPrivate::tabletPressTarget; const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); @@ -474,8 +468,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() rotation = packet.pkOrientation.orTwist; } - if (QWindowsContext::verboseTablet > 1) { - qDebug() + if (QWindowsContext::verbose > 1) { + qCDebug(lcQpaTablet) << "Packet #" << i << '/' << packetCount << "button:" << packet.pkButtons << globalPosF << z << "to:" << target << localPos << "(packet" << packet.pkX << packet.pkY << ") dev:" << currentDevice << "pointer:" diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 00a5da8f44..6349c1e355 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -354,7 +354,7 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const case UseFullScreenForPopupMenu: return QVariant(true); case DialogButtonBoxLayout: - return QVariant(int(0)); // QDialogButtonBox::WinLayout + return QVariant(QPlatformDialogHelper::WinLayout); case IconThemeSearchPaths: return QVariant(iconThemeSearchPaths()); case StyleNames: @@ -406,10 +406,6 @@ void QWindowsTheme::refreshPalettes() m_palettes[ToolTipPalette] = new QPalette(toolTipPalette(*m_palettes[SystemPalette])); m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette])); m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette]); - if (QWindowsContext::verboseTheming) - qDebug() << __FUNCTION__ << '\n' - << " system=" << paletteToString(*m_palettes[SystemPalette]) - << " tooltip=" << paletteToString(*m_palettes[ToolTipPalette]); } void QWindowsTheme::clearFonts() @@ -449,11 +445,6 @@ void QWindowsTheme::refreshFonts() m_fonts[DockWidgetTitleFont] = new QFont(titleFont); m_fonts[ItemViewFont] = new QFont(iconTitleFont); m_fonts[FixedFont] = new QFont(fixedFont); - - if (QWindowsContext::verboseTheming) - qDebug() << __FUNCTION__ << '\n' - << " menuFont=" << menuFont - << " messageBox=" << MessageBoxFont; #endif // !Q_OS_WINCE } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 51902385e1..a0a9e75e2d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -48,8 +48,9 @@ # include "qwindowscursor.h" #endif -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) # include "qwindowseglcontext.h" +# include <QtGui/QOpenGLFunctions> #endif #include <QtGui/QGuiApplication> @@ -358,7 +359,7 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bo struct WindowCreationData { - typedef QWindowsWindow::WindowData WindowData; + typedef QWindowsWindowData WindowData; enum Flags { ForceChild = 0x1, ForceTopLevel = 0x2 }; WindowCreationData() : parentHandle(0), type(Qt::Widget), style(0), exStyle(0), @@ -534,7 +535,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag } } -QWindowsWindow::WindowData +QWindowsWindowData WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const { typedef QSharedPointer<QWindowCreationContext> QWindowCreationContextPtr; @@ -546,8 +547,7 @@ QWindowsWindow::WindowData result.hwnd = GetDesktopWindow(); result.geometry = frameGeometry(result.hwnd, true); result.embedded = false; - if (QWindowsContext::verboseWindows) - qDebug().nospace() << "Created desktop window " << w << result.hwnd; + qCDebug(lcQpaWindows) << "Created desktop window " << w << result.hwnd; return result; } if ((flags & Qt::WindowType_Mask) == Qt::ForeignWindow) { @@ -558,8 +558,7 @@ QWindowsWindow::WindowData result.geometry = frameGeometry(result.hwnd, !GetParent(result.hwnd)); result.frame = QWindowsGeometryHint::frame(style, exStyle); result.embedded = false; - if (QWindowsContext::verboseWindows) - qDebug() << "Foreign window: " << w << result.hwnd << result.geometry << result.frame; + qCDebug(lcQpaWindows) << "Foreign window: " << w << result.hwnd << result.geometry << result.frame; return result; } @@ -580,24 +579,21 @@ QWindowsWindow::WindowData const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); - if (QWindowsContext::verboseWindows) - qDebug().nospace() - << "CreateWindowEx: " << w << *this - << " class=" <<windowClassName << " title=" << title - << "\nrequested: " << rect << ": " - << context->frameWidth << 'x' << context->frameHeight - << '+' << context->frameX << '+' << context->frameY - << " custom margins: " << context->customMargins; + qCDebug(lcQpaWindows).nospace() + << "CreateWindowEx: " << w << *this << " class=" <<windowClassName << " title=" << title + << "\nrequested: " << rect << ": " + << context->frameWidth << 'x' << context->frameHeight + << '+' << context->frameX << '+' << context->frameY + << " custom margins: " << context->customMargins; result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16, style, context->frameX, context->frameY, context->frameWidth, context->frameHeight, parentHandle, NULL, appinst, NULL); - if (QWindowsContext::verboseWindows) - qDebug().nospace() - << "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: " - << context->obtainedGeometry << context->margins; + qCDebug(lcQpaWindows).nospace() + << "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: " + << context->obtainedGeometry << context->margins; if (!result.hwnd) { qErrnoWarning("%s: CreateWindowEx failed", __FUNCTION__); @@ -627,8 +623,7 @@ void WindowCreationData::applyWindowFlags(HWND hwnd) const const LONG_PTR newExStyle = exStyle; if (newExStyle != oldExStyle) SetWindowLongPtr(hwnd, GWL_EXSTYLE, newExStyle); - if (QWindowsContext::verboseWindows) - qDebug().nospace() << __FUNCTION__ << hwnd << *this + qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << hwnd << *this << "\n Style from " << debugWinStyle(oldStyle) << "\n to " << debugWinStyle(newStyle) << "\n ExStyle from " << debugWinExStyle(oldExStyle) << " to " @@ -705,10 +700,8 @@ QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle) qErrnoWarning("%s: AdjustWindowRectEx failed", __FUNCTION__); const QMargins result(qAbs(rect.left), qAbs(rect.top), qAbs(rect.right), qAbs(rect.bottom)); - if (QWindowsContext::verboseWindows) - qDebug().nospace() << __FUNCTION__ << " style= 0x" - << QString::number(style, 16) - << " exStyle=0x" << QString::number(exStyle, 16) << ' ' << rect << ' ' << result; + qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << " style= 0x" + << QString::number(style, 16) << " exStyle=0x" << QString::number(exStyle, 16) << ' ' << rect << ' ' << result; return result; } @@ -727,10 +720,9 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co ncp->rgrc[0].right -= customMargins.right(); ncp->rgrc[0].bottom -= customMargins.bottom(); result = 0; - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << oldClientArea << '+' << customMargins << "-->" - << ncp->rgrc[0] << ' ' << ncp->rgrc[1] << ' ' << ncp->rgrc[2] - << ' ' << ncp->lppos->cx << ',' << ncp->lppos->cy; + qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << oldClientArea << '+' << customMargins << "-->" + << ncp->rgrc[0] << ' ' << ncp->rgrc[1] << ' ' << ncp->rgrc[2] + << ' ' << ncp->lppos->cx << ',' << ncp->lppos->cy; return true; #else Q_UNUSED(customMargins) @@ -749,11 +741,10 @@ void QWindowsGeometryHint::applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const void QWindowsGeometryHint::applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXINFO *mmi) const { - if (QWindowsContext::verboseWindows) - qDebug().nospace() << '>' << __FUNCTION__ << '<' << " min=" - << minimumSize.width() << ',' << minimumSize.height() - << " max=" << maximumSize.width() << ',' << maximumSize.height() - << " in " << *mmi; + qCDebug(lcQpaWindows).nospace() << '>' << __FUNCTION__ << '<' << " min=" + << minimumSize.width() << ',' << minimumSize.height() + << " max=" << maximumSize.width() << ',' << maximumSize.height() + << " in " << *mmi; const QMargins margins = QWindowsGeometryHint::frame(style, exStyle); const int frameWidth = margins.left() + margins.right() + customMargins.left() + customMargins.right(); @@ -770,10 +761,9 @@ void QWindowsGeometryHint::applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXI // windows with title bar have an implicit size limit of 112 pixels if (maximumHeight < QWINDOWSIZE_MAX) mmi->ptMaxTrackSize.y = qMax(maximumHeight + frameHeight, 112); - if (QWindowsContext::verboseWindows) - qDebug().nospace() << '<' << __FUNCTION__ - << " frame=" << margins << ' ' << frameWidth << ',' << frameHeight - << " out " << *mmi; + qCDebug(lcQpaWindows).nospace() << '<' << __FUNCTION__ + << " frame=" << margins << ' ' << frameWidth << ',' << frameHeight + << " out " << *mmi; } #endif // !Q_OS_WINCE @@ -831,15 +821,13 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, } } - if (QWindowsContext::verboseWindows) - qDebug().nospace() - << __FUNCTION__ << ' ' << w << geometry - << " pos incl. frame" << QWindowsGeometryHint::positionIncludesFrame(w) - << " frame: " << frameWidth << 'x' << frameHeight << '+' - << frameX << '+' << frameY - << " min" << geometryHint.minimumSize - << " max" << geometryHint.maximumSize - << " custom margins " << customMargins; + qCDebug(lcQpaWindows).nospace() + << __FUNCTION__ << ' ' << w << geometry + << " pos incl. frame" << QWindowsGeometryHint::positionIncludesFrame(w) + << " frame: " << frameWidth << 'x' << frameHeight << '+' + << frameX << '+' << frameY + << " min" << geometryHint.minimumSize << " max" << geometryHint.maximumSize + << " custom margins " << customMargins; } /*! @@ -864,7 +852,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, \ingroup qt-lighthouse-win */ -QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : +QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) : QPlatformWindow(aWindow), m_data(data), m_flags(WithinCreate), @@ -874,7 +862,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : m_dropTarget(0), m_savedStyle(0), m_format(aWindow->format()), -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) m_eglSurface(0), #endif #ifdef Q_OS_WINCE @@ -891,24 +879,13 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : return; // No further handling for Qt::Desktop if (aWindow->surfaceType() == QWindow::OpenGLSurface) { setFlag(OpenGLSurface); -#ifdef QT_OPENGL_ES_2 - setFlag(OpenGL_ES2); +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) + if (QOpenGLFunctions::isES()) + setFlag(OpenGL_ES2); #endif } - if (aWindow->isTopLevel()) { - switch (type) { - case Qt::Window: - case Qt::Dialog: - case Qt::Sheet: - case Qt::Drawer: - case Qt::Popup: - case Qt::Tool: - registerDropSite(); - break; - default: - break; - } - } + updateDropSite(); + #ifndef Q_OS_WINCE if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch) { if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0)) { @@ -949,8 +926,7 @@ void QWindowsWindow::fireExpose(const QRegion ®ion, bool force) void QWindowsWindow::destroyWindow() { - if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() << m_data.hwnd; + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << m_data.hwnd; if (m_data.hwnd) { // Stop event dispatching before Window is destroyed. setFlag(WithinDestroy); QWindowsContext *context = QWindowsContext::instance(); @@ -958,12 +934,10 @@ void QWindowsWindow::destroyWindow() context->clearWindowUnderMouse(); if (hasMouseCapture()) setMouseGrabEnabled(false); - unregisterDropSite(); -#ifdef QT_OPENGL_ES_2 + setDropSiteEnabled(false); +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) if (m_eglSurface) { - if (QWindowsContext::verboseGL) - qDebug("%s: Freeing EGL surface %p, this = %p", - __FUNCTION__, m_eglSurface, this); + qCDebug(lcQpaGl) << __FUNCTION__ << "Freeing EGL surface " << m_eglSurface << window(); eglDestroySurface(m_staticEglContext->display(), m_eglSurface); m_eglSurface = 0; } @@ -983,31 +957,44 @@ void QWindowsWindow::destroyWindow() } } -void QWindowsWindow::registerDropSite() +void QWindowsWindow::updateDropSite() { -#ifndef QT_NO_CLIPBOARD -# ifndef QT_NO_DRAGANDDROP - if (m_data.hwnd && !m_dropTarget) { - m_dropTarget = new QWindowsOleDropTarget(window()); - RegisterDragDrop(m_data.hwnd, m_dropTarget); - CoLockObjectExternal(m_dropTarget, true, true); + bool enabled = false; + if (window()->isTopLevel()) { + switch (window()->type()) { + case Qt::Window: + case Qt::Dialog: + case Qt::Sheet: + case Qt::Drawer: + case Qt::Popup: + case Qt::Tool: + enabled = true; + break; + default: + break; + } } -# endif // !QT_NO_DRAGANDDROP -#endif // !QT_NO_CLIPBOARD + setDropSiteEnabled(enabled); } -void QWindowsWindow::unregisterDropSite() +void QWindowsWindow::setDropSiteEnabled(bool dropEnabled) { -#ifndef QT_NO_CLIPBOARD -# ifndef QT_NO_DRAGANDDROP - if (m_data.hwnd && m_dropTarget) { + if (isDropSiteEnabled() == dropEnabled) + return; + qCDebug(lcQpaMime) << __FUNCTION__ << window() << dropEnabled; +#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_DRAGANDDROP) + if (dropEnabled) { + Q_ASSERT(m_data.hwnd); + m_dropTarget = new QWindowsOleDropTarget(window()); + RegisterDragDrop(m_data.hwnd, m_dropTarget); + CoLockObjectExternal(m_dropTarget, true, true); + } else { m_dropTarget->Release(); CoLockObjectExternal(m_dropTarget, false, true); RevokeDragDrop(m_data.hwnd); m_dropTarget = 0; } -# endif // !QT_NO_DRAGANDDROP -#endif // !QT_NO_CLIPBOARD +#endif // !QT_NO_CLIPBOARD && !QT_NO_DRAGANDDROP } // Returns topmost QWindowsWindow ancestor even if there are embedded windows in the chain. @@ -1033,14 +1020,14 @@ QWindow *QWindowsWindow::topLevelOf(QWindow *w) return w; } -QWindowsWindow::WindowData - QWindowsWindow::WindowData::create(const QWindow *w, - const WindowData ¶meters, +QWindowsWindowData + QWindowsWindowData::create(const QWindow *w, + const QWindowsWindowData ¶meters, const QString &title) { WindowCreationData creationData; creationData.fromWindow(w, parameters.flags); - WindowData result = creationData.create(w, parameters, title); + QWindowsWindowData result = creationData.create(w, parameters, title); // Force WM_NCCALCSIZE (with wParam=1) via SWP_FRAMECHANGED for custom margin. creationData.initialize(result.hwnd, !parameters.customMargins.isNull(), 1); return result; @@ -1048,8 +1035,7 @@ QWindowsWindow::WindowData void QWindowsWindow::setVisible(bool visible) { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() << m_data.hwnd << visible; + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << m_data.hwnd << visible; if (m_data.hwnd) { if (visible) { show_sys(); @@ -1193,20 +1179,19 @@ void QWindowsWindow::hide_sys() const if (flags & Qt::Popup) ShowWindow(m_data.hwnd, SW_HIDE); else - SetWindowPos(m_data.hwnd,0, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER); + SetWindowPos(m_data.hwnd,0, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); } } void QWindowsWindow::setParent(const QPlatformWindow *newParent) { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << window() << newParent; + qCDebug(lcQpaWindows) << __FUNCTION__ << window() << newParent; if (m_data.hwnd) setParent_sys(newParent); } -void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const +void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) { // Use GetAncestor instead of GetParent, as GetParent can return owner window for toplevels HWND oldParentHWND = GetAncestor(m_data.hwnd, GA_PARENT); @@ -1235,8 +1220,11 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const // WS_CHILD/WS_POPUP must be manually set/cleared in addition // to dialog frames, etc (see SetParent() ) if the top level state changes. // Force toplevel state as QWindow::isTopLevel cannot be relied upon here. - if (wasTopLevel != isTopLevel) + if (wasTopLevel != isTopLevel) { + setDropSiteEnabled(false); setWindowFlags_sys(window()->flags(), unsigned(isTopLevel ? WindowCreationData::ForceTopLevel : WindowCreationData::ForceChild)); + updateDropSite(); + } } } @@ -1252,6 +1240,28 @@ void QWindowsWindow::handleCompositionSettingsChanged() applyBlurBehindWindow(handle()); } +static QRect normalFrameGeometry(HWND hwnd) +{ +#ifndef Q_OS_WINCE + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + if (GetWindowPlacement(hwnd, &wp)) + return qrectFromRECT(wp.rcNormalPosition); +#else + Q_UNUSED(hwnd) +#endif + return QRect(); +} + +QRect QWindowsWindow::normalGeometry() const +{ + // Check for fake 'fullscreen' mode. + const bool fakeFullScreen = m_savedFrameGeometry.isValid() && window()->windowState() == Qt::WindowFullScreen; + const QRect frame = fakeFullScreen ? m_savedFrameGeometry : normalFrameGeometry(m_data.hwnd); + const QMargins margins = fakeFullScreen ? QWindowsGeometryHint::frame(m_savedStyle, 0) : frameMargins(); + return frame.isValid() ? frame.marginsRemoved(margins) : frame; +} + void QWindowsWindow::setGeometry(const QRect &rectIn) { QRect rect = rectIn; @@ -1350,8 +1360,7 @@ void QWindowsWindow::handleGeometryChange() if (testFlag(SynchronousGeometryChangeEvent)) QWindowSystemInterface::flushWindowSystemEvents(); - if (QWindowsContext::verboseEvents || QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() << m_data.geometry; + qCDebug(lcQpaEvents) << __FUNCTION__ << this << window() << m_data.geometry; } void QWindowsWindow::setGeometry_sys(const QRect &rect) const @@ -1359,17 +1368,15 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const const QMargins margins = frameMargins(); const QRect frameGeometry = rect + margins; - if (QWindowsContext::verboseWindows) - qDebug() << '>' << __FUNCTION__ << this << window() + qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << this << window() << " \n from " << geometry_sys() << " frame: " << margins << " to " <<rect << " new frame: " << frameGeometry; const bool rc = MoveWindow(m_data.hwnd, frameGeometry.x(), frameGeometry.y(), frameGeometry.width(), frameGeometry.height(), true); - if (QWindowsContext::verboseWindows) - qDebug() << '<' << __FUNCTION__ << this << window() - << " \n resulting " << rc << geometry_sys(); + qCDebug(lcQpaWindows) << '<' << __FUNCTION__ << this << window() + << " \n resulting " << rc << geometry_sys(); } QRect QWindowsWindow::frameGeometry_sys() const @@ -1442,8 +1449,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, void QWindowsWindow::setWindowTitle(const QString &title) { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() <<title; + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() <<title; if (m_data.hwnd) { const QString fullTitle = formatWindowTitle(title, QStringLiteral(" - ")); SetWindowText(m_data.hwnd, (const wchar_t*)fullTitle.utf16()); @@ -1452,15 +1458,16 @@ void QWindowsWindow::setWindowTitle(const QString &title) void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags) { - if (QWindowsContext::verboseWindows) - qDebug() << '>' << __FUNCTION__ << this << window() << "\n from: " - << QWindowsWindow::debugWindowFlags(m_data.flags) - << "\n to: " << QWindowsWindow::debugWindowFlags(flags); + qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << this << window() << "\n from: " + << QWindowsWindow::debugWindowFlags(m_data.flags) + << "\n to: " << QWindowsWindow::debugWindowFlags(flags); const QRect oldGeometry = geometry(); if (m_data.flags != flags) { m_data.flags = flags; - if (m_data.hwnd) + if (m_data.hwnd) { m_data = setWindowFlags_sys(flags); + updateDropSite(); + } } // When switching to a frameless window, geometry // may change without a WM_MOVE. Report change manually. @@ -1470,13 +1477,12 @@ void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags) if (oldGeometry != newGeometry) handleGeometryChange(); - if (QWindowsContext::verboseWindows) - qDebug() << '<' << __FUNCTION__ << "\n returns: " - << QWindowsWindow::debugWindowFlags(m_data.flags) - << " geometry " << oldGeometry << "->" << newGeometry; + qCDebug(lcQpaWindows) << '<' << __FUNCTION__ << "\n returns: " + << QWindowsWindow::debugWindowFlags(m_data.flags) + << " geometry " << oldGeometry << "->" << newGeometry; } -QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt, +QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt, unsigned flags) const { WindowCreationData creationData; @@ -1484,7 +1490,7 @@ QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt creationData.applyWindowFlags(m_data.hwnd); creationData.initialize(m_data.hwnd, true, m_opacity); - WindowData result = m_data; + QWindowsWindowData result = m_data; result.flags = creationData.flags; result.embedded = creationData.embedded; setFlag(FrameDirty); @@ -1493,8 +1499,7 @@ QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << "\n from " << debugWindowStates(m_windowState) << " to " << debugWindowStates(state); setFlag(FrameDirty); @@ -1577,10 +1582,8 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) const Qt::WindowState oldState = m_windowState; if (oldState == newState) return; - if (QWindowsContext::verboseWindows) - qDebug() << '>' << __FUNCTION__ << this << window() - << " from " << debugWindowStates(oldState) - << " to " << debugWindowStates(newState); + qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << this << window() + << " from " << debugWindowStates(oldState) << " to " << debugWindowStates(newState); const bool visible = isVisible(); @@ -1620,10 +1623,9 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) m_savedStyle = style(); #ifndef Q_OS_WINCE if (oldState == Qt::WindowMinimized) { - WINDOWPLACEMENT wp; - wp.length = sizeof(WINDOWPLACEMENT); - if (GetWindowPlacement(m_data.hwnd, &wp)) - m_savedFrameGeometry = qrectFromRECT(wp.rcNormalPosition); + const QRect nf = normalFrameGeometry(m_data.hwnd); + if (nf.isValid()) + m_savedFrameGeometry = nf; } else { #endif m_savedFrameGeometry = frameGeometry_sys(); @@ -1677,15 +1679,12 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) ShowWindow(m_data.hwnd, (newState == Qt::WindowMinimized) ? SW_MINIMIZE : (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE); } - if (QWindowsContext::verboseWindows) - qDebug() << '<' << __FUNCTION__ << this << window() - << debugWindowStates(newState); + qCDebug(lcQpaWindows) << '<' << __FUNCTION__ << this << window() << debugWindowStates(newState); } void QWindowsWindow::setStyle(unsigned s) const { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() << debugWinStyle(s); + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << debugWinStyle(s); setFlag(WithinSetStyle); setFlag(FrameDirty); SetWindowLongPtr(m_data.hwnd, GWL_STYLE, s); @@ -1694,8 +1693,7 @@ void QWindowsWindow::setStyle(unsigned s) const void QWindowsWindow::setExStyle(unsigned s) const { - if (QWindowsContext::verboseWindows) - qDebug().nospace() << __FUNCTION__ << ' ' << this << ' ' << window() + qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << this << ' ' << window() << " 0x" << QByteArray::number(s, 16); setFlag(FrameDirty); SetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE, s); @@ -1703,15 +1701,13 @@ void QWindowsWindow::setExStyle(unsigned s) const void QWindowsWindow::raise() { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window(); + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); SetWindowPos(m_data.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } void QWindowsWindow::lower() { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window(); + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); if (m_data.hwnd) SetWindowPos(m_data.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } @@ -1734,8 +1730,7 @@ void QWindowsWindow::windowEvent(QEvent *event) void QWindowsWindow::propagateSizeHints() { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window(); + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); } QMargins QWindowsWindow::frameMargins() const @@ -1753,8 +1748,7 @@ QMargins QWindowsWindow::frameMargins() const void QWindowsWindow::setOpacity(qreal level) { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << level; + qCDebug(lcQpaWindows) << __FUNCTION__ << level; if (m_opacity != level) { m_opacity = level; if (m_data.hwnd) @@ -1816,8 +1810,7 @@ void QWindowsWindow::setMask(const QRegion ®ion) void QWindowsWindow::requestActivateWindow() { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window(); + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); // 'Active' state handling is based in focus since it needs to work for // child windows as well. if (m_data.hwnd) { @@ -1832,8 +1825,7 @@ bool QWindowsWindow::setKeyboardGrabEnabled(bool grab) qWarning("%s: No handle", __FUNCTION__); return false; } - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << this << window() << grab; + qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << grab; QWindowsContext *context = QWindowsContext::instance(); if (grab) { @@ -1847,8 +1839,7 @@ bool QWindowsWindow::setKeyboardGrabEnabled(bool grab) bool QWindowsWindow::setMouseGrabEnabled(bool grab) { - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << window() << grab; + qCDebug(lcQpaWindows) << __FUNCTION__ << window() << grab; if (!m_data.hwnd) { qWarning("%s: No handle", __FUNCTION__); return false; @@ -1930,8 +1921,7 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const } } - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << window() << *mmi; + qCDebug(lcQpaWindows) << __FUNCTION__ << window() << *mmi; } bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *result) const @@ -2031,9 +2021,8 @@ void QWindowsWindow::setCursor(const QWindowsWindowCursor &c) #ifndef QT_NO_CURSOR if (c.handle() != m_cursor.handle()) { const bool apply = applyNewCursor(window()); - if (QWindowsContext::verboseWindows) - qDebug() << window() << __FUNCTION__ << "Shape=" << c.cursor().shape() - << " doApply=" << apply; + qCDebug(lcQpaWindows) <<window() << __FUNCTION__ + << "Shape=" << c.cursor().shape() << " doApply=" << apply; m_cursor = c; if (apply) applyCursor(); @@ -2120,7 +2109,7 @@ void QWindowsWindow::setEnabled(bool enabled) setStyle(newStyle); } -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) EGLSurface QWindowsWindow::ensureEglSurfaceHandle(const QWindowsWindow::QWindowsEGLStaticContextPtr &staticContext, EGLConfig config) { if (!m_eglSurface) { @@ -2131,9 +2120,7 @@ EGLSurface QWindowsWindow::ensureEglSurfaceHandle(const QWindowsWindow::QWindows Q_FUNC_INFO, window()->metaObject()->className(), qPrintable(window()->objectName()), eglGetError()); - if (QWindowsContext::verboseGL) - qDebug("%s: Created EGL surface %p, this = %p", - __FUNCTION__, m_eglSurface, this); + qCDebug(lcQpaGl) << __FUNCTION__<<"Created EGL surface "<< m_eglSurface <<window(); } return m_eglSurface; } @@ -2244,9 +2231,8 @@ void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins) QRect newFrame = currentFrameGeometry.marginsRemoved(oldCustomMargins) + m_data.customMargins; newFrame.moveTo(topLeft); setFlag(FrameDirty); - if (QWindowsContext::verboseWindows) - qDebug() << __FUNCTION__ << oldCustomMargins << "->" << newCustomMargins - << currentFrameGeometry << "->" << newFrame; + qCDebug(lcQpaWindows) << __FUNCTION__ << oldCustomMargins << "->" << newCustomMargins + << currentFrameGeometry << "->" << newFrame; SetWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED); } } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 61dc3e2dc2..ba0f22bb0a 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -50,7 +50,7 @@ #include <qpa/qplatformwindow.h> -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) # include <QtCore/QSharedPointer> # include <EGL/egl.h> #endif @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QWindowsOleDropTarget; class QDebug; -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) class QWindowsEGLStaticContext; #endif @@ -111,10 +111,26 @@ struct QWindowCreationContext int frameHeight; }; +struct QWindowsWindowData +{ + QWindowsWindowData() : hwnd(0), embedded(false) {} + + Qt::WindowFlags flags; + QRect geometry; + QMargins frame; // Do not use directly for windows, see FrameDirty. + QMargins customMargins; // User-defined, additional frame for NCCALCSIZE + HWND hwnd; + bool embedded; + + static QWindowsWindowData create(const QWindow *w, + const QWindowsWindowData ¶meters, + const QString &title); +}; + class QWindowsWindow : public QPlatformWindow { public: -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) typedef QSharedPointer<QWindowsEGLStaticContext> QWindowsEGLStaticContextPtr; #endif @@ -140,28 +156,13 @@ public: WithinMaximize = 0x40000 }; - struct WindowData - { - WindowData() : hwnd(0) {} - - Qt::WindowFlags flags; - QRect geometry; - QMargins frame; // Do not use directly for windows, see FrameDirty. - QMargins customMargins; // User-defined, additional frame for NCCALCSIZE - HWND hwnd; - bool embedded; - - static WindowData create(const QWindow *w, - const WindowData ¶meters, - const QString &title); - }; - - QWindowsWindow(QWindow *window, const WindowData &data); + QWindowsWindow(QWindow *window, const QWindowsWindowData &data); ~QWindowsWindow(); virtual QSurfaceFormat format() const { return m_format; } virtual void setGeometry(const QRect &rect); virtual QRect geometry() const { return m_data.geometry; } + QRect normalGeometry() const Q_DECL_OVERRIDE; virtual void setVisible(bool visible); bool isVisible() const; @@ -205,7 +206,7 @@ public: QMargins customMargins() const { return m_data.customMargins; } void setCustomMargins(const QMargins &m); -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) EGLSurface eglSurfaceHandle() const { return m_eglSurface;} EGLSurface ensureEglSurfaceHandle(const QWindowsEGLStaticContextPtr &staticContext, EGLConfig config); #endif @@ -274,20 +275,21 @@ private: inline void setGeometry_sys(const QRect &rect) const; inline QRect frameGeometry_sys() const; inline QRect geometry_sys() const; - inline WindowData setWindowFlags_sys(Qt::WindowFlags wt, unsigned flags = 0) const; + inline QWindowsWindowData setWindowFlags_sys(Qt::WindowFlags wt, unsigned flags = 0) const; inline bool isFullScreen_sys() const; inline void setWindowState_sys(Qt::WindowState newState); - inline void setParent_sys(const QPlatformWindow *parent) const; + inline void setParent_sys(const QPlatformWindow *parent); inline void updateTransientParent() const; void destroyWindow(); - void registerDropSite(); - void unregisterDropSite(); + inline bool isDropSiteEnabled() const { return m_dropTarget != 0; } + void setDropSiteEnabled(bool enabled); + void updateDropSite(); void handleGeometryChange(); void handleWindowStateChange(Qt::WindowState state); inline void destroyIcon(); void fireExpose(const QRegion ®ion, bool force=false); - mutable WindowData m_data; + mutable QWindowsWindowData m_data; mutable unsigned m_flags; HDC m_hdc; Qt::WindowState m_windowState; @@ -299,7 +301,7 @@ private: unsigned m_savedStyle; QRect m_savedFrameGeometry; const QSurfaceFormat m_format; -#ifdef QT_OPENGL_ES_2 +#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC) EGLSurface m_eglSurface; QSharedPointer<QWindowsEGLStaticContext> m_staticEglContext; #endif diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri new file mode 100644 index 0000000000..13799ba1ba --- /dev/null +++ b/src/plugins/platforms/windows/windows.pri @@ -0,0 +1,184 @@ +# Note: OpenGL32 must precede Gdi32 as it overwrites some functions. +LIBS *= -lole32 +!wince*:LIBS *= -luser32 -lwinspool -limm32 -lwinmm -loleaut32 + +contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):!contains(QT_CONFIG, dynamicgl): LIBS *= -lopengl32 + +mingw: LIBS *= -luuid +# For the dialog helpers: +!wince*:LIBS *= -lshlwapi -lshell32 +!wince*:LIBS *= -ladvapi32 +wince*:DEFINES *= QT_LIBINFIX=L"\"\\\"$${QT_LIBINFIX}\\\"\"" + +DEFINES *= QT_NO_CAST_FROM_ASCII + +contains(QT_CONFIG, directwrite) { + LIBS *= -ldwrite + SOURCES += $$PWD/qwindowsfontenginedirectwrite.cpp + HEADERS += $$PWD/qwindowsfontenginedirectwrite.h +} else { + DEFINES *= QT_NO_DIRECTWRITE +} + +SOURCES += \ + $$PWD/qwindowswindow.cpp \ + $$PWD/qwindowsintegration.cpp \ + $$PWD/qwindowscontext.cpp \ + $$PWD/qwindowsscreen.cpp \ + $$PWD/qwindowskeymapper.cpp \ + $$PWD/qwindowsfontengine.cpp \ + $$PWD/qwindowsfontdatabase.cpp \ + $$PWD/qwindowsmousehandler.cpp \ + $$PWD/qwindowsguieventdispatcher.cpp \ + $$PWD/qwindowsole.cpp \ + $$PWD/qwindowsmime.cpp \ + $$PWD/qwindowsinternalmimedata.cpp \ + $$PWD/qwindowscursor.cpp \ + $$PWD/qwindowsinputcontext.cpp \ + $$PWD/qwindowstheme.cpp \ + $$PWD/qwindowsdialoghelpers.cpp \ + $$PWD/qwindowsservices.cpp \ + $$PWD/qwindowsnativeimage.cpp \ + $$PWD/qwindowsnativeinterface.cpp + +HEADERS += \ + $$PWD/qwindowswindow.h \ + $$PWD/qwindowsintegration.h \ + $$PWD/qwindowscontext.h \ + $$PWD/qwindowsscreen.h \ + $$PWD/qwindowskeymapper.h \ + $$PWD/qwindowsfontengine.h \ + $$PWD/qwindowsfontdatabase.h \ + $$PWD/qwindowsmousehandler.h \ + $$PWD/qwindowsguieventdispatcher.h \ + $$PWD/qtwindowsglobal.h \ + $$PWD/qtwindows_additional.h \ + $$PWD/qwindowsole.h \ + $$PWD/qwindowsmime.h \ + $$PWD/qwindowsinternalmimedata.h \ + $$PWD/qwindowscursor.h \ + $$PWD/array.h \ + $$PWD/qwindowsinputcontext.h \ + $$PWD/qwindowstheme.h \ + $$PWD/qwindowsdialoghelpers.h \ + $$PWD/qwindowsservices.h \ + $$PWD/qplatformfunctions_wince.h \ + $$PWD/qwindowsnativeimage.h \ + $$PWD/qwindowsnativeinterface.h + +INCLUDEPATH += $$PWD + +contains(QT_CONFIG, opengles2) { + SOURCES += $$PWD/qwindowseglcontext.cpp + HEADERS += $$PWD/qwindowseglcontext.h +} else: contains(QT_CONFIG,opengl) { + SOURCES += $$PWD/qwindowsglcontext.cpp + HEADERS += $$PWD/qwindowsglcontext.h +} + +# Dynamic GL needs both WGL and EGL +contains(QT_CONFIG,dynamicgl) { + SOURCES += $$PWD/qwindowseglcontext.cpp + HEADERS += $$PWD/qwindowseglcontext.h +} + +!contains( DEFINES, QT_NO_CLIPBOARD ) { + SOURCES += $$PWD/qwindowsclipboard.cpp + HEADERS += $$PWD/qwindowsclipboard.h +} + +# drag and drop on windows only works if a clipboard is available +!contains( DEFINES, QT_NO_DRAGANDDROP ) { + !win32:SOURCES += $$PWD/qwindowsdrag.cpp + !win32:HEADERS += $$PWD/qwindowsdrag.h + win32:!contains( DEFINES, QT_NO_CLIPBOARD ) { + HEADERS += $$PWD/qwindowsdrag.h + SOURCES += $$PWD/qwindowsdrag.cpp + } +} + +!wince*:!contains( DEFINES, QT_NO_TABLETEVENT ) { + INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/wintab + HEADERS += $$PWD/qwindowstabletsupport.h + SOURCES += $$PWD/qwindowstabletsupport.cpp +} + +!wince*:!contains( DEFINES, QT_NO_SESSIONMANAGER ) { + SOURCES += $$PWD/qwindowssessionmanager.cpp + HEADERS += $$PWD/qwindowssessionmanager.h +} + +contains(QT_CONFIG, freetype) { + DEFINES *= QT_NO_FONTCONFIG + QT_FREETYPE_DIR = $$QT_SOURCE_TREE/src/3rdparty/freetype + + HEADERS += \ + $$PWD/qwindowsfontdatabase_ft.h + SOURCES += \ + $$PWD/qwindowsfontdatabase_ft.cpp \ + $$QT_FREETYPE_DIR/src/base/ftbase.c \ + $$QT_FREETYPE_DIR/src/base/ftbbox.c \ + $$QT_FREETYPE_DIR/src/base/ftdebug.c \ + $$QT_FREETYPE_DIR/src/base/ftglyph.c \ + $$QT_FREETYPE_DIR/src/base/ftinit.c \ + $$QT_FREETYPE_DIR/src/base/ftmm.c \ + $$QT_FREETYPE_DIR/src/base/fttype1.c \ + $$QT_FREETYPE_DIR/src/base/ftsynth.c \ + $$QT_FREETYPE_DIR/src/base/ftbitmap.c \ + $$QT_FREETYPE_DIR/src/bdf/bdf.c \ + $$QT_FREETYPE_DIR/src/cache/ftcache.c \ + $$QT_FREETYPE_DIR/src/cff/cff.c \ + $$QT_FREETYPE_DIR/src/cid/type1cid.c \ + $$QT_FREETYPE_DIR/src/gzip/ftgzip.c \ + $$QT_FREETYPE_DIR/src/pcf/pcf.c \ + $$QT_FREETYPE_DIR/src/pfr/pfr.c \ + $$QT_FREETYPE_DIR/src/psaux/psaux.c \ + $$QT_FREETYPE_DIR/src/pshinter/pshinter.c \ + $$QT_FREETYPE_DIR/src/psnames/psmodule.c \ + $$QT_FREETYPE_DIR/src/raster/raster.c \ + $$QT_FREETYPE_DIR/src/sfnt/sfnt.c \ + $$QT_FREETYPE_DIR/src/smooth/smooth.c \ + $$QT_FREETYPE_DIR/src/truetype/truetype.c \ + $$QT_FREETYPE_DIR/src/type1/type1.c \ + $$QT_FREETYPE_DIR/src/type42/type42.c \ + $$QT_FREETYPE_DIR/src/winfonts/winfnt.c \ + $$QT_FREETYPE_DIR/src/lzw/ftlzw.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvalid.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvbase.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvgdef.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvjstf.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvcommn.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvgpos.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvgsub.c\ + $$QT_FREETYPE_DIR/src/otvalid/otvmod.c\ + $$QT_FREETYPE_DIR/src/autofit/afangles.c\ + $$QT_FREETYPE_DIR/src/autofit/afglobal.c\ + $$QT_FREETYPE_DIR/src/autofit/aflatin.c\ + $$QT_FREETYPE_DIR/src/autofit/afmodule.c\ + $$QT_FREETYPE_DIR/src/autofit/afdummy.c\ + $$QT_FREETYPE_DIR/src/autofit/afhints.c\ + $$QT_FREETYPE_DIR/src/autofit/afloader.c\ + $$QT_FREETYPE_DIR/src/autofit/autofit.c + + SOURCES += $$QT_FREETYPE_DIR/src/base/ftsystem.c + + + INCLUDEPATH += \ + $$QT_FREETYPE_DIR/src \ + $$QT_FREETYPE_DIR/include + + TR_EXCLUDE += $$QT_FREETYPE_DIR/* + + DEFINES += FT2_BUILD_LIBRARY + contains(QT_CONFIG, system-zlib) { + DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB + } +} else:contains(QT_CONFIG, system-freetype) { + include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri) + HEADERS += \ + $$PWD/qwindowsfontdatabase_ft.h + SOURCES += \ + $$PWD/qwindowsfontdatabase_ft.cpp +} + +contains(QT_CONFIG, accessibility):include($$PWD/accessible/accessible.pri) diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro index 0249e156d9..188bd7917c 100644 --- a/src/plugins/platforms/windows/windows.pro +++ b/src/plugins/platforms/windows/windows.pro @@ -8,184 +8,19 @@ QT *= core-private QT *= gui-private QT *= platformsupport-private -# Note: OpenGL32 must precede Gdi32 as it overwrites some functions. -LIBS *= -lole32 -!wince*:LIBS *= -lgdi32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32 +!wince:LIBS *= -lgdi32 -contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):LIBS *= -lopengl32 +include(windows.pri) -win32-g++*: LIBS *= -luuid -# For the dialog helpers: -!wince*:LIBS *= -lshlwapi -lshell32 -!wince*:LIBS *= -ladvapi32 -wince*:DEFINES *= QT_LIBINFIX=L"\"\\\"$${QT_LIBINFIX}\\\"\"" - -DEFINES *= QT_NO_CAST_FROM_ASCII - -contains(QT_CONFIG, directwrite) { - LIBS *= -ldwrite - SOURCES += qwindowsfontenginedirectwrite.cpp - HEADERS += qwindowsfontenginedirectwrite.h -} else { - DEFINES *= QT_NO_DIRECTWRITE -} - -SOURCES += \ +SOURCES += \ main.cpp \ - qwindowsnativeimage.cpp \ - qwindowswindow.cpp \ - qwindowsintegration.cpp \ - qwindowscontext.cpp \ qwindowsbackingstore.cpp \ - qwindowsscreen.cpp \ - qwindowskeymapper.cpp \ - qwindowsfontengine.cpp \ - qwindowsfontdatabase.cpp \ - qwindowsmousehandler.cpp \ - qwindowsguieventdispatcher.cpp \ - qwindowsole.cpp \ - qwindowsmime.cpp \ - qwindowsinternalmimedata.cpp \ - qwindowscursor.cpp \ - qwindowsinputcontext.cpp \ - qwindowstheme.cpp \ - qwindowsdialoghelpers.cpp \ - qwindowsservices.cpp + qwindowsgdiintegration.cpp \ + qwindowsgdinativeinterface.cpp -HEADERS += \ - qwindowsnativeimage.h \ - qwindowswindow.h \ - qwindowsintegration.h \ - qwindowscontext.h \ +HEADERS += \ qwindowsbackingstore.h \ - qwindowsscreen.h \ - qwindowskeymapper.h \ - qwindowsfontengine.h \ - qwindowsfontdatabase.h \ - qwindowsmousehandler.h \ - qwindowsguieventdispatcher.h \ - qtwindowsglobal.h \ - qtwindows_additional.h \ - qwindowsole.h \ - qwindowsmime.h \ - qwindowsinternalmimedata.h \ - qwindowscursor.h \ - array.h \ - qwindowsinputcontext.h \ - qwindowstheme.h \ - qwindowsdialoghelpers.h \ - qwindowsservices.h \ - qplatformfunctions_wince.h - -contains(QT_CONFIG, opengles2) { - SOURCES += qwindowseglcontext.cpp - HEADERS += qwindowseglcontext.h -} else { - contains(QT_CONFIG, opengl) { - SOURCES += qwindowsglcontext.cpp - HEADERS += qwindowsglcontext.h - } -} - -!contains( DEFINES, QT_NO_CLIPBOARD ) { - SOURCES += qwindowsclipboard.cpp - HEADERS += qwindowsclipboard.h -} - -# drag and drop on windows only works if a clipboard is available -!contains( DEFINES, QT_NO_DRAGANDDROP ) { - !win32:SOURCES += qwindowsdrag.cpp - !win32:HEADERS += qwindowsdrag.h - win32:!contains( DEFINES, QT_NO_CLIPBOARD ) { - HEADERS += qwindowsdrag.h - SOURCES += qwindowsdrag.cpp - } -} - -!wince*:!contains( DEFINES, QT_NO_TABLETEVENT ) { - INCLUDEPATH += ../../../3rdparty/wintab - HEADERS += qwindowstabletsupport.h - SOURCES += qwindowstabletsupport.cpp -} - -!wince*:!contains( DEFINES, QT_NO_SESSIONMANAGER ) { - SOURCES += qwindowssessionmanager.cpp - HEADERS += qwindowssessionmanager.h -} - -contains(QT_CONFIG, freetype) { - DEFINES *= QT_NO_FONTCONFIG - QT_FREETYPE_DIR = $$QT_SOURCE_TREE/src/3rdparty/freetype - - HEADERS += \ - qwindowsfontdatabase_ft.h - SOURCES += \ - qwindowsfontdatabase_ft.cpp \ - $$QT_FREETYPE_DIR/src/base/ftbase.c \ - $$QT_FREETYPE_DIR/src/base/ftbbox.c \ - $$QT_FREETYPE_DIR/src/base/ftdebug.c \ - $$QT_FREETYPE_DIR/src/base/ftglyph.c \ - $$QT_FREETYPE_DIR/src/base/ftinit.c \ - $$QT_FREETYPE_DIR/src/base/ftmm.c \ - $$QT_FREETYPE_DIR/src/base/fttype1.c \ - $$QT_FREETYPE_DIR/src/base/ftsynth.c \ - $$QT_FREETYPE_DIR/src/base/ftbitmap.c \ - $$QT_FREETYPE_DIR/src/bdf/bdf.c \ - $$QT_FREETYPE_DIR/src/cache/ftcache.c \ - $$QT_FREETYPE_DIR/src/cff/cff.c \ - $$QT_FREETYPE_DIR/src/cid/type1cid.c \ - $$QT_FREETYPE_DIR/src/gzip/ftgzip.c \ - $$QT_FREETYPE_DIR/src/pcf/pcf.c \ - $$QT_FREETYPE_DIR/src/pfr/pfr.c \ - $$QT_FREETYPE_DIR/src/psaux/psaux.c \ - $$QT_FREETYPE_DIR/src/pshinter/pshinter.c \ - $$QT_FREETYPE_DIR/src/psnames/psmodule.c \ - $$QT_FREETYPE_DIR/src/raster/raster.c \ - $$QT_FREETYPE_DIR/src/sfnt/sfnt.c \ - $$QT_FREETYPE_DIR/src/smooth/smooth.c \ - $$QT_FREETYPE_DIR/src/truetype/truetype.c \ - $$QT_FREETYPE_DIR/src/type1/type1.c \ - $$QT_FREETYPE_DIR/src/type42/type42.c \ - $$QT_FREETYPE_DIR/src/winfonts/winfnt.c \ - $$QT_FREETYPE_DIR/src/lzw/ftlzw.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvalid.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvbase.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvgdef.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvjstf.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvcommn.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvgpos.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvgsub.c\ - $$QT_FREETYPE_DIR/src/otvalid/otvmod.c\ - $$QT_FREETYPE_DIR/src/autofit/afangles.c\ - $$QT_FREETYPE_DIR/src/autofit/afglobal.c\ - $$QT_FREETYPE_DIR/src/autofit/aflatin.c\ - $$QT_FREETYPE_DIR/src/autofit/afmodule.c\ - $$QT_FREETYPE_DIR/src/autofit/afdummy.c\ - $$QT_FREETYPE_DIR/src/autofit/afhints.c\ - $$QT_FREETYPE_DIR/src/autofit/afloader.c\ - $$QT_FREETYPE_DIR/src/autofit/autofit.c - - SOURCES += $$QT_FREETYPE_DIR/src/base/ftsystem.c - - - INCLUDEPATH += \ - $$QT_FREETYPE_DIR/src \ - $$QT_FREETYPE_DIR/include - - TR_EXCLUDE += $$QT_FREETYPE_DIR/* - - DEFINES += FT2_BUILD_LIBRARY - contains(QT_CONFIG, system-zlib) { - DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB - } -} else:contains(QT_CONFIG, system-freetype) { - include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri) - HEADERS += \ - qwindowsfontdatabase_ft.h - SOURCES += \ - qwindowsfontdatabase_ft.cpp -} + qwindowsgdiintegration.h \ + qwindowsgdinativeinterface.h OTHER_FILES += windows.json - -contains(QT_CONFIG, accessibility):include(accessible/accessible.pri) |