summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowscontext.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-06 16:19:14 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-06 16:50:03 +0200
commit1326cd15f7ba985551f0fddc717e3bfc01ddda85 (patch)
tree024eb871ed5f4e8c02e21412475e6e9929a2b030 /src/plugins/platforms/windows/qwindowscontext.cpp
parentfe70367fe06984d1ac84cc276ca3fd3edc4193c7 (diff)
parentbeb7258a56b6ec76531b73cc07ee30132a3f548f (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: mkspecs/qnx-x86-qcc/qplatformdefs.h src/corelib/global/qglobal.h src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/qgl.cpp src/opengl/qglpixelbuffer.cpp src/opengl/qglshaderprogram.cpp tests/auto/opengl/qglthreads/tst_qglthreads.cpp Change-Id: Iaba137884d3526a139000ca26fee02bb27b5cdb5
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp89
1 files changed, 68 insertions, 21 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 7643177395..ccff2d3e9f 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 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.
@@ -49,11 +49,11 @@
#include "qwindowsmime.h"
#include "qwindowsinputcontext.h"
#include "qwindowstabletsupport.h"
+#include <private/qguiapplication_p.h>
#ifndef QT_NO_ACCESSIBILITY
# include "accessible/qwindowsaccessibility.h"
#endif
#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
-# include <private/qguiapplication_p.h>
# include <private/qsessionmanager_p.h>
# include "qwindowssessionmanager.h"
#endif
@@ -76,6 +76,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <windowsx.h>
+#ifndef Q_OS_WINCE
+# include <comdef.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -213,7 +216,7 @@ bool QWindowsUser32DLL::initTouch()
unregisterTouchWindow = (UnregisterTouchWindow)(library.resolve("UnregisterTouchWindow"));
getTouchInputInfo = (GetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
closeTouchInputHandle = (CloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
- return registerTouchWindow && unregisterTouchWindow && getTouchInputInfo && getTouchInputInfo;
+ return registerTouchWindow && unregisterTouchWindow && getTouchInputInfo && closeTouchInputHandle;
}
/*!
@@ -325,6 +328,10 @@ QWindowsContextPrivate::QWindowsContextPrivate()
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
+ if (FAILED(m_oleInitializeResult)) {
+ qWarning() << "QWindowsContext: OleInitialize() failed: "
+ << QWindowsContext::comErrorString(m_oleInitializeResult);
+ }
}
QWindowsContext::QWindowsContext() :
@@ -734,45 +741,70 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
QByteArray QWindowsContext::comErrorString(HRESULT hr)
{
+ QByteArray result = QByteArrayLiteral("COM error 0x")
+ + QByteArray::number(quintptr(hr), 16) + ' ';
switch (hr) {
case S_OK:
- return QByteArrayLiteral("S_OK");
+ result += QByteArrayLiteral("S_OK");
+ break;
case S_FALSE:
- return QByteArrayLiteral("S_FALSE");
+ result += QByteArrayLiteral("S_FALSE");
+ break;
case E_UNEXPECTED:
- return QByteArrayLiteral("E_UNEXPECTED");
+ result += QByteArrayLiteral("E_UNEXPECTED");
+ break;
case CO_E_ALREADYINITIALIZED:
- return QByteArrayLiteral("CO_E_ALREADYINITIALIZED");
+ result += QByteArrayLiteral("CO_E_ALREADYINITIALIZED");
+ break;
case CO_E_NOTINITIALIZED:
- return QByteArrayLiteral("CO_E_NOTINITIALIZED");
+ result += QByteArrayLiteral("CO_E_NOTINITIALIZED");
+ break;
case RPC_E_CHANGED_MODE:
- return QByteArrayLiteral("RPC_E_CHANGED_MODE");
+ result += QByteArrayLiteral("RPC_E_CHANGED_MODE");
+ break;
case OLE_E_WRONGCOMPOBJ:
- return QByteArrayLiteral("OLE_E_WRONGCOMPOBJ");
+ result += QByteArrayLiteral("OLE_E_WRONGCOMPOBJ");
+ break;
case CO_E_NOT_SUPPORTED:
- return QByteArrayLiteral("CO_E_NOT_SUPPORTED");
+ result += QByteArrayLiteral("CO_E_NOT_SUPPORTED");
+ break;
case E_NOTIMPL:
- return QByteArrayLiteral("E_NOTIMPL");
+ result += QByteArrayLiteral("E_NOTIMPL");
+ break;
case E_INVALIDARG:
- return QByteArrayLiteral("E_INVALIDARG");
+ result += QByteArrayLiteral("E_INVALIDARG");
+ break;
case E_NOINTERFACE:
- return QByteArrayLiteral("E_NOINTERFACE");
+ result += QByteArrayLiteral("E_NOINTERFACE");
+ break;
case E_POINTER:
- return QByteArrayLiteral("E_POINTER");
+ result += QByteArrayLiteral("E_POINTER");
+ break;
case E_HANDLE:
- return QByteArrayLiteral("E_HANDLE");
+ result += QByteArrayLiteral("E_HANDLE");
+ break;
case E_ABORT:
- return QByteArrayLiteral("E_ABORT");
+ result += QByteArrayLiteral("E_ABORT");
+ break;
case E_FAIL:
- return QByteArrayLiteral("E_FAIL");
+ result += QByteArrayLiteral("E_FAIL");
+ break;
case RPC_E_WRONG_THREAD:
- return QByteArrayLiteral("RPC_E_WRONG_THREAD");
+ result += QByteArrayLiteral("RPC_E_WRONG_THREAD");
+ break;
case RPC_E_THREAD_NOT_INIT:
- return QByteArrayLiteral("RPC_E_THREAD_NOT_INIT");
+ result += QByteArrayLiteral("RPC_E_THREAD_NOT_INIT");
+ break;
default:
break;
}
- return "Unknown error 0x" + QByteArray::number(quint64(hr), 16);
+#ifndef Q_OS_WINCE
+ _com_error error(hr);
+ result += QByteArrayLiteral(" (");
+ result += QString::fromWCharArray(error.ErrorMessage()).toLocal8Bit();
+ result += ')';
+#endif // !Q_OS_WINCE
+ return result;
}
/*!
@@ -1068,6 +1100,21 @@ void QWindowsContext::handleFocusEvent(QtWindows::WindowsEventType et,
{
QWindow *nextActiveWindow = 0;
if (et == QtWindows::FocusInEvent) {
+ QWindow *topWindow = QWindowsWindow::topLevelOf(platformWindow->window());
+ QWindow *modalWindow = 0;
+ if (QGuiApplicationPrivate::instance()->isWindowBlocked(topWindow, &modalWindow) && topWindow != modalWindow) {
+ modalWindow->requestActivate();
+ return;
+ }
+ // QTBUG-32867: Invoking WinAPI SetParent() can cause focus-in for the
+ // window which is not desired for native child widgets.
+ if (platformWindow->testFlag(QWindowsWindow::WithinSetParent)) {
+ QWindow *currentFocusWindow = QGuiApplication::focusWindow();
+ if (currentFocusWindow && currentFocusWindow != platformWindow->window()) {
+ currentFocusWindow->requestActivate();
+ return;
+ }
+ }
nextActiveWindow = platformWindow->window();
} else {
// Focus out: Is the next window known and different