1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qwindowscontext.h"
43 #include "qwindowswindow.h"
44 #include "qwindowskeymapper.h"
45 #include "qwindowsguieventdispatcher.h"
46 #include "qwindowsmousehandler.h"
47 #include "qtwindowsglobal.h"
48 #include "qwindowsmime.h"
49 #include "qwindowsinputcontext.h"
50 #include "accessible/qwindowsaccessibility.h"
51 #include "qwindowsscreen.h"
52 #include "qwindowstheme.h"
54 #include <QtGui/QWindow>
55 #include <QtGui/QWindowSystemInterface>
56 #include <QtGui/QPlatformNativeInterface>
57 #include <QtGui/QGuiApplication>
59 #include <QtCore/QSet>
60 #include <QtCore/QHash>
61 #include <QtCore/QStringList>
62 #include <QtCore/QDebug>
63 #include <QtCore/QSysInfo>
64 #include <QtCore/QScopedArrayPointer>
65 #include <QtCore/private/qsystemlibrary_p.h>
73 // Verbosity of components
74 int QWindowsContext::verboseIntegration = 0;
75 int QWindowsContext::verboseWindows = 0;
76 int QWindowsContext::verboseEvents = 0;
77 int QWindowsContext::verboseBackingStore = 0;
78 int QWindowsContext::verboseFonts = 0;
79 int QWindowsContext::verboseGL = 0;
80 int QWindowsContext::verboseOLE = 0;
81 int QWindowsContext::verboseInputMethods = 0;
82 int QWindowsContext::verboseDialogs = 0;
83 int QWindowsContext::verboseTheming = 0;
85 // Get verbosity of components from "foo:2,bar:3"
86 static inline int componentVerbose(const char *v, const char *keyWord)
88 if (const char *k = strstr(v, keyWord)) {
89 k += qstrlen(keyWord);
99 static inline bool hasTouchSupport(QSysInfo::WinVersion wv)
101 enum { QT_SM_DIGITIZER = 94, QT_NID_INTEGRATED_TOUCH = 0x1,
102 QT_NID_EXTERNAL_TOUCH = 0x02, QT_NID_MULTI_INPUT = 0x40 };
104 return wv < QSysInfo::WV_WINDOWS7 ? false :
105 (GetSystemMetrics(QT_SM_DIGITIZER) & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH | QT_NID_MULTI_INPUT)) != 0;
108 #if !defined(LANG_SYRIAC)
109 # define LANG_SYRIAC 0x5a
112 static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
114 if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) {
115 // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
116 // Vista, check the Keyboard Layouts for enabling RTL.
117 if (const UINT nLayouts = GetKeyboardLayoutList(0, 0)) {
118 QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
119 GetKeyboardLayoutList(nLayouts, lpList.data());
120 for (UINT i = 0; i < nLayouts; ++i) {
121 switch (PRIMARYLANGID((quintptr)lpList[i])) {
134 // Pre-NT: figure out whether a RTL language is installed
135 return IsValidLanguageGroup(LGRPID_ARABIC, LGRPID_INSTALLED)
136 || IsValidLanguageGroup(LGRPID_HEBREW, LGRPID_INSTALLED)
137 || IsValidLocale(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
138 || IsValidLocale(MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
139 || IsValidLocale(MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
140 || IsValidLocale(MAKELCID(MAKELANGID(LANG_FARSI, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED);
144 \class QWindowsUser32DLL
145 \brief Struct that contains dynamically resolved symbols of User32.dll.
147 The stub libraries shipped with the MinGW compiler miss some of the
148 functions. They need to be retrieved dynamically.
150 In addition, touch-related functions are available only from Windows onwards.
151 These need to resolved dynamically for Q_CC_MSVC as well.
153 \sa QWindowsShell32DLL
155 \ingroup qt-lighthouse-win
158 QWindowsUser32DLL::QWindowsUser32DLL() :
159 setLayeredWindowAttributes(0), updateLayeredWindow(0),
160 updateLayeredWindowIndirect(0),
162 registerTouchWindow(0), getTouchInputInfo(0), closeTouchInputHandle(0)
166 void QWindowsUser32DLL::init()
168 QSystemLibrary library(QStringLiteral("user32"));
169 // MinGW (g++ 3.4.5) accepts only C casts.
170 setLayeredWindowAttributes = (SetLayeredWindowAttributes)(library.resolve("SetLayeredWindowAttributes"));
171 updateLayeredWindow = (UpdateLayeredWindow)(library.resolve("UpdateLayeredWindow"));
172 if (!setLayeredWindowAttributes || !updateLayeredWindow)
173 qFatal("This version of Windows is not supported (User32.dll is missing the symbols 'SetLayeredWindowAttributes', 'UpdateLayeredWindow').");
175 updateLayeredWindowIndirect = (UpdateLayeredWindowIndirect)(library.resolve("UpdateLayeredWindowIndirect"));
176 isHungAppWindow = (IsHungAppWindow)library.resolve("IsHungAppWindow");
179 bool QWindowsUser32DLL::initTouch()
181 QSystemLibrary library(QStringLiteral("user32"));
182 registerTouchWindow = (RegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
183 getTouchInputInfo = (GetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
184 closeTouchInputHandle = (CloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
185 return registerTouchWindow && getTouchInputInfo && getTouchInputInfo;
189 \class QWindowsShell32DLL
190 \brief Struct that contains dynamically resolved symbols of Shell32.dll.
192 The stub libraries shipped with the MinGW compiler miss some of the
193 functions. They need to be retrieved dynamically.
195 \sa QWindowsUser32DLL
197 \ingroup qt-lighthouse-win
200 QWindowsShell32DLL::QWindowsShell32DLL() : sHCreateItemFromParsingName(0)
204 void QWindowsShell32DLL::init()
206 QSystemLibrary library(QStringLiteral("shell32"));
207 sHCreateItemFromParsingName = (SHCreateItemFromParsingName)(library.resolve("SHCreateItemFromParsingName"));
210 QWindowsUser32DLL QWindowsContext::user32dll;
211 QWindowsShell32DLL QWindowsContext::shell32dll;
213 QWindowsContext *QWindowsContext::m_instance = 0;
216 \class QWindowsContext
217 \brief Singleton container for all relevant information.
219 Holds state information formerly stored in \c qapplication_win.cpp.
220 \ingroup qt-lighthouse-win
223 typedef QHash<HWND, QWindowsWindow *> HandleBaseWindowHash;
225 struct QWindowsContextPrivate {
226 typedef QPlatformNativeInterface::EventFilter EventFilter;
230 GenericWindowsEventFilter,
234 QWindowsContextPrivate();
236 unsigned m_systemInfo;
237 QSet<QString> m_registeredWindowClassNames;
238 HandleBaseWindowHash m_windows;
239 HDC m_displayContext;
240 const int m_defaultDPI;
241 QWindowsKeyMapper m_keyMapper;
242 QWindowsMouseHandler m_mouseHandler;
243 QWindowsMimeConverter m_mimeConverter;
244 QWindowsScreenManager m_screenManager;
245 QSharedPointer<QWindowCreationContext> m_creationContext;
246 const HRESULT m_oleInitializeResult;
247 const QByteArray m_eventType;
248 EventFilter m_eventFilters[EventFilterTypeCount];
251 QWindowsContextPrivate::QWindowsContextPrivate() :
253 m_displayContext(GetDC(0)),
254 m_defaultDPI(GetDeviceCaps(m_displayContext,LOGPIXELSY)),
255 m_oleInitializeResult(OleInitialize(NULL)),
256 m_eventType(QByteArrayLiteral("windows_generic_MSG"))
258 QWindowsContext::user32dll.init();
259 QWindowsContext::shell32dll.init();
261 const QSysInfo::WinVersion ver = QSysInfo::windowsVersion();
263 if (hasTouchSupport(ver) && QWindowsContext::user32dll.initTouch())
264 m_systemInfo |= QWindowsContext::SI_SupportsTouch;
266 if (useRTL_Extensions(ver)) {
267 m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
268 m_keyMapper.setUseRTLExtensions(true);
270 qFill(m_eventFilters, m_eventFilters + EventFilterTypeCount, EventFilter(0));
273 QWindowsContext::QWindowsContext() :
274 d(new QWindowsContextPrivate)
277 # pragma warning( disable : 4996 )
280 if (const char *v = getenv("QT_QPA_VERBOSE")) {
281 QWindowsContext::verboseIntegration = componentVerbose(v, "integration");
282 QWindowsContext::verboseWindows = componentVerbose(v, "windows");
283 QWindowsContext::verboseEvents = componentVerbose(v, "events");
284 QWindowsContext::verboseBackingStore = componentVerbose(v, "backingstore");
285 QWindowsContext::verboseFonts = componentVerbose(v, "fonts");
286 QWindowsContext::verboseGL = componentVerbose(v, "gl");
287 QWindowsContext::verboseOLE = componentVerbose(v, "ole");
288 QWindowsContext::verboseInputMethods = componentVerbose(v, "im");
289 QWindowsContext::verboseDialogs = componentVerbose(v, "dialogs");
290 QWindowsContext::verboseTheming = componentVerbose(v, "theming");
294 QWindowsContext::~QWindowsContext()
296 unregisterWindowClasses();
297 if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE)
300 d->m_screenManager.clearScreens(); // Order: Potentially calls back to the windows.
304 QWindowsContext *QWindowsContext::instance()
309 unsigned QWindowsContext::systemInfo() const
311 return d->m_systemInfo;
314 void QWindowsContext::setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx)
316 d->m_creationContext = ctx;
319 int QWindowsContext::defaultDPI() const
321 return d->m_defaultDPI;
324 HDC QWindowsContext::displayContext() const
326 return d->m_displayContext;
329 QWindow *QWindowsContext::keyGrabber() const
331 return d->m_keyMapper.keyGrabber();
334 void QWindowsContext::setKeyGrabber(QWindow *w)
336 d->m_keyMapper.setKeyGrabber(w);
339 // Window class registering code (from qapplication_win.cpp)
340 // If 0 is passed as the widget pointer, register a window class
341 // for QWidget as default. This is used in QGLTemporaryContext
342 // during GL initialization, where we don't want to use temporary
343 // QWidgets or QGLWidgets, neither do we want to have separate code
344 // to register window classes.
346 QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL)
348 const Qt::WindowFlags flags = w ? w->windowFlags() : (Qt::WindowFlags)0;
349 const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
353 QString cname = QStringLiteral("Qt5");
355 cname += QStringLiteral("QGLWindow");
356 style = CS_DBLCLKS|CS_OWNDC;
358 } else if (w && (flags & Qt::MSWindowsOwnDC)) {
359 cname += QStringLiteral("QWindowOwnDC");
360 style = CS_DBLCLKS|CS_OWNDC;
362 } else if (w && (type == Qt::Tool || type == Qt::ToolTip)) {
364 if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) {
365 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
366 && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) {
367 style |= CS_DROPSHADOW;
369 cname += QStringLiteral("QToolTip");
371 cname += QStringLiteral("QTool");
373 style |= CS_SAVEBITS;
375 } else if (w && (type == Qt::Popup)) {
376 cname += QStringLiteral("QPopup");
377 style = CS_DBLCLKS|CS_SAVEBITS;
378 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
379 && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
380 style |= CS_DROPSHADOW;
383 cname += QStringLiteral("QWindow");
390 brush = GetSysColorBrush(COLOR_WINDOW);
391 return registerWindowClass(cname, qWindowsWndProc, style, brush, icon);
394 QString QWindowsContext::registerWindowClass(QString cname,
400 // since multiple Qt versions can be used in one process
401 // each one has to have window class names with a unique name
402 // The first instance gets the unmodified name; if the class
403 // has already been registered by another instance of Qt then
404 // add an instance-specific ID, the address of the window proc.
405 static int classExists = -1;
407 const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
408 if (classExists == -1) {
410 classExists = GetClassInfo(appInstance, (wchar_t*)cname.utf16(), &wcinfo);
411 classExists = classExists && wcinfo.lpfnWndProc != proc;
415 cname += QString::number((quintptr)proc);
417 if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
421 wc.cbSize = sizeof(WNDCLASSEX);
423 wc.lpfnWndProc = proc;
426 wc.hInstance = appInstance;
428 wc.hIcon = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
430 int sw = GetSystemMetrics(SM_CXSMICON);
431 int sh = GetSystemMetrics(SM_CYSMICON);
432 wc.hIconSm = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0);
434 wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
442 wc.hbrBackground = brush;
444 wc.lpszClassName = (wchar_t*)cname.utf16();
445 ATOM atom = RegisterClassEx(&wc);
448 qErrnoWarning("QApplication::regClass: Registering window class '%s' failed.",
451 d->m_registeredWindowClassNames.insert(cname);
452 if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows)
453 qDebug().nospace() << __FUNCTION__ << ' ' << cname
454 << " style=0x" << QString::number(style, 16)
455 << " brush=" << brush << " icon=" << icon << " atom=" << atom;
459 void QWindowsContext::unregisterWindowClasses()
461 const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
463 foreach (const QString &name, d->m_registeredWindowClassNames) {
464 if (QWindowsContext::verboseIntegration)
465 qDebug() << __FUNCTION__ << name;
466 UnregisterClass((wchar_t*)name.utf16(), appInstance);
468 d->m_registeredWindowClassNames.clear();
471 int QWindowsContext::screenDepth() const
473 return GetDeviceCaps(d->m_displayContext, BITSPIXEL);
476 QString QWindowsContext::windowsErrorMessage(unsigned long errorCode)
478 QString rc = QString::fromLatin1("#%1: ").arg(errorCode);
481 const int len = FormatMessage(
482 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
483 NULL, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
485 rc = QString::fromUtf16(lpMsgBuf, len);
488 rc += QString::fromLatin1("<unknown error>");
493 void QWindowsContext::addWindow(HWND hwnd, QWindowsWindow *w)
495 d->m_windows.insert(hwnd, w);
498 void QWindowsContext::removeWindow(HWND hwnd)
500 const HandleBaseWindowHash::iterator it = d->m_windows.find(hwnd);
501 if (it != d->m_windows.end()) {
502 if (d->m_keyMapper.keyGrabber() == it.value()->window())
503 d->m_keyMapper.setKeyGrabber(0);
504 d->m_windows.erase(it);
508 QWindowsWindow *QWindowsContext::findPlatformWindow(HWND hwnd) const
510 return d->m_windows.value(hwnd);
513 QWindow *QWindowsContext::findWindow(HWND hwnd) const
515 if (const QWindowsWindow *bw = findPlatformWindow(hwnd))
520 QWindow *QWindowsContext::windowUnderMouse() const
522 return d->m_mouseHandler.windowUnderMouse();
526 \brief Find a child window at a screen point.
528 Deep search for a QWindow at global point, skipping non-owned
529 windows (accessibility?). Implemented using ChildWindowFromPointEx()
530 instead of (historically used) WindowFromPoint() to get a well-defined
531 behaviour for hidden/transparent windows.
533 \a cwex_flags are flags of ChildWindowFromPointEx().
534 \a parent is the parent window, pass GetDesktopWindow() for top levels.
537 QWindowsWindow *QWindowsContext::findPlatformWindowAt(HWND parent,
538 const QPoint &screenPointIn,
539 unsigned cwex_flags) const
541 QWindowsWindow *result = 0;
542 const POINT screenPoint = { screenPointIn.x(), screenPointIn.y() };
544 POINT point = screenPoint;
545 ScreenToClient(parent, &point);
546 // Returns parent if inside & none matched.
547 const HWND child = ChildWindowFromPointEx(parent, point, cwex_flags);
548 if (child && child != parent) {
549 if (QWindowsWindow *window = findPlatformWindow(child))
559 QWindowsMimeConverter &QWindowsContext::mimeConverter() const
561 return d->m_mimeConverter;
564 QWindowsScreenManager &QWindowsContext::screenManager()
566 return d->m_screenManager;
570 \brief Convenience to create a non-visible, message-only dummy
571 window for example used as clipboard watcher or for GL.
574 HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
575 const wchar_t *windowName,
576 WNDPROC wndProc, DWORD style)
579 wndProc = DefWindowProc;
580 QString className = registerWindowClass(classNameIn, wndProc);
581 return CreateWindowEx(0, (wchar_t*)className.utf16(),
583 CW_USEDEFAULT, CW_USEDEFAULT,
584 CW_USEDEFAULT, CW_USEDEFAULT,
585 HWND_MESSAGE, NULL, (HINSTANCE)GetModuleHandle(0), NULL);
589 \brief Common COM error strings.
592 QByteArray QWindowsContext::comErrorString(HRESULT hr)
596 return QByteArray("S_OK");
598 return QByteArray("S_FALSE");
600 return QByteArray("E_UNEXPECTED");
601 case CO_E_ALREADYINITIALIZED:
602 return QByteArray("CO_E_ALREADYINITIALIZED");
603 case CO_E_NOTINITIALIZED:
604 return QByteArray("CO_E_NOTINITIALIZED");
605 case RPC_E_CHANGED_MODE:
606 return QByteArray("RPC_E_CHANGED_MODE");
607 case OLE_E_WRONGCOMPOBJ:
608 return QByteArray("OLE_E_WRONGCOMPOBJ");
609 case CO_E_NOT_SUPPORTED:
610 return QByteArray("CO_E_NOT_SUPPORTED");
612 return QByteArray("E_NOTIMPL");
614 return QByteArray("");
616 return QByteArray("");
618 return QByteArray("");
620 return QByteArray("");
622 return QByteArray("");
624 return QByteArray("");
626 return QByteArray("");
630 return "Unknown error 0x" + QByteArray::number(quint64(hr), 16);
634 \brief Set event filter.
636 \sa QWindowsNativeInterface
639 QWindowsContext::EventFilter QWindowsContext::setEventFilter(const QByteArray &eventType, EventFilter filter)
641 int eventFilterType = -1;
642 if (eventType == d->m_eventType)
643 eventFilterType = QWindowsContextPrivate::GenericWindowsEventFilter;
644 if (eventFilterType < 0) {
645 qWarning("%s: Attempt to set unsupported event filter '%s'.",
646 __FUNCTION__, eventType.constData());
649 const EventFilter previous = d->m_eventFilters[eventFilterType];
650 d->m_eventFilters[eventFilterType] = filter;
655 \brief Main windows procedure registered for windows.
657 \sa QWindowsGuiEventDispatcher
660 bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
661 QtWindows::WindowsEventType et,
662 WPARAM wParam, LPARAM lParam, LRESULT *result)
667 msg.hwnd = hwnd; // re-create MSG structure
668 msg.message = message; // time and pt fields ignored
671 msg.pt.x = GET_X_LPARAM(lParam);
672 msg.pt.y = GET_Y_LPARAM(lParam);
674 long filterResult = 0;
675 if (d->m_eventFilters[QWindowsContextPrivate::GenericWindowsEventFilter]) {
676 if (d->m_eventFilters[QWindowsContextPrivate::GenericWindowsEventFilter](&msg, &filterResult)) {
677 *result = LRESULT(filterResult);
681 // Events without an associated QWindow or events we are not interested in.
683 case QtWindows::InputMethodStartCompositionEvent:
684 return QWindowsInputContext::instance()->startComposition(hwnd);
685 case QtWindows::InputMethodCompositionEvent:
686 return QWindowsInputContext::instance()->composition(hwnd, lParam);
687 case QtWindows::InputMethodEndCompositionEvent:
688 return QWindowsInputContext::instance()->endComposition(hwnd);
689 case QtWindows::InputMethodRequest:
690 return QWindowsInputContext::instance()->handleIME_Request(wParam, lParam, result);
691 case QtWindows::InputMethodOpenCandidateWindowEvent:
692 case QtWindows::InputMethodCloseCandidateWindowEvent:
693 // TODO: Release/regrab mouse if a popup has mouse grab.
695 case QtWindows::ClipboardEvent:
696 case QtWindows::DestroyEvent:
698 case QtWindows::UnknownEvent:
700 case QtWindows::AccessibleObjectFromWindowRequest:
701 return QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(hwnd, wParam, lParam, result);
702 case QtWindows::DisplayChangedEvent:
703 return d->m_screenManager.handleDisplayChange(wParam, lParam);
708 QWindowsWindow *platformWindow = findPlatformWindow(hwnd);
709 // Before CreateWindowEx() returns, some events are sent,
710 // for example WM_GETMINMAXINFO asking for size constraints for top levels.
711 // Pass on to current creation context
712 if (!platformWindow && !d->m_creationContext.isNull()) {
714 case QtWindows::QuerySizeHints:
715 d->m_creationContext->applyToMinMaxInfo(reinterpret_cast<MINMAXINFO *>(lParam));
717 case QtWindows::ResizeEvent:
718 d->m_creationContext->obtainedGeometry.setSize(QSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
720 case QtWindows::MoveEvent:
721 d->m_creationContext->obtainedGeometry.moveTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
723 case QtWindows::CalculateSize:
729 if (platformWindow) {
730 if (QWindowsContext::verboseEvents > 1)
731 qDebug().nospace() << "Event window: " << platformWindow->window();
733 qWarning("%s: No Qt Window found for event 0x%x (%s), hwnd=0x%p.",
734 __FUNCTION__, message,
735 QWindowsGuiEventDispatcher::windowsMessageName(message), hwnd);
740 if (QWindowSystemInterface::handleNativeEvent(platformWindow->window(), d->m_eventType, &msg, &filterResult)) {
741 *result = LRESULT(filterResult);
746 case QtWindows::KeyDownEvent:
747 case QtWindows::KeyEvent:
748 case QtWindows::InputMethodKeyEvent:
749 case QtWindows::InputMethodKeyDownEvent:
750 return d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
751 case QtWindows::MoveEvent:
752 platformWindow->handleMoved();
754 case QtWindows::ResizeEvent:
755 platformWindow->handleResized((int)wParam);
757 case QtWindows::QuerySizeHints:
758 platformWindow->getSizeHints(reinterpret_cast<MINMAXINFO *>(lParam));
760 case QtWindows::CalculateSize:
761 // NCCALCSIZE_PARAMS structure if wParam==TRUE
762 if (wParam && QWindowsContext::verboseWindows) {
763 const NCCALCSIZE_PARAMS *ncp = reinterpret_cast<NCCALCSIZE_PARAMS *>(lParam);
764 qDebug() << platformWindow->window() << *ncp;
767 case QtWindows::ExposeEvent:
768 return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
769 case QtWindows::MouseWheelEvent:
770 case QtWindows::MouseEvent:
771 case QtWindows::NonClientMouseEvent:
772 case QtWindows::LeaveEvent:
773 return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
774 case QtWindows::TouchEvent:
775 return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
776 case QtWindows::FocusInEvent: // see QWindowsWindow::requestActivateWindow().
777 QWindowSystemInterface::handleWindowActivated(platformWindow->window());
779 case QtWindows::FocusOutEvent:
780 QWindowSystemInterface::handleWindowActivated(0);
782 case QtWindows::ShowEvent:
783 platformWindow->handleShown();
785 case QtWindows::HideEvent:
786 platformWindow->handleHidden();
788 case QtWindows::CloseEvent:
789 QWindowSystemInterface::handleCloseEvent(platformWindow->window());
791 case QtWindows::ThemeChanged: // ### fixme: Compress these events?
792 if (QWindowsTheme *theme = QWindowsTheme::instance())
793 theme->windowsThemeChanged(platformWindow->window());
795 case QtWindows::ActivateWindowEvent:
796 if (platformWindow->testFlag(QWindowsWindow::BlockedByModal))
797 if (const QWindow *modalWindow = QGuiApplication::modalWindow())
798 QWindowsWindow::baseWindowOf(modalWindow)->alertWindow();
807 \brief Windows functions for actual windows.
809 There is another one for timers, sockets, etc in
810 QEventDispatcherWin32.
812 \ingroup qt-lighthouse-win
815 extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
818 const QtWindows::WindowsEventType et = windowsEventType(message, wParam);
819 const bool handled = QWindowsContext::instance()->windowsProc(hwnd, message, et, wParam, lParam, &result);
820 if (QWindowsContext::verboseEvents > 1)
821 if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message))
822 qDebug("EVENT: hwd=%p %s msg=0x%x et=0x%x wp=%d at %d,%d handled=%d",
823 hwnd, eventName, message, et, int(wParam),
824 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), handled);
826 result = DefWindowProc(hwnd, message, wParam, lParam);