Changeset 561 for trunk/src/gui/kernel/qapplication_win.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qapplication_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** 40 40 ****************************************************************************/ 41 41 42 #ifdef Q_ OS_WINCE42 #ifdef Q_WS_WINCE 43 43 #include "qguifunctions_wince.h" 44 44 #include "qmenubar.h" … … 49 49 extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.cpp 50 50 #endif 51 #ifdef Q_ OS_WINCE_WM51 #ifdef Q_WS_WINCE_WM 52 52 #include <windowsm.h> 53 53 #include <tpcshell.h> 54 #ifdef QT_WINCE_GESTURES 55 #include <gesture.h> 56 #endif 54 57 #endif 55 58 … … 89 92 #include <private/qkeymapper_p.h> 90 93 #include <private/qlocale_p.h> 94 #include "qevent_p.h" 91 95 92 96 //#define ALIEN_DEBUG … … 105 109 #endif // QT_NO_ACCESSIBILITY 106 110 107 #include <winuser.h>108 111 #if !defined(WINABLEAPI) 109 # if defined(Q_ OS_WINCE)112 # if defined(Q_WS_WINCE) 110 113 # include <bldver.h> 111 114 # endif … … 113 116 #endif 114 117 115 116 #ifndef FLASHW_STOP 117 typedef struct { 118 UINT cbSize; 119 HWND hwnd; 118 #ifndef WM_TOUCH 119 # define WM_TOUCH 0x0240 120 121 # define TOUCHEVENTF_MOVE 0x0001 122 # define TOUCHEVENTF_DOWN 0x0002 123 # define TOUCHEVENTF_UP 0x0004 124 # define TOUCHEVENTF_INRANGE 0x0008 125 # define TOUCHEVENTF_PRIMARY 0x0010 126 # define TOUCHEVENTF_NOCOALESCE 0x0020 127 # define TOUCHEVENTF_PEN 0x0040 128 # define TOUCHEVENTF_PALM 0x0080 129 130 # define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001 131 # define TOUCHINPUTMASKF_EXTRAINFO 0x0002 132 # define TOUCHINPUTMASKF_CONTACTAREA 0x0004 133 134 typedef struct tagTOUCHINPUT 135 { 136 LONG x; 137 LONG y; 138 HANDLE hSource; 139 DWORD dwID; 120 140 DWORD dwFlags; 121 UINT uCount; 122 DWORD dwTimeout; 123 } FLASHWINFO, *PFLASHWINFO; 124 #define FLASHW_STOP 0 125 #define FLASHW_CAPTION 0x00000001 126 #define FLASHW_TRAY 0x00000002 127 #define FLASHW_ALL (FLASHW_CAPTION | FLASHW_TRAY) 128 #define FLASHW_TIMER 0x00000004 129 #define FLASHW_TIMERNOFG 0x0000000C 130 #endif /* FLASHW_STOP */ 131 typedef BOOL (WINAPI *PtrFlashWindowEx)(PFLASHWINFO pfwi); 132 static PtrFlashWindowEx pFlashWindowEx = 0; 141 DWORD dwMask; 142 DWORD dwTime; 143 ULONG_PTR dwExtraInfo; 144 DWORD cxContact; 145 DWORD cyContact; 146 } TOUCHINPUT, *PTOUCHINPUT; 147 148 #endif 133 149 134 150 #include <windowsx.h> … … 154 170 #endif 155 171 172 #ifndef IMR_RECONVERTSTRING 173 #define IMR_RECONVERTSTRING 4 174 #endif 175 176 #ifndef IMR_CONFIRMRECONVERTSTRING 177 #define IMR_CONFIRMRECONVERTSTRING 0x0005 178 #endif 156 179 QT_BEGIN_NAMESPACE 157 180 158 #ifdef Q_ OS_WINCE181 #ifdef Q_WS_WINCE 159 182 #ifndef SHRG_RETURNCMD 160 183 struct SHRGINFO { … … 199 222 #endif 200 223 201 bool qt_cleartype_enabled;224 Q_GUI_EXPORT bool qt_cleartype_enabled; 202 225 Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default 203 226 … … 221 244 HCTX qt_tablet_context; // the hardware context for the tablet (like a window handle) 222 245 bool qt_tablet_tilt_support; 223 static void tabletInit(UINT wActiveCsr, HCTX hTab); 246 247 #ifndef QT_NO_TABLETEVENT 248 static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab); 249 static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor); 224 250 static void initWinTabFunctions(); // resolve the WINTAB api functions 251 #endif // QT_NO_TABLETEVENT 225 252 226 253 … … 234 261 extern QRegion qt_dirtyRegion(QWidget *); 235 262 236 typedef QHash< UINT, QTabletDeviceData> QTabletCursorInfo;263 typedef QHash<quint64, QTabletDeviceData> QTabletCursorInfo; 237 264 Q_GLOBAL_STATIC(QTabletCursorInfo, tCursorInfo) 238 265 QTabletDeviceData currentTabletPointer; … … 240 267 // from qregion_win.cpp 241 268 extern HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom); 242 243 Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,244 UINT wMsgFilterMax, UINT wRemoveMsg);245 Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);246 269 247 270 // support for on-the-fly changes of the XP theme engine … … 259 282 #define WM_XBUTTONUP 0x020C 260 283 #define WM_XBUTTONDBLCLK 0x020D 284 #endif 285 #ifndef GET_KEYSTATE_WPARAM 261 286 #define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam)) 262 287 #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam)) 263 288 #define XBUTTON1 0x0001 264 289 #define XBUTTON2 0x0002 290 #endif 291 #ifndef MK_XBUTTON1 265 292 #define MK_XBUTTON1 0x0020 266 293 #define MK_XBUTTON2 0x0040 267 294 #endif 268 295 269 #ifdef Q_OS_WINCE 270 #define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam)) 271 #endif 272 273 // support for multi-media-keys on ME/2000/XP 296 // support for multi-media-keys 274 297 #ifndef WM_APPCOMMAND 275 298 #define WM_APPCOMMAND 0x0319 276 299 #endif 300 301 #ifndef FAPPCOMMAND_MOUSE 277 302 #define FAPPCOMMAND_MOUSE 0x8000 278 303 #define FAPPCOMMAND_KEY 0 … … 308 333 #define APPCOMMAND_TREBLE_DOWN 22 309 334 #define APPCOMMAND_TREBLE_UP 23 335 #endif // FAPPCOMMAND_MOUSE 310 336 311 337 // New commands from Windows XP (some even Sp1) … … 342 368 #endif // APPCOMMAND_MICROPHONE_VOLUME_MUTE 343 369 344 #endif // WM_APPCOMMAND345 346 static UINT WM95_MOUSEWHEEL = 0;347 348 370 #if (_WIN32_WINNT < 0x0400) 349 371 // This struct is defined in winuser.h if the _WIN32_WINNT >= 0x0400 -- in the … … 377 399 *****************************************************************************/ 378 400 379 extern Q_CORE_EXPORT char theAppName[];380 extern Q_CORE_EXPORT char appFileName[];381 extern Q_CORE_EXPORT HINSTANCE appInst; // handle to app instance382 extern Q_CORE_EXPORT HINSTANCE appPrevInst; // handle to prev app instance383 extern Q_CORE_EXPORT int appCmdShow; // main window show command384 401 static HWND curWin = 0; // current window 385 402 static HDC displayDC = 0; // display device context … … 422 439 #define __export 423 440 #endif 424 425 QApplicationPrivate* getQApplicationPrivateInternal()426 {427 return qApp->d_func();428 }429 441 430 442 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); … … 449 461 bool translateCloseEvent(const MSG &msg); 450 462 bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets); 463 bool translateGestureEvent(const MSG &msg, const GESTUREINFO &gi); 451 464 void repolishStyle(QStyle &style); 452 465 inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); } … … 498 511 QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHTTEXT)))); 499 512 500 #if defined(Q_ OS_WINCE)513 #if defined(Q_WS_WINCE) 501 514 // ### hardcoded until I find out how to get it from the system settings. 502 515 pal.setColor(QPalette::LinkVisited, pal.highlight().color().dark(150)); … … 517 530 pal.setColor(QPalette::Inactive, QPalette::Dark, pal.dark().color()); 518 531 519 if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95) { 520 if (pal.midlight() == pal.button()) 521 pal.setColor(QPalette::Midlight, pal.button().color().lighter(110)); 522 if (pal.background() != pal.base()) { 523 pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Inactive, QPalette::Window)); 524 pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Inactive, QPalette::Text)); 525 } 526 } 532 if (pal.midlight() == pal.button()) 533 pal.setColor(QPalette::Midlight, pal.button().color().lighter(110)); 534 if (pal.background() != pal.base()) { 535 pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Inactive, QPalette::Window)); 536 pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Inactive, QPalette::Text)); 537 } 538 527 539 const QColor bg = pal.background().color(); 528 540 const QColor fg = pal.foreground().color(), btn = pal.button().color(); … … 574 586 static void qt_set_windows_font_resources() 575 587 { 576 #ifndef Q_OS_WINCE 577 QFont menuFont; 578 QFont messageFont; 579 QFont statusFont; 580 QFont titleFont; 581 QFont iconTitleFont; 582 QT_WA({ 583 NONCLIENTMETRICS ncm; 584 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONTW); 585 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0); 586 menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont,true); 587 messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont,true); 588 statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont,true); 589 titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont,true); 590 LOGFONTW lfIconTitleFont; 591 SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0); 592 iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont,true); 593 } , { 594 // A version 595 NONCLIENTMETRICSA ncm; 596 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, lfMessageFont) + sizeof(LOGFONTA); 597 SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); 598 menuFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMenuFont,true); 599 messageFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMessageFont,true); 600 statusFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfStatusFont,true); 601 titleFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfCaptionFont,true); 602 LOGFONTA lfIconTitleFont; 603 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0); 604 iconTitleFont = qt_LOGFONTtoQFont((LOGFONT&)lfIconTitleFont,true); 605 }); 588 #ifndef Q_WS_WINCE 589 NONCLIENTMETRICS ncm; 590 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT); 591 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0); 592 593 QFont menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont, true); 594 QFont messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont, true); 595 QFont statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont, true); 596 QFont titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont, true); 597 598 LOGFONT lfIconTitleFont; 599 SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0); 600 QFont iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont, true); 606 601 607 602 QApplication::setFont(menuFont, "QMenu"); … … 625 620 smallerFont.setPointSize(systemFont.pointSize()-1); 626 621 QApplication::setFont(smallerFont, "QTabBar"); 627 } 628 #endif// Q_OS_WINCE 622 smallerFont.setBold(true); 623 QApplication::setFont(smallerFont, "QAbstractButton"); 624 } 625 #endif// Q_WS_WINCE 629 626 } 630 627 631 628 static void qt_win_read_cleartype_settings() 632 629 { 633 QT_WA({ 634 UINT result; 635 BOOL ok; 636 ok = SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0); 637 if (ok) 638 qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE); 639 }, { 640 UINT result; 641 BOOL ok; 642 ok = SystemParametersInfoA(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0); 643 if (ok) 644 qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE); 645 }); 630 UINT result = 0; 631 #ifdef Q_OS_WINCE 632 if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &result, 0)) 633 qt_cleartype_enabled = result; 634 #else 635 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0)) 636 qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE); 637 #endif 646 638 } 647 639 … … 660 652 QColor menuCol(qt_colorref2qrgb(GetSysColor(COLOR_MENU))); 661 653 QColor menuText(qt_colorref2qrgb(GetSysColor(COLOR_MENUTEXT))); 662 BOOL isFlat = 0;654 BOOL isFlat = false; 663 655 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP 664 656 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) 665 SystemParametersInfo( 0x1022 /*SPI_GETFLATMENU*/, 0, &isFlat, 0);657 SystemParametersInfo(SPI_GETFLATMENU, 0, &isFlat, 0); 666 658 QPalette menu(pal); 667 659 // we might need a special color group for the menu. … … 678 670 (QSysInfo::WindowsVersion >= QSysInfo::WV_XP 679 671 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based) 680 && isFlat ? COLOR_MENUHILIGHT 681 : COLOR_HIGHLIGHT)))); 672 && isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT)))); 682 673 menu.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled); 683 674 menu.setColor(QPalette::Disabled, QPalette::Button, … … 695 686 menu.setColor(QPalette::Inactive, QPalette::HighlightedText, 696 687 menu.color(QPalette::Active, QPalette::HighlightedText)); 697 698 if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95) 699 menu.setColor(QPalette::Inactive, QPalette::ButtonText, 700 pal.color(QPalette::Inactive, QPalette::Dark)); 688 menu.setColor(QPalette::Inactive, QPalette::ButtonText, 689 pal.color(QPalette::Inactive, QPalette::Dark)); 701 690 QApplication::setPalette(menu, "QMenu"); 702 691 … … 715 704 *****************************************************************************/ 716 705 717 typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst, 718 const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey, 719 const Q_BLENDFUNCTION *pblend, DWORD dwflags); 720 static PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0; 721 706 typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID); 707 static PtrSetProcessDPIAware ptrSetProcessDPIAware = 0; 708 PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0; 709 PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect = 0; 722 710 static BOOL WINAPI qt_updateLayeredWindowIndirect(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *info) 723 711 { … … 746 734 else 747 735 #endif // QT_DEBUG 748 if (qstrcmp(argv[i], "-direct3d") == 0)749 QApplication::setAttribute(Qt::AA_MSWindowsUseDirect3DByDefault);750 else751 736 argv[j++] = argv[i]; 752 737 } … … 756 741 } 757 742 758 // Get the application name/instance if qWinMain() was not invoked 759 #ifndef Q_OS_WINCE 743 #ifndef Q_WS_WINCE 760 744 // No message boxes but important ones 761 745 SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); 762 746 #endif 763 747 764 if (appInst == 0) { 765 QT_WA({ 766 appInst = GetModuleHandle(0); 767 }, { 768 appInst = GetModuleHandleA(0); 769 }); 770 } 771 772 #ifndef Q_OS_WINCE 748 #ifndef Q_WS_WINCE 773 749 // Initialize OLE/COM 774 750 // S_OK means success and S_FALSE means that it has already … … 782 758 783 759 // Misc. initialization 784 #if defined(QT_DEBUG) && !defined(Q_ OS_WINCE)760 #if defined(QT_DEBUG) && !defined(Q_WS_WINCE) 785 761 GdiSetBatchLimit(1); 786 762 #endif … … 794 770 QCursorData::initialize(); 795 771 #endif 796 qApp->setObjectName(QLatin1String(theAppName)); 797 798 #if !defined(Q_OS_WINCE) 772 qApp->setObjectName(priv->appName()); 773 799 774 // default font 800 HFONT hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); 801 QFont f(QLatin1String("MS Sans Serif"),8); 802 int result = 0; 803 QT_WA({ 804 LOGFONT lf; 805 if (result = GetObject(hfont, sizeof(lf), &lf)) 806 f = qt_LOGFONTtoQFont((LOGFONT&)lf,true); 807 } , { 808 LOGFONTA lf; 809 if (result = GetObjectA(hfont, sizeof(lf), &lf)) 810 f = qt_LOGFONTtoQFont((LOGFONT&)lf,true); 811 }); 812 if (result 813 && QSysInfo::WindowsVersion >= QSysInfo::WV_2000 814 && QSysInfo::WindowsVersion <= QSysInfo::WV_NT_based 815 && f.family() == QLatin1String("MS Shell Dlg")) 816 f.setFamily(QLatin1String("MS Shell Dlg 2")); 817 QApplicationPrivate::setSystemFont(f); 818 #else //Q_OS_WINCE 819 LOGFONT lf; 820 HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT); 821 int result = 0; 822 result = GetObject(stockFont, sizeof(lf), &lf); 823 QFont font = qt_LOGFONTtoQFont(lf, true); 824 if (result) 825 QApplicationPrivate::setSystemFont(font); 826 #endif //Q_OS_WINCE 775 #ifndef Q_WS_WINCE 776 HGDIOBJ stockFont = GetStockObject(DEFAULT_GUI_FONT); 777 #else 778 HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT); 779 #endif 780 781 LOGFONT lf; 782 GetObject(stockFont, sizeof(lf), &lf); 783 QFont systemFont = qt_LOGFONTtoQFont(lf, true); 784 785 #ifndef Q_WS_WINCE 786 if (systemFont.family() == QLatin1String("MS Shell Dlg")) { 787 systemFont.setFamily(QLatin1String("MS Shell Dlg 2")); 788 } 789 #endif 790 791 QApplicationPrivate::setSystemFont(systemFont); 827 792 828 793 // QFont::locale_init(); ### Uncomment when it does something on Windows … … 831 796 qt_set_windows_resources(); 832 797 833 QT_WA({ 834 WM95_MOUSEWHEEL = RegisterWindowMessage(L"MSWHEEL_ROLLMSG"); 835 } , { 836 WM95_MOUSEWHEEL = RegisterWindowMessageA("MSWHEEL_ROLLMSG"); 837 }); 798 #ifndef QT_NO_TABLETEVENT 838 799 initWinTabFunctions(); 800 #endif // QT_NO_TABLETEVENT 839 801 QApplicationPrivate::inputContext = new QWinInputContext(0); 840 802 … … 856 818 if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect) 857 819 ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect; 820 821 // Notify Vista and Windows 7 that we support highter DPI settings 822 ptrSetProcessDPIAware = (PtrSetProcessDPIAware) 823 QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware"); 824 if (ptrSetProcessDPIAware) 825 ptrSetProcessDPIAware(); 826 #endif 827 828 priv->GetGestureInfo = 0; 829 priv->GetGestureExtraArgs = 0; 830 priv->CloseGestureInfoHandle = 0; 831 priv->SetGestureConfig = 0; 832 priv->GetGestureConfig = 0; 833 priv->BeginPanningFeedback = 0; 834 priv->UpdatePanningFeedback = 0; 835 priv->EndPanningFeedback = 0; 836 837 #if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES) 838 priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo; 839 priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments; 840 #elif !defined(Q_WS_WINCE) 841 #if !defined(QT_NO_NATIVE_GESTURES) 842 priv->GetGestureInfo = 843 (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"), 844 "GetGestureInfo"); 845 priv->GetGestureExtraArgs = 846 (PtrGetGestureExtraArgs)QLibrary::resolve(QLatin1String("user32"), 847 "GetGestureExtraArgs"); 848 priv->CloseGestureInfoHandle = 849 (PtrCloseGestureInfoHandle)QLibrary::resolve(QLatin1String("user32"), 850 "CloseGestureInfoHandle"); 851 priv->SetGestureConfig = 852 (PtrSetGestureConfig)QLibrary::resolve(QLatin1String("user32"), 853 "SetGestureConfig"); 854 priv->GetGestureConfig = 855 (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"), 856 "GetGestureConfig"); 857 #endif // QT_NO_NATIVE_GESTURES 858 priv->BeginPanningFeedback = 859 (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), 860 "BeginPanningFeedback"); 861 priv->UpdatePanningFeedback = 862 (PtrUpdatePanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), 863 "UpdatePanningFeedback"); 864 priv->EndPanningFeedback = 865 (PtrEndPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), 866 "EndPanningFeedback"); 858 867 #endif 859 868 } … … 881 890 QApplicationPrivate::inputContext = 0; 882 891 883 #ifndef Q_ OS_WINCE892 #ifndef Q_WS_WINCE 884 893 // Deinitialize OLE/COM 885 894 OleUninitialize(); … … 891 900 Platform specific global and internal functions 892 901 *****************************************************************************/ 893 894 Q_GUI_EXPORT int qWinAppCmdShow() // get main window show command895 {896 return appCmdShow;897 }898 899 902 900 903 Q_GUI_EXPORT HDC qt_win_display_dc() // get display DC … … 929 932 cname = QLatin1String("QWidgetOwnDC"); 930 933 style = CS_DBLCLKS; 931 #ifndef Q_ OS_WINCE934 #ifndef Q_WS_WINCE 932 935 style |= CS_OWNDC; 933 936 #endif … … 938 941 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP 939 942 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) { 940 style |= 0x00020000; // CS_DROPSHADOW943 style |= CS_DROPSHADOW; 941 944 } 942 945 cname = QLatin1String("QToolTip"); … … 944 947 cname = QLatin1String("QTool"); 945 948 } 946 #ifndef Q_ OS_WINCE949 #ifndef Q_WS_WINCE 947 950 style |= CS_SAVEBITS; 948 951 #endif … … 951 954 cname = QLatin1String("QPopup"); 952 955 style = CS_DBLCLKS; 953 #ifndef Q_ OS_WINCE956 #ifndef Q_WS_WINCE 954 957 style |= CS_SAVEBITS; 955 958 #endif 956 959 if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP 957 960 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) 958 style |= 0x00020000; // CS_DROPSHADOW961 style |= CS_DROPSHADOW; 959 962 icon = false; 960 963 } else { … … 964 967 } 965 968 966 #ifndef Q_ OS_WINCE969 #ifndef Q_WS_WINCE 967 970 // force CS_OWNDC when the GL graphics system is 968 971 // used as the default renderer … … 976 979 // move the windows to the front when starting 977 980 // a second instance. 978 wchar_t uniqueAppID[ 256];979 GetModuleFileName W(0, uniqueAppID, 255);980 cname = QString::number(RegisterWindowMessage W(981 (const wchar_t *) QString::from Utf16((const ushort *)uniqueAppID).toLower().replace(QString(QString::fromLatin1("\\")),982 Q String(QString::fromLatin1("_"))).utf16()));981 wchar_t uniqueAppID[MAX_PATH]; 982 GetModuleFileName(0, uniqueAppID, MAX_PATH); 983 cname = QString::number(RegisterWindowMessage( 984 (const wchar_t *) QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1Char('\\'), 985 QLatin1Char('_')).utf16())); 983 986 #endif 984 987 … … 991 994 992 995 if (classExists == -1) { 993 QT_WA({ 994 WNDCLASS wcinfo; 995 classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo); 996 classExists = classExists && wcinfo.lpfnWndProc != QtWndProc; 997 }, { 998 WNDCLASSA wcinfo; 999 classExists = GetClassInfoA((HINSTANCE)qWinAppInst(), cname.toLatin1(), &wcinfo); 1000 classExists = classExists && wcinfo.lpfnWndProc != QtWndProc; 1001 }); 996 WNDCLASS wcinfo; 997 classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (wchar_t*)cname.utf16(), &wcinfo); 998 classExists = classExists && wcinfo.lpfnWndProc != QtWndProc; 1002 999 } 1003 1000 … … 1008 1005 return cname; 1009 1006 1010 ATOM atom; 1011 #ifndef Q_OS_WINCE 1012 HBRUSH bgBrush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); 1013 QT_WA({ 1014 WNDCLASS wc; 1015 wc.style = style; 1016 wc.lpfnWndProc = (WNDPROC)QtWndProc; 1017 wc.cbClsExtra = 0; 1018 wc.cbWndExtra = 0; 1019 wc.hInstance = (HINSTANCE)qWinAppInst(); 1020 if (icon) { 1021 wc.hIcon = LoadIcon(appInst, L"IDI_ICON1"); 1022 if (!wc.hIcon) 1023 wc.hIcon = LoadIcon(0, IDI_APPLICATION); 1024 } else { 1025 wc.hIcon = 0; 1026 } 1027 wc.hCursor = 0; 1028 wc.hbrBackground= bgBrush; 1029 wc.lpszMenuName = 0; 1030 wc.lpszClassName= (TCHAR*)cname.utf16(); 1031 atom = RegisterClass(&wc); 1032 } , { 1033 WNDCLASSA wc; 1034 wc.style = style; 1035 wc.lpfnWndProc = (WNDPROC)QtWndProc; 1036 wc.cbClsExtra = 0; 1037 wc.cbWndExtra = 0; 1038 wc.hInstance = (HINSTANCE)qWinAppInst(); 1039 if (icon) { 1040 wc.hIcon = LoadIconA(appInst, (char*)"IDI_ICON1"); 1041 if (!wc.hIcon) 1042 wc.hIcon = LoadIconA(0, (char*)IDI_APPLICATION); 1043 } else { 1044 wc.hIcon = 0; 1045 } 1046 wc.hCursor = 0; 1047 wc.hbrBackground= bgBrush; 1048 wc.lpszMenuName = 0; 1049 QByteArray tempArray = cname.toLatin1(); 1050 wc.lpszClassName= tempArray; 1051 atom = RegisterClassA(&wc); 1052 }); 1007 WNDCLASS wc; 1008 wc.style = style; 1009 wc.lpfnWndProc = (WNDPROC)QtWndProc; 1010 wc.cbClsExtra = 0; 1011 wc.cbWndExtra = 0; 1012 wc.hInstance = qWinAppInst(); 1013 if (icon) { 1014 wc.hIcon = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); 1015 #ifndef Q_WS_WINCE 1016 if (!wc.hIcon) 1017 wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); 1018 #endif 1019 } else { 1020 wc.hIcon = 0; 1021 } 1022 wc.hCursor = 0; 1023 #ifndef Q_WS_WINCE 1024 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); 1053 1025 #else 1054 WNDCLASS wc; 1055 wc.style = style; 1056 wc.lpfnWndProc = (WNDPROC)QtWndProc; 1057 wc.cbClsExtra = 0; 1058 wc.cbWndExtra = 0; 1059 wc.hInstance = (HINSTANCE)qWinAppInst(); 1060 if (icon) { 1061 wc.hIcon = LoadIcon(appInst, L"IDI_ICON1"); 1062 // if (!wc.hIcon) 1063 // wc.hIcon = LoadIcon(0, IDI_APPLICATION); 1064 } else { 1065 wc.hIcon = 0; 1066 } 1067 wc.hCursor = 0; 1068 wc.hbrBackground= 0; 1069 wc.lpszMenuName = 0; 1070 wc.lpszClassName= (TCHAR*)cname.utf16(); 1071 atom = RegisterClass(&wc); 1072 #endif 1026 wc.hbrBackground = 0; 1027 #endif 1028 wc.lpszMenuName = 0; 1029 wc.lpszClassName = (wchar_t*)cname.utf16(); 1030 1031 ATOM atom = RegisterClass(&wc); 1073 1032 1074 1033 #ifndef QT_NO_DEBUG 1075 1034 if (!atom) 1076 1035 qErrnoWarning("QApplication::regClass: Registering window class failed."); 1036 #else 1037 Q_UNUSED(atom); 1077 1038 #endif 1078 1039 … … 1092 1053 QHash<QString, int>::ConstIterator it = hash->constBegin(); 1093 1054 while (it != hash->constEnd()) { 1094 QT_WA({ 1095 UnregisterClass((TCHAR*)it.key().utf16(), (HINSTANCE)qWinAppInst()); 1096 } , { 1097 UnregisterClassA(it.key().toLatin1(), (HINSTANCE)qWinAppInst()); 1098 }); 1055 UnregisterClass((wchar_t*)it.key().utf16(), qWinAppInst()); 1099 1056 ++it; 1100 1057 } … … 1130 1087 } 1131 1088 1132 Q_GUI_EXPORTvoid qWinProcessConfigRequests() // perform requests in queue1089 static void qWinProcessConfigRequests() // perform requests in queue 1133 1090 { 1134 1091 if (!configRequests) … … 1313 1270 static void alert_widget(QWidget *widget, int duration) 1314 1271 { 1272 #ifdef Q_OS_WINCE 1273 Q_UNUSED(widget); 1274 Q_UNUSED(duration); 1275 #else 1315 1276 bool stopFlash = duration < 0; 1316 1277 1317 if (!pFlashWindowEx) { 1318 #ifndef Q_OS_WINCE 1319 QLibrary themeLib(QLatin1String("user32")); 1320 pFlashWindowEx = (PtrFlashWindowEx)themeLib.resolve("FlashWindowEx"); 1321 #endif 1322 } 1323 1324 if (pFlashWindowEx && widget && (!widget->isActiveWindow() || stopFlash)) { 1278 if (widget && (!widget->isActiveWindow() || stopFlash)) { 1325 1279 DWORD timeOut = GetCaretBlinkTime(); 1326 1280 if (timeOut <= 0) … … 1340 1294 info.uCount = stopFlash ? 0 : flashCount; 1341 1295 1342 pFlashWindowEx(&info); 1343 } 1296 FlashWindowEx(&info); 1297 } 1298 #endif 1344 1299 } 1345 1300 … … 1372 1327 extern uint qGlobalPostedEventsCount(); 1373 1328 1374 /*!1375 \internal1376 \since 4.11377 1378 If \a gotFocus is true, \a widget will become the active window.1379 Otherwise the active window is reset to 0.1380 */1381 1329 void QApplication::winFocus(QWidget *widget, bool gotFocus) 1382 1330 { … … 1389 1337 // raise the entire application, not just the dialog 1390 1338 QWidget* mw = QApplicationPrivate::active_window; 1391 #ifndef Q_ OS_WINCE1339 #ifndef Q_WS_WINCE 1392 1340 while(mw->parentWidget() && (mw->windowType() == Qt::Dialog)) 1393 1341 mw = mw->parentWidget()->window(); … … 1436 1384 static bool qt_is_translatable_mouse_event(UINT message) 1437 1385 { 1438 return ( message >= WM_MOUSEFIRST && message <= WM_MOUSELAST||1439 message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)1386 return (((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) || 1387 (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)) 1440 1388 && message != WM_MOUSEWHEEL 1441 1442 #ifndef Q_OS_WINCE 1443 || message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK 1389 && message != WM_MOUSEHWHEEL) 1390 1391 #ifndef Q_WS_WINCE 1392 || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK) 1444 1393 #endif 1445 1394 ; … … 1480 1429 // If it's a non-client-area message the coords are screen coords, otherwise they are 1481 1430 // client coords. 1482 #ifndef Q_ OS_WINCE1431 #ifndef Q_WS_WINCE 1483 1432 if (message < WM_NCMOUSEMOVE || message > WM_NCMBUTTONDBLCLK) 1484 1433 #endif … … 1510 1459 && (message == WM_MBUTTONDOWN || message == WM_XBUTTONDOWN 1511 1460 || message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN 1512 #ifndef Q_ OS_WINCE1461 #ifndef Q_WS_WINCE 1513 1462 || message == WM_NCMBUTTONDOWN || message == WM_NCLBUTTONDOWN 1514 1463 || message == WM_NCRBUTTONDOWN)) { … … 1520 1469 1521 1470 switch (message) { 1522 #ifndef Q_ OS_WINCE1471 #ifndef Q_WS_WINCE 1523 1472 case WM_QUERYENDSESSION: { 1524 1473 if (sm_smActive) // bogus message from windows … … 1542 1491 // we receive the message for each toplevel window included internal hidden ones, 1543 1492 // but the aboutToQuit signal should be emitted only once. 1544 QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();1493 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); 1545 1494 if (endsession && !qAppPriv->aboutToQuitEmitted) { 1546 1495 qAppPriv->aboutToQuitEmitted = true; … … 1548 1497 qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0); 1549 1498 // since the process will be killed immediately quit() has no real effect 1550 qApp->quit();1499 QApplication::quit(); 1551 1500 } 1552 1501 … … 1554 1503 } 1555 1504 case WM_DISPLAYCHANGE: 1556 if ( qApp->type() == QApplication::Tty)1505 if (QApplication::type() == QApplication::Tty) 1557 1506 break; 1558 1507 if (qt_desktopWidget) { … … 1571 1520 1572 1521 case WM_SETTINGCHANGE: 1573 #ifdef Q_ OS_WINCE1522 #ifdef Q_WS_WINCE 1574 1523 // CE SIP hide/show 1575 1524 if (wParam == SPI_SETSIPINFO) { … … 1580 1529 #endif 1581 1530 // ignore spurious XP message when user logs in again after locking 1582 if ( qApp->type() == QApplication::Tty)1531 if (QApplication::type() == QApplication::Tty) 1583 1532 break; 1584 1533 if (QApplication::desktopSettingsAware() && wParam != SPI_SETWORKAREA) { … … 1603 1552 if (wParam == SPI_SETFONTSMOOTHINGTYPE) { 1604 1553 qt_win_read_cleartype_settings(); 1605 foreach (QWidget *w, qApp->topLevelWidgets()) {1554 foreach (QWidget *w, QApplication::topLevelWidgets()) { 1606 1555 if (!w->isVisible()) 1607 1556 continue; … … 1612 1561 break; 1613 1562 case WM_SYSCOLORCHANGE: 1614 if ( qApp->type() == QApplication::Tty)1563 if (QApplication::type() == QApplication::Tty) 1615 1564 break; 1616 1565 if (QApplication::desktopSettingsAware()) { … … 1664 1613 1665 1614 if (qt_is_translatable_mouse_event(message)) { 1666 if ( qApp->activePopupWidget() != 0) { // in popup mode1615 if (QApplication::activePopupWidget() != 0) { // in popup mode 1667 1616 POINT curPos = msg.pt; 1668 1617 QWidget* w = QApplication::widgetAt(curPos.x, curPos.y); … … 1673 1622 if (!qt_tabletChokeMouse) { 1674 1623 result = widget->translateMouseEvent(msg); // mouse event 1675 #if defined(Q_ OS_WINCE) && !defined(QT_NO_CONTEXTMENU)1676 if (message == WM_LBUTTONDOWN && widget != qApp->activePopupWidget()) {1624 #if defined(Q_WS_WINCE) && !defined(QT_NO_CONTEXTMENU) 1625 if (message == WM_LBUTTONDOWN && widget != QApplication::activePopupWidget()) { 1677 1626 QWidget* alienWidget = widget; 1678 if ((alienWidget != qApp->activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) {1627 if ((alienWidget != QApplication::activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) { 1679 1628 QPoint pos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); 1680 1629 QPoint globalPos(msg.pt.x, msg.pt.y); … … 1683 1632 if (!alienWidget->testAttribute(Qt::WA_NativeWindow) && !alienWidget->testAttribute(Qt::WA_PaintOnScreen)) { 1684 1633 alienWidget = QApplication::widgetAt(globalPos); 1685 pos = alienWidget->mapFromGlobal(globalPos); 1634 if (alienWidget) 1635 pos = alienWidget->mapFromGlobal(globalPos); 1686 1636 } 1687 SHRGINFO shrg; 1688 shrg.cbSize = sizeof(shrg); 1689 shrg.hwndClient = hwnd; 1690 shrg.ptDown.x = GET_X_LPARAM(lParam); 1691 shrg.ptDown.y = GET_Y_LPARAM(lParam); 1692 shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION; 1693 resolveAygLibs(); 1694 if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) { 1695 if (qApp->activePopupWidget()) 1696 qApp->activePopupWidget()->close(); 1697 QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos); 1698 result = qt_sendSpontaneousEvent(alienWidget, &e); 1637 if (alienWidget) { 1638 SHRGINFO shrg; 1639 shrg.cbSize = sizeof(shrg); 1640 shrg.hwndClient = hwnd; 1641 shrg.ptDown.x = GET_X_LPARAM(lParam); 1642 shrg.ptDown.y = GET_Y_LPARAM(lParam); 1643 shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION; 1644 resolveAygLibs(); 1645 if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) { 1646 if (QApplication::activePopupWidget()) 1647 QApplication::activePopupWidget()->close(); 1648 QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos); 1649 result = qt_sendSpontaneousEvent(alienWidget, &e); 1650 } 1699 1651 } 1700 1652 } … … 1705 1657 // and sometimes we get both a WM_MOUSEMOVE and 1706 1658 // a WM_LBUTTONDOWN/UP, this creates a spurious mouse 1707 // press/release event, using the winPeekMessage1659 // press/release event, using the PeekMessage 1708 1660 // will help us fix this. This leaves us with a 1709 1661 // question: … … 1715 1667 if (is_mouse_move) { 1716 1668 MSG msg1; 1717 if ( winPeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,1718 1669 if (PeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST, 1670 WM_MOUSELAST, PM_NOREMOVE)) 1719 1671 next_is_button = (msg1.message == WM_LBUTTONUP 1720 1672 || msg1.message == WM_LBUTTONDOWN); … … 1723 1675 qt_tabletChokeMouse = false; 1724 1676 } 1725 } else if (message == WM95_MOUSEWHEEL) {1726 result = widget->translateWheelEvent(msg);1727 1677 } else { 1728 1678 switch (message) { 1679 case WM_TOUCH: 1680 result = QApplicationPrivate::instance()->translateTouchEvent(msg); 1681 break; 1729 1682 case WM_KEYDOWN: // keyboard event 1730 1683 case WM_SYSKEYDOWN: … … 1733 1686 case WM_KEYUP: 1734 1687 case WM_SYSKEYUP: 1688 #if Q_OS_WINCE_WM 1689 case WM_HOTKEY: 1690 if(HIWORD(msg.lParam) == VK_TBACK) { 1691 const bool hotKeyDown = !(LOWORD(msg.lParam) & MOD_KEYUP); 1692 msg.lParam = 0x69 << 16; 1693 msg.wParam = VK_BACK; 1694 if (hotKeyDown) { 1695 msg.message = WM_KEYDOWN; 1696 qt_keymapper_private()->updateKeyMap(msg); 1697 } else { 1698 msg.message = WM_KEYUP; 1699 } 1700 } 1701 // fall-through intended 1702 #endif 1735 1703 case WM_IME_CHAR: 1736 1704 case WM_IME_KEYDOWN: 1737 1705 case WM_CHAR: { 1738 1706 MSG msg1; 1739 bool anyMsg = winPeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);1707 bool anyMsg = PeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE); 1740 1708 if (anyMsg && msg1.message == WM_DEADCHAR) { 1741 1709 result = true; // consume event since there is a dead char next … … 1756 1724 ? (QETWidget*)QApplication::activePopupWidget()->focusWidget() 1757 1725 : (QETWidget*)QApplication::activePopupWidget(); 1758 else if ( qApp->focusWidget())1726 else if (QApplication::focusWidget()) 1759 1727 widget = (QETWidget*)QApplication::focusWidget(); 1760 1728 else if (!widget || widget->internalWinId() == GetFocus()) // We faked the message to go to exactly that widget. … … 1771 1739 1772 1740 case WM_MOUSEWHEEL: 1741 case WM_MOUSEHWHEEL: 1773 1742 result = widget->translateWheelEvent(msg); 1774 1743 break; … … 1797 1766 key = Qt::Key_BassUp; 1798 1767 break; 1799 case APPCOMMAND_BROWSER_BACKWARD:1800 key = Qt::Key_Back;1801 break;1802 case APPCOMMAND_BROWSER_FAVORITES:1803 key = Qt::Key_Favorites;1804 break;1805 case APPCOMMAND_BROWSER_FORWARD:1806 key = Qt::Key_Forward;1807 break;1808 case APPCOMMAND_BROWSER_HOME:1809 key = Qt::Key_HomePage;1810 break;1811 case APPCOMMAND_BROWSER_REFRESH:1812 key = Qt::Key_Refresh;1813 break;1814 case APPCOMMAND_BROWSER_SEARCH:1815 key = Qt::Key_Search;1816 break;1817 case APPCOMMAND_BROWSER_STOP:1818 key = Qt::Key_Stop;1819 break;1820 case APPCOMMAND_LAUNCH_APP1:1821 key = Qt::Key_Launch0;1822 break;1823 case APPCOMMAND_LAUNCH_APP2:1824 key = Qt::Key_Launch1;1825 break;1826 case APPCOMMAND_LAUNCH_MAIL:1827 key = Qt::Key_LaunchMail;1828 break;1829 case APPCOMMAND_LAUNCH_MEDIA_SELECT:1830 key = Qt::Key_LaunchMedia;1831 break;1832 case APPCOMMAND_MEDIA_NEXTTRACK:1833 key = Qt::Key_MediaNext;1834 break;1835 case APPCOMMAND_MEDIA_PLAY_PAUSE:1836 key = Qt::Key_MediaPlay;1837 break;1838 case APPCOMMAND_MEDIA_PREVIOUSTRACK:1839 key = Qt::Key_MediaPrevious;1840 break;1841 case APPCOMMAND_MEDIA_STOP:1842 key = Qt::Key_MediaStop;1843 break;1844 1768 case APPCOMMAND_TREBLE_DOWN: 1845 1769 key = Qt::Key_TrebleDown; … … 1848 1772 key = Qt::Key_TrebleUp; 1849 1773 break; 1850 case APPCOMMAND_VOLUME_DOWN:1851 key = Qt::Key_VolumeDown;1852 break;1853 case APPCOMMAND_VOLUME_MUTE:1854 key = Qt::Key_VolumeMute;1855 break;1856 case APPCOMMAND_VOLUME_UP:1857 key = Qt::Key_VolumeUp;1858 break;1859 // Commands new in Windows XP1860 1774 case APPCOMMAND_HELP: 1861 1775 key = Qt::Key_Help; … … 1863 1777 case APPCOMMAND_FIND: 1864 1778 key = Qt::Key_Search; 1865 break;1866 case APPCOMMAND_PRINT:1867 key = Qt::Key_Print;1868 break;1869 case APPCOMMAND_MEDIA_PLAY:1870 key = Qt::Key_MediaPlay;1871 1779 break; 1872 1780 default: … … 1878 1786 if (g) 1879 1787 widget = (QETWidget*)g; 1880 else if ( qApp->focusWidget())1881 widget = (QETWidget*) qApp->focusWidget();1788 else if (QApplication::focusWidget()) 1789 widget = (QETWidget*)QApplication::focusWidget(); 1882 1790 else 1883 1791 widget = (QETWidget*)widget->window(); … … 1901 1809 break; 1902 1810 1903 #ifndef Q_ OS_WINCE1811 #ifndef Q_WS_WINCE 1904 1812 case WM_NCHITTEST: 1905 1813 if (widget->isWindow()) { … … 1908 1816 QRect fs = widget->frameStrut(); 1909 1817 if (!widget->isMinimized()) { 1818 if (widget->minimumHeight() == widget->maximumHeight()) { 1819 if (pos.y() < -(fs.top() - fs.left())) 1820 return HTCAPTION; 1821 if (pos.y() >= widget->height()) 1822 return HTBORDER; 1823 } 1910 1824 if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width())) 1911 break; 1912 if (widget->minimumHeight() == widget->maximumHeight() && (pos.y() < -(fs.top() - fs.left()) || pos.y() >= widget->height())) 1913 break; 1825 return HTBORDER; 1914 1826 } 1915 1827 } … … 1920 1832 1921 1833 case WM_SYSCOMMAND: { 1922 #ifndef Q_ OS_WINCE1834 #ifndef Q_WS_WINCE 1923 1835 bool window_state_change = false; 1924 1836 Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state); … … 1932 1844 QWhatsThis::enterWhatsThisMode(); 1933 1845 #endif 1934 QT_WA({ 1935 DefWindowProc(hwnd, WM_NCPAINT, 1, 0); 1936 } , { 1937 DefWindowProcA(hwnd, WM_NCPAINT, 1, 0); 1938 }); 1846 DefWindowProc(hwnd, WM_NCPAINT, 1, 0); 1939 1847 break; 1940 1848 #if defined(QT_NON_COMMERCIAL) … … 1948 1856 qt_sendSpontaneousEvent(widget, &e); 1949 1857 widget->hideChildren(true); 1950 #ifndef Q_OS_WINCE1951 1858 const QString title = widget->windowIconText(); 1952 1859 if (!title.isEmpty()) 1953 1860 widget->setWindowTitle_helper(title); 1954 #endif1955 1861 } 1956 1862 result = false; … … 1971 1877 QShowEvent e; 1972 1878 qt_sendSpontaneousEvent(widget, &e); 1973 #ifndef Q_OS_WINCE1974 1879 const QString title = widget->windowTitle(); 1975 1880 if (!title.isEmpty()) 1976 1881 widget->setWindowTitle_helper(title); 1977 #endif1978 1882 } 1979 1883 result = false; … … 1988 1892 qt_sendSpontaneousEvent(widget, &e); 1989 1893 } 1990 #endif 1894 #endif // #ifndef Q_OS_WINCE 1991 1895 1992 1896 break; … … 1994 1898 1995 1899 case WM_SETTINGCHANGE: 1996 if ( qApp->type() == QApplication::Tty )1900 if ( QApplication::type() == QApplication::Tty ) 1997 1901 break; 1998 1902 1999 1903 if (!msg.wParam) { 2000 QString area = QT_WA_INLINE(QString::fromUtf16((unsigned short *)msg.lParam), 2001 QString::fromLocal8Bit((char*)msg.lParam)); 1904 QString area = QString::fromWCharArray((wchar_t*)msg.lParam); 2002 1905 if (area == QLatin1String("intl")) { 2003 1906 QLocalePrivate::updateSystemPrivate(); … … 2007 1910 } 2008 1911 else if (msg.wParam == SPI_SETICONTITLELOGFONT) { 2009 if ( qApp->desktopSettingsAware()) {1912 if (QApplication::desktopSettingsAware()) { 2010 1913 widget = (QETWidget*)QWidget::find(hwnd); 2011 1914 if (widget && !widget->parentWidget()) { … … 2021 1924 break; 2022 1925 2023 #ifndef Q_ OS_WINCE1926 #ifndef Q_WS_WINCE 2024 1927 case WM_ENTERSIZEMOVE: 2025 1928 autoCaptureWnd = hwnd; 2026 QApplicationPrivate::inSizeMove = true;2027 1929 break; 2028 1930 case WM_EXITSIZEMOVE: 2029 1931 autoCaptureWnd = 0; 2030 QApplicationPrivate::inSizeMove = false;2031 1932 break; 2032 1933 #endif … … 2050 1951 2051 1952 case WM_ACTIVATE: 2052 if ( qApp->type() == QApplication::Tty )1953 if ( QApplication::type() == QApplication::Tty ) 2053 1954 break; 2054 1955 … … 2076 1977 // loses focus. Doing it here would result in the widget getting focus to not know 2077 1978 // where it got it from; it would simply get a 0 value as the old focus widget. 1979 #ifdef Q_WS_WINCE 1980 { 1981 #ifdef Q_WS_WINCE_WM 1982 // On Windows mobile we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages. 1983 // Thus we have to unset the minimized state explicitly. We must do this for all 1984 // top-level widgets, because we get the HWND of a random widget here. 1985 foreach (QWidget* tlw, QApplication::topLevelWidgets()) { 1986 if (tlw->isMinimized()) 1987 tlw->setWindowState(tlw->windowState() & ~Qt::WindowMinimized); 1988 } 1989 #else 1990 // On Windows CE we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages. 1991 // Thus we have to unset the minimized state explicitly. 1992 if (widget->windowState() & Qt::WindowMinimized) 1993 widget->setWindowState(widget->windowState() & ~Qt::WindowMinimized); 1994 #endif // Q_WS_WINCE_WM 1995 1996 #else 2078 1997 if (!(widget->windowState() & Qt::WindowMinimized)) { 1998 #endif 2079 1999 // Ignore the activate message send by WindowsXP to a minimized window 2080 #ifdef Q_ OS_WINCE_WM2000 #ifdef Q_WS_WINCE_WM 2081 2001 if (widget->windowState() & Qt::WindowFullScreen) 2082 2002 qt_wince_hide_taskbar(widget->winId()); … … 2105 2025 break; 2106 2026 2107 #ifndef Q_ OS_WINCE2027 #ifndef Q_WS_WINCE 2108 2028 case WM_MOUSEACTIVATE: 2109 2029 if (widget->window()->windowType() == Qt::Tool) { … … 2194 2114 break; 2195 2115 2196 #ifndef Q_ OS_WINCE2116 #ifndef Q_WS_WINCE 2197 2117 case WM_WINDOWPOSCHANGING: 2198 2118 { … … 2275 2195 QWidget *fw = QWidget::keyboardGrabber(); 2276 2196 if (!fw) { 2277 if ( qApp->activePopupWidget())2278 fw = ( qApp->activePopupWidget()->focusWidget()2279 ? qApp->activePopupWidget()->focusWidget()2280 : qApp->activePopupWidget());2281 else if ( qApp->focusWidget())2282 fw = qApp->focusWidget();2197 if (QApplication::activePopupWidget()) 2198 fw = (QApplication::activePopupWidget()->focusWidget() 2199 ? QApplication::activePopupWidget()->focusWidget() 2200 : QApplication::activePopupWidget()); 2201 else if (QApplication::focusWidget()) 2202 fw = QApplication::focusWidget(); 2283 2203 else if (widget) 2284 2204 fw = widget->window(); … … 2297 2217 case WM_IME_ENDCOMPOSITION: 2298 2218 case WM_IME_COMPOSITION: { 2299 QWidget *fw = qApp->focusWidget();2219 QWidget *fw = QApplication::focusWidget(); 2300 2220 QWinInputContext *im = fw ? qobject_cast<QWinInputContext *>(fw->inputContext()) : 0; 2301 2221 if (fw && im) { … … 2309 2229 break; 2310 2230 } 2311 2312 #ifndef Q_OS_WINCE 2231 case WM_IME_REQUEST: { 2232 QWidget *fw = QApplication::focusWidget(); 2233 QWinInputContext *im = fw ? qobject_cast<QWinInputContext *>(fw->inputContext()) : 0; 2234 if (fw && im) { 2235 if(wParam == IMR_RECONVERTSTRING) { 2236 int ret = im->reconvertString((RECONVERTSTRING *)lParam); 2237 if (ret == -1) { 2238 result = false; 2239 } else { 2240 return ret; 2241 } 2242 } else if (wParam == IMR_CONFIRMRECONVERTSTRING) { 2243 RETURN(TRUE); 2244 } else { 2245 // in all other cases, call DefWindowProc() 2246 result = false; 2247 } 2248 } 2249 break; 2250 } 2251 #ifndef Q_WS_WINCE 2313 2252 case WM_CHANGECBCHAIN: 2314 2253 case WM_DRAWCLIPBOARD: … … 2330 2269 { 2331 2270 // Ignoring all requests while starting up 2332 if ( qApp->startingUp() || qApp->closingDown() || (DWORD)lParam != OBJID_CLIENT) {2271 if (QApplication::startingUp() || QApplication::closingDown() || (DWORD)lParam != OBJID_CLIENT) { 2333 2272 result = false; 2334 2273 break; … … 2373 2312 ret = qMin<int>(wParam - 1, text.size()); 2374 2313 text.resize(ret); 2375 QT_WA({ 2376 memcpy((void *)lParam, text.utf16(), (text.size() + 1) * 2); 2377 }, { 2378 memcpy((void *)lParam, text.toLocal8Bit().data(), text.size() + 1); 2379 }); 2314 memcpy((void *)lParam, text.utf16(), (text.size() + 1) * sizeof(ushort)); 2380 2315 delete acc; 2381 2316 } … … 2397 2332 break; 2398 2333 case WT_PROXIMITY: 2399 if (ptrWTPacketsGet) { 2400 bool enteredProximity = LOWORD(lParam) != 0; 2401 PACKET proximityBuffer[QT_TABLET_NPACKETQSIZE]; 2402 int totalPacks = ptrWTPacketsGet(qt_tablet_context, QT_TABLET_NPACKETQSIZE, proximityBuffer); 2403 if (totalPacks > 0 && enteredProximity) { 2404 uint currentCursor = proximityBuffer[0].pkCursor; 2405 if (!tCursorInfo()->contains(currentCursor)) 2406 tabletInit(currentCursor, qt_tablet_context); 2407 currentTabletPointer = tCursorInfo()->value(currentCursor); 2334 2335 #ifndef QT_NO_TABLETEVENT 2336 if (ptrWTPacketsGet && ptrWTInfo) { 2337 const bool enteredProximity = LOWORD(lParam) != 0; 2338 PACKET proximityBuffer[1]; // we are only interested in the first packet in this case 2339 const int totalPacks = ptrWTPacketsGet(qt_tablet_context, 1, proximityBuffer); 2340 if (totalPacks > 0) { 2341 const UINT currentCursor = proximityBuffer[0].pkCursor; 2342 2343 UINT csr_physid; 2344 ptrWTInfo(WTI_CURSORS + currentCursor, CSR_PHYSID, &csr_physid); 2345 UINT csr_type; 2346 ptrWTInfo(WTI_CURSORS + currentCursor, CSR_TYPE, &csr_type); 2347 const UINT deviceIdMask = 0xFF6; // device type mask && device color mask 2348 quint64 uniqueId = (csr_type & deviceIdMask); 2349 uniqueId = (uniqueId << 32) | csr_physid; 2350 2351 // initialising and updating the cursor should be done in response to 2352 // WT_CSRCHANGE. We do it in WT_PROXIMITY because some wintab never send 2353 // the event WT_CSRCHANGE even if asked with CXO_CSRMESSAGES 2354 const QTabletCursorInfo *const globalCursorInfo = tCursorInfo(); 2355 if (!globalCursorInfo->contains(uniqueId)) 2356 tabletInit(uniqueId, csr_type, qt_tablet_context); 2357 2358 currentTabletPointer = globalCursorInfo->value(uniqueId); 2359 tabletUpdateCursor(currentTabletPointer, currentCursor); 2408 2360 } 2409 2361 qt_tabletChokeMouse = false; 2410 #ifndef QT_NO_TABLETEVENT 2362 2411 2363 QTabletEvent tabletProximity(enteredProximity ? QEvent::TabletEnterProximity 2412 2364 : QEvent::TabletLeaveProximity, … … 2414 2366 0, 0, 0, 0, 0, currentTabletPointer.llId); 2415 2367 QApplication::sendEvent(qApp, &tabletProximity); 2416 #endif // QT_NO_TABLETEVENT 2417 } 2418 break; 2419 #ifdef Q_OS_WINCE_WM 2368 } 2369 #endif // QT_NO_TABLETEVENT 2370 2371 break; 2372 #ifdef Q_WS_WINCE_WM 2420 2373 case WM_SETFOCUS: { 2421 2374 HIMC hC; … … 2430 2383 if (!QWidget::find((HWND)wParam)) { // we don't get focus, so unset it now 2431 2384 if (!widget->hasFocus()) // work around Windows bug after minimizing/restoring 2432 widget = (QETWidget*) qApp->focusWidget();2385 widget = (QETWidget*)QApplication::focusWidget(); 2433 2386 HWND focus = ::GetFocus(); 2434 2387 //if there is a current widget and the new widget belongs to the same toplevel window 2388 //or if the current widget was embedded into non-qt window (i.e. we won't get WM_ACTIVATEAPP) 2435 2389 //then we clear the focus on the widget 2436 2390 //in case the new widget belongs to a different widget hierarchy, clearing the focus 2437 2391 //will be handled because the active window will change 2438 if (widget && ::IsChild(widget->window()->internalWinId(), focus)) { 2392 const bool embedded = widget && ((QETWidget*)widget->window())->topData()->embedded; 2393 if (widget && (embedded || ::IsChild(widget->window()->internalWinId(), focus))) { 2439 2394 widget->clearFocus(); 2440 2395 result = true; … … 2447 2402 break; 2448 2403 case WM_THEMECHANGED: 2449 if ((widget->windowType() == Qt::Desktop) || !qApp || qApp->closingDown()2450 || qApp->type() == QApplication::Tty)2404 if ((widget->windowType() == Qt::Desktop) || !qApp || QApplication::closingDown() 2405 || QApplication::type() == QApplication::Tty) 2451 2406 break; 2452 2407 2453 2408 if (widget->testAttribute(Qt::WA_WState_Polished)) 2454 qApp->style()->unpolish(widget);2409 QApplication::style()->unpolish(widget); 2455 2410 2456 2411 if (widget->testAttribute(Qt::WA_WState_Polished)) 2457 qApp->style()->polish(widget);2458 widget->repolishStyle(* qApp->style());2412 QApplication::style()->polish(widget); 2413 widget->repolishStyle(*QApplication::style()); 2459 2414 if (widget->isVisible()) 2460 2415 widget->update(); 2461 2416 break; 2462 2417 2463 #ifndef Q_ OS_WINCE2418 #ifndef Q_WS_WINCE 2464 2419 case WM_INPUTLANGCHANGE: { 2465 charinfo[7];2466 if (!GetLocaleInfo A(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {2420 wchar_t info[7]; 2421 if (!GetLocaleInfo(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) { 2467 2422 inputcharset = CP_ACP; 2468 2423 } else { 2469 inputcharset = QString::from Latin1(info).toInt();2424 inputcharset = QString::fromWCharArray(info).toInt(); 2470 2425 } 2471 2426 QKeyMapper::changeKeyboard(); … … 2561 2516 result = false; 2562 2517 break; 2518 case WM_GESTURE: { 2519 GESTUREINFO gi; 2520 memset(&gi, 0, sizeof(GESTUREINFO)); 2521 gi.cbSize = sizeof(GESTUREINFO); 2522 2523 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); 2524 BOOL bResult = false; 2525 if (qAppPriv->GetGestureInfo) 2526 bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi); 2527 if (bResult) { 2528 if (gi.dwID == GID_BEGIN) { 2529 // find the alien widget for the gesture position. 2530 // This might not be accurate as the position is the center 2531 // point of two fingers for multi-finger gestures. 2532 QPoint pt(gi.ptsLocation.x, gi.ptsLocation.y); 2533 QWidget *w = widget->childAt(widget->mapFromGlobal(pt)); 2534 qAppPriv->gestureWidget = w ? w : widget; 2535 } 2536 if (qAppPriv->gestureWidget) 2537 static_cast<QETWidget*>(qAppPriv->gestureWidget)->translateGestureEvent(msg, gi); 2538 if (qAppPriv->CloseGestureInfoHandle) 2539 qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam); 2540 if (gi.dwID == GID_END) 2541 qAppPriv->gestureWidget = 0; 2542 } else { 2543 DWORD dwErr = GetLastError(); 2544 if (dwErr > 0) 2545 qWarning() << "translateGestureEvent: error = " << dwErr; 2546 } 2547 result = true; 2548 break; 2549 } 2563 2550 default: 2564 2551 result = false; // event was not processed … … 2659 2646 2660 2647 bool block_event = false; 2661 #ifndef Q_ OS_WINCE2662 if (type != WM_NCHITTEST) 2648 #ifndef Q_WS_WINCE 2649 if (type != WM_NCHITTEST) { 2663 2650 #endif 2664 2651 if ((type >= WM_MOUSEFIRST && type <= WM_MOUSELAST) || 2665 type == WM_MOUSEWHEEL || type == (int)WM95_MOUSEWHEEL ||2652 type == WM_MOUSEWHEEL || type == WM_MOUSEHWHEEL || 2666 2653 type == WM_MOUSELEAVE || 2667 2654 (type >= WM_KEYFIRST && type <= WM_KEYLAST) 2668 #ifndef Q_ OS_WINCE2655 #ifndef Q_WS_WINCE 2669 2656 || type == WM_NCMOUSEMOVE 2670 2657 #endif 2671 2658 ) { 2672 2659 if (type == WM_MOUSEMOVE 2673 #ifndef Q_ OS_WINCE2660 #ifndef Q_WS_WINCE 2674 2661 || type == WM_NCMOUSEMOVE 2675 2662 #endif … … 2689 2676 block_event = true; 2690 2677 } 2691 #ifndef Q_OS_WINCE 2692 else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){ 2693 if (!top->isActiveWindow()) { 2694 top->activateWindow(); 2695 } else { 2696 QApplication::beep(); 2697 } 2698 block_event = true; 2699 ret = MA_NOACTIVATEANDEAT; 2700 } else if (type == WM_SYSCOMMAND) { 2701 if (!(msg->wParam == SC_RESTORE && widget->isMinimized())) 2678 #ifndef Q_WS_WINCE 2679 else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){ 2680 if (!top->isActiveWindow()) { 2681 top->activateWindow(); 2682 } else { 2683 QApplication::beep(); 2684 } 2702 2685 block_event = true; 2686 ret = MA_NOACTIVATEANDEAT; 2687 } else if (type == WM_SYSCOMMAND) { 2688 if (!(msg->wParam == SC_RESTORE && widget->isMinimized())) 2689 block_event = true; 2690 } 2703 2691 } 2704 2692 #endif … … 2744 2732 popup->focusWidget()->setFocus(Qt::PopupFocusReason); 2745 2733 } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup 2746 if (QWidget *fw = q_func()->focusWidget()) {2734 if (QWidget *fw = QApplication::focusWidget()) { 2747 2735 QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); 2748 q_func()->sendEvent(fw, &e);2736 QApplication::sendEvent(fw, &e); 2749 2737 } 2750 2738 } … … 2773 2761 releaseAutoCapture(); 2774 2762 QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget() 2775 : q_func()->focusWidget();2763 : QApplication::focusWidget(); 2776 2764 if (fw) { 2777 if (fw != q_func()->focusWidget()) {2765 if (fw != QApplication::focusWidget()) { 2778 2766 fw->setFocus(Qt::PopupFocusReason); 2779 2767 } else { 2780 2768 QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); 2781 q_func()->sendEvent(fw, &e);2769 QApplication::sendEvent(fw, &e); 2782 2770 } 2783 2771 } … … 2847 2835 WM_XBUTTONDBLCLK, QEvent::MouseButtonDblClick, Qt::XButton1, 2848 2836 2849 #ifndef Q_ OS_WINCE2837 #ifndef Q_WS_WINCE 2850 2838 WM_NCMOUSEMOVE, QEvent::NonClientAreaMouseMove, 0, 2851 2839 WM_NCLBUTTONDOWN, QEvent::NonClientAreaMouseButtonPress, Qt::LeftButton, … … 2902 2890 // reset button state 2903 2891 2904 MSG msg = {0, 0, 0, 0, 0, 0, 0}; 2905 QT_WA( { 2906 while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) 2907 ; 2908 if (msg.message == WM_MOUSEMOVE) 2909 PostMessage(msg.hwnd, msg.message, 0, msg.lParam); 2910 }, { 2911 MSG msg; 2912 msg.message = 0; 2913 while (PeekMessageA(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) 2914 ; 2915 if (msg.message == WM_MOUSEMOVE) 2916 PostMessageA(msg.hwnd, msg.message, 0, msg.lParam); 2917 } ); 2892 MSG msg = {0, 0, 0, 0, 0, {0, 0} }; 2893 while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) 2894 ; 2895 if (msg.message == WM_MOUSEMOVE) 2896 PostMessage(msg.hwnd, msg.message, 0, msg.lParam); 2918 2897 } 2919 2898 2920 2899 // In DnD, the mouse release event never appears, so the 2921 2900 // mouse button state machine must be manually reset 2922 /*! \internal */2923 2901 void QApplication::winMouseButtonUp() 2924 2902 { … … 2951 2929 if (msg.message == WM_MOUSEMOVE) { 2952 2930 MSG mouseMsg; 2953 while ( winPeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST,2954 2931 while (PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST, 2932 WM_MOUSELAST, PM_NOREMOVE)) { 2955 2933 if (mouseMsg.message == WM_MOUSEMOVE) { 2956 2934 #define PEEKMESSAGE_IS_BROKEN 1 … … 2963 2941 MSG keyMsg; 2964 2942 bool done = false; 2965 while ( winPeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST,2966 2943 while (PeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST, 2944 PM_NOREMOVE)) { 2967 2945 if (keyMsg.time < mouseMsg.time) { 2968 2946 if ((keyMsg.lParam & 0xC0000000) == 0x40000000) { 2969 winPeekMessage(&keyMsg, 0, keyMsg.message,2970 2947 PeekMessage(&keyMsg, 0, keyMsg.message, 2948 keyMsg.message, PM_REMOVE); 2971 2949 } else { 2972 2950 done = true; … … 2994 2972 msgPtr->pt = mouseMsg.pt; 2995 2973 // Remove the mouse move message 2996 winPeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,2997 2974 PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE, 2975 WM_MOUSEMOVE, PM_REMOVE); 2998 2976 } else { 2999 2977 break; // there was no more WM_MOUSEMOVE event … … 3024 3002 alienWidget = 0; 3025 3003 3026 if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove) { 3004 if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove 3005 || type == QEvent::TabletMove) { 3006 3027 3007 if (!(state & Qt::MouseButtonMask)) 3028 3008 qt_button_down = 0; … … 3044 3024 HWND id = effectiveWinId(); 3045 3025 QWidget *mouseGrabber = QWidget::mouseGrabber(); 3046 QWidget *activePopupWidget = qApp->activePopupWidget();3026 QWidget *activePopupWidget = QApplication::activePopupWidget(); 3047 3027 if (mouseGrabber) { 3048 3028 if (!activePopupWidget || (activePopupWidget == this && !rect().contains(widgetPos))) … … 3137 3117 3138 3118 replayPopupMouseEvent = false; 3139 QWidget* activePopupWidget = qApp->activePopupWidget();3119 QWidget* activePopupWidget = QApplication::activePopupWidget(); 3140 3120 QWidget *target = activePopupWidget; 3141 3121 const QPoint globalPos(gpos.x, gpos.y); … … 3155 3135 break; 3156 3136 case QEvent::MouseButtonRelease: 3137 case QEvent::TabletRelease: 3138 3157 3139 releaseAfter = true; 3158 3140 break; … … 3165 3147 target = popupButtonFocus; 3166 3148 } else if (popupChild) { 3167 // forward mouse events to the popup child. mouse move events 3168 // are only forwarded to popup children that enable mouse tracking. 3169 if (type != QEvent::MouseMove || popupChild->hasMouseTracking()) 3170 target = popupChild; 3149 target = popupChild; 3171 3150 } 3172 3151 … … 3198 3177 3199 3178 if (type == QEvent::MouseButtonPress 3200 && qApp->activePopupWidget() != activePopupWidget3179 && QApplication::activePopupWidget() != activePopupWidget 3201 3180 && replayPopupMouseEvent) { 3202 3181 // the popup dissappeared. Replay the event … … 3212 3191 ScreenToClient(hwndTarget, &widgetpt); 3213 3192 LPARAM lParam = MAKELPARAM(widgetpt.x, widgetpt.y); 3214 winPostMessage(hwndTarget, msg.message, msg.wParam, lParam);3193 PostMessage(hwndTarget, msg.message, msg.wParam, lParam); 3215 3194 } 3216 3195 } else if (type == QEvent::MouseButtonRelease && button == Qt::RightButton 3217 && qApp->activePopupWidget() == activePopupWidget) {3196 && QApplication::activePopupWidget() == activePopupWidget) { 3218 3197 // popup still alive and received right-button-release 3219 3198 #if !defined(QT_NO_CONTEXTMENU) … … 3279 3258 3280 3259 int delta; 3281 if (msg.message == WM_MOUSEWHEEL )3260 if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) 3282 3261 delta = (short) HIWORD (msg.wParam); 3283 3262 else 3284 3263 delta = (int) msg.wParam; 3285 3264 3286 Qt::Orientation orient = ( state&Qt::AltModifier3265 Qt::Orientation orient = (msg.message == WM_MOUSEHWHEEL || state&Qt::AltModifier 3287 3266 #if 0 3288 3267 // disabled for now - Trenton's one-wheel mouse makes trouble... … … 3297 3276 #endif 3298 3277 ) ? Qt::Horizontal : Qt::Vertical; 3278 3279 // according to the MSDN documentation on WM_MOUSEHWHEEL: 3280 // a positive value indicates that the wheel was rotated to the right; 3281 // a negative value indicates that the wheel was rotated to the left. 3282 // Qt defines this value as the exact opposite, so we have to flip the value! 3283 if (msg.message == WM_MOUSEHWHEEL) 3284 delta = -delta; 3299 3285 3300 3286 QPoint globalPos; … … 3318 3304 // send the event to the widget or its ancestors 3319 3305 { 3320 QWidget* popup = qApp->activePopupWidget();3306 QWidget* popup = QApplication::activePopupWidget(); 3321 3307 if (popup && w->window() != popup) 3322 3308 popup->close(); … … 3334 3320 3335 3321 // send the event to the widget that has the focus or its ancestors, if different 3336 if (w != qApp->focusWidget() && (w = qApp->focusWidget())) {3337 QWidget* popup = qApp->activePopupWidget();3322 if (w != QApplication::focusWidget() && (w = QApplication::focusWidget())) { 3323 QWidget* popup = QApplication::activePopupWidget(); 3338 3324 if (popup && w->window() != popup) 3339 3325 popup->close(); … … 3356 3342 // the following is adapted from the wintab syspress example (public domain) 3357 3343 /* -------------------------------------------------------------------------- */ 3358 static void tabletInit(UINT wActiveCsr, HCTX hTab) 3359 { 3344 // Initialize the "static" information of a cursor device (pen, airbrush, etc). 3345 // The QTabletDeviceData is initialized with the data that do not change in time 3346 // (number of button, type of device, etc) but do not initialize the variable data 3347 // (e.g.: pen or eraser) 3348 #ifndef QT_NO_TABLETEVENT 3349 3350 static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab) 3351 { 3352 Q_ASSERT(ptrWTInfo); 3353 Q_ASSERT(ptrWTGet); 3354 3355 Q_ASSERT(!tCursorInfo()->contains(uniqueId)); 3356 3360 3357 /* browse WinTab's many info items to discover pressure handling. */ 3361 if (ptrWTInfo && ptrWTGet) { 3362 AXIS np; 3363 LOGCONTEXT lc; 3364 BYTE wPrsBtn; 3365 BYTE logBtns[32]; 3366 UINT size; 3367 3368 /* discover the LOGICAL button generated by the pressure channel. */ 3369 /* get the PHYSICAL button from the cursor category and run it */ 3370 /* through that cursor's button map (usually the identity map). */ 3371 wPrsBtn = (BYTE)-1; 3372 ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_NPBUTTON, &wPrsBtn); 3373 size = ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_BUTTONMAP, &logBtns); 3374 if ((UINT)wPrsBtn < size) 3375 wPrsBtn = logBtns[wPrsBtn]; 3376 3377 /* get the current context for its device variable. */ 3378 ptrWTGet(hTab, &lc); 3379 3380 /* get the size of the pressure axis. */ 3381 QTabletDeviceData tdd; 3382 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_NPRESSURE, &np); 3383 tdd.minPressure = int(np.axMin); 3384 tdd.maxPressure = int(np.axMax); 3385 3386 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_TPRESSURE, &np); 3387 tdd.minTanPressure = int(np.axMin); 3388 tdd.maxTanPressure = int(np.axMax); 3389 3390 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_X, &np); 3391 tdd.minX = int(np.axMin); 3392 tdd.maxX = int(np.axMax); 3393 3394 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_Y, &np); 3395 tdd.minY = int(np.axMin); 3396 tdd.maxY = int(np.axMax); 3397 3398 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_Z, &np); 3399 tdd.minZ = int(np.axMin); 3400 tdd.maxZ = int(np.axMax); 3401 3402 int csr_type, 3403 csr_physid; 3404 ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_TYPE, &csr_type); 3405 ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_PHYSID, &csr_physid); 3406 tdd.llId = csr_type & 0x0F06; 3407 tdd.llId = (tdd.llId << 24) | csr_physid; 3408 #ifndef QT_NO_TABLETEVENT 3409 if (((csr_type & 0x0006) == 0x0002) && ((csr_type & 0x0F06) != 0x0902)) { 3410 tdd.currentDevice = QTabletEvent::Stylus; 3411 } else { 3412 switch (csr_type & 0x0F06) { 3358 AXIS np; 3359 LOGCONTEXT lc; 3360 3361 /* get the current context for its device variable. */ 3362 ptrWTGet(hTab, &lc); 3363 3364 /* get the size of the pressure axis. */ 3365 QTabletDeviceData tdd; 3366 tdd.llId = uniqueId; 3367 3368 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_NPRESSURE, &np); 3369 tdd.minPressure = int(np.axMin); 3370 tdd.maxPressure = int(np.axMax); 3371 3372 ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_TPRESSURE, &np); 3373 tdd.minTanPressure = int(np.axMin); 3374 tdd.maxTanPressure = int(np.axMax); 3375 3376 LOGCONTEXT lcMine; 3377 3378 /* get default region */ 3379 ptrWTInfo(WTI_DEFCONTEXT, 0, &lcMine); 3380 3381 tdd.minX = 0; 3382 tdd.maxX = int(lcMine.lcInExtX) - int(lcMine.lcInOrgX); 3383 3384 tdd.minY = 0; 3385 tdd.maxY = int(lcMine.lcInExtY) - int(lcMine.lcInOrgY); 3386 3387 tdd.minZ = 0; 3388 tdd.maxZ = int(lcMine.lcInExtZ) - int(lcMine.lcInOrgZ); 3389 3390 const uint cursorTypeBitMask = 0x0F06; // bitmask to find the specific cursor type (see Wacom FAQ) 3391 if (((csr_type & 0x0006) == 0x0002) && ((csr_type & cursorTypeBitMask) != 0x0902)) { 3392 tdd.currentDevice = QTabletEvent::Stylus; 3393 } else { 3394 switch (csr_type & cursorTypeBitMask) { 3413 3395 case 0x0802: 3414 3396 tdd.currentDevice = QTabletEvent::Stylus; … … 3428 3410 default: 3429 3411 tdd.currentDevice = QTabletEvent::NoDevice; 3430 } 3431 } 3432 3433 switch (wActiveCsr % 3) { 3434 case 2: 3435 tdd.currentPointerType = QTabletEvent::Eraser; 3436 break; 3437 case 1: 3438 tdd.currentPointerType = QTabletEvent::Pen; 3439 break; 3440 case 0: 3441 tdd.currentPointerType = QTabletEvent::Cursor; 3442 break; 3443 default: 3444 tdd.currentPointerType = QTabletEvent::UnknownPointer; 3445 } 3412 } 3413 } 3414 tCursorInfo()->insert(uniqueId, tdd); 3415 } 3446 3416 #endif // QT_NO_TABLETEVENT 3447 tCursorInfo()->insert(wActiveCsr, tdd); 3448 } 3449 } 3417 3418 // Update the "dynamic" informations of a cursor device (pen, airbrush, etc). 3419 // The dynamic information is the information of QTabletDeviceData that can change 3420 // in time (eraser or pen if a device is turned around). 3421 #ifndef QT_NO_TABLETEVENT 3422 3423 static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor) 3424 { 3425 switch (currentCursor % 3) { // %3 for dual track 3426 case 0: 3427 tdd.currentPointerType = QTabletEvent::Cursor; 3428 break; 3429 case 1: 3430 tdd.currentPointerType = QTabletEvent::Pen; 3431 break; 3432 case 2: 3433 tdd.currentPointerType = QTabletEvent::Eraser; 3434 break; 3435 default: 3436 tdd.currentPointerType = QTabletEvent::UnknownPointer; 3437 } 3438 } 3439 #endif // QT_NO_TABLETEVENT 3450 3440 3451 3441 bool QETWidget::translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, … … 3508 3498 QPoint globalPos(qRound(hiResGlobal.x()), qRound(hiResGlobal.y())); 3509 3499 3500 if (t == QEvent::TabletPress) 3501 { 3502 qt_button_down = QApplication::widgetAt(globalPos); 3503 } 3504 3510 3505 // make sure the tablet event get's sent to the proper widget... 3511 QWidget *w = QApplication::widgetAt(globalPos); 3506 QWidget *w = 0; 3507 3512 3508 if (qt_button_down) 3513 3509 w = qt_button_down; // Pass it to the thing that's grabbed it. 3510 else 3511 w = QApplication::widgetAt(globalPos); 3514 3512 3515 3513 if (!w) 3516 3514 w = this; 3515 3516 if (t == QEvent::TabletRelease) 3517 { 3518 if (qt_win_ignoreNextMouseReleaseEvent) { 3519 qt_win_ignoreNextMouseReleaseEvent = false; 3520 if (qt_button_down && qt_button_down->internalWinId() == autoCaptureWnd) { 3521 releaseAutoCapture(); 3522 qt_button_down = 0; 3523 } 3524 } 3525 3526 } 3527 3517 3528 QPoint localPos = w->mapFromGlobal(globalPos); 3518 3529 #ifndef QT_NO_TABLETEVENT … … 3562 3573 3563 3574 extern bool qt_is_gui_used; 3575 3576 3577 #ifndef QT_NO_TABLETEVENT 3578 3564 3579 static void initWinTabFunctions() 3565 3580 { … … 3572 3587 QLibrary library(QLatin1String("wintab32")); 3573 3588 if (library.load()) { 3574 QT_WA({ 3575 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); 3576 ptrWTGet = (PtrWTGet)library.resolve("WTGetW"); 3577 } , { 3578 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoA"); 3579 ptrWTGet = (PtrWTGet)library.resolve("WTGetA"); 3580 }); 3581 3589 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); 3590 ptrWTGet = (PtrWTGet)library.resolve("WTGetW"); 3582 3591 ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable"); 3583 3592 ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap"); … … 3586 3595 #endif // Q_OS_WINCE 3587 3596 } 3597 #endif // QT_NO_TABLETEVENT 3588 3598 3589 3599 … … 3650 3660 QSize oldSize = size(); 3651 3661 QSize newSize(a, b); 3652 #ifdef Q_ OS_WINCE_WM3662 #ifdef Q_WS_WINCE_WM 3653 3663 if (isFullScreen() && (oldSize.width() == newSize.height()) && (oldSize.height() == newSize.width())) 3654 3664 qt_wince_hide_taskbar(internalWinId()); … … 3662 3672 // (like Windows+M) 3663 3673 if (msg.wParam == SIZE_MINIMIZED && !isMinimized()) { 3664 #ifndef Q_ OS_WINCE3674 #ifndef Q_WS_WINCE 3665 3675 const QString title = windowIconText(); 3666 3676 if (!title.isEmpty()) … … 3674 3684 } 3675 3685 } else if (msg.wParam != SIZE_MINIMIZED && isMinimized()) { 3676 #ifndef Q_ OS_WINCE3686 #ifndef Q_WS_WINCE 3677 3687 const QString title = windowTitle(); 3678 3688 if (!title.isEmpty()) … … 3720 3730 QPoint newCPos(a, b); 3721 3731 // Ignore silly Windows move event to wild pos after iconify. 3722 #if !defined(Q_ OS_WINCE)3732 #if !defined(Q_WS_WINCE) 3723 3733 if (!IsIconic(internalWinId()) && newCPos != oldPos) { 3724 3734 #endif … … 3732 3742 QApplication::postEvent(this, e); 3733 3743 } 3734 #if !defined(Q_ OS_WINCE)3744 #if !defined(Q_WS_WINCE) 3735 3745 } 3736 3746 #endif … … 3753 3763 } 3754 3764 3765 bool QETWidget::translateGestureEvent(const MSG &, const GESTUREINFO &gi) 3766 { 3767 const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y); 3768 QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos); 3769 if (alienWidget && alienWidget->internalWinId()) 3770 alienWidget = 0; 3771 QWidget *widget = alienWidget ? alienWidget : this; 3772 3773 QNativeGestureEvent event; 3774 event.sequenceId = gi.dwSequenceID; 3775 event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y); 3776 event.argument = gi.ullArguments; 3777 3778 switch (gi.dwID) { 3779 case GID_BEGIN: 3780 event.gestureType = QNativeGestureEvent::GestureBegin; 3781 break; 3782 case GID_END: 3783 event.gestureType = QNativeGestureEvent::GestureEnd; 3784 break; 3785 case GID_ZOOM: 3786 event.gestureType = QNativeGestureEvent::Zoom; 3787 break; 3788 case GID_PAN: 3789 event.gestureType = QNativeGestureEvent::Pan; 3790 break; 3791 case GID_ROTATE: 3792 event.gestureType = QNativeGestureEvent::Rotate; 3793 break; 3794 case GID_TWOFINGERTAP: 3795 case GID_ROLLOVER: 3796 default: 3797 break; 3798 } 3799 if (event.gestureType != QNativeGestureEvent::None) 3800 qt_sendSpontaneousEvent(widget, &event); 3801 return true; 3802 } 3803 3755 3804 3756 3805 void QApplication::setCursorFlashTime(int msecs) … … 3774 3823 void QApplication::setDoubleClickInterval(int ms) 3775 3824 { 3776 #ifndef Q_ OS_WINCE3825 #ifndef Q_WS_WINCE 3777 3826 SetDoubleClickTime(ms); 3778 3827 #endif … … 3806 3855 if (n < 0) 3807 3856 n = 0; 3808 QT_WA({ 3809 SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0); 3810 } , { 3811 SystemParametersInfoA(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0); 3812 }); 3857 SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0); 3813 3858 #else 3814 3859 QApplicationPrivate::wheel_scroll_lines = n; … … 3820 3865 #ifdef SPI_GETWHEELSCROLLLINES 3821 3866 uint i = 3; 3822 QT_WA({ 3823 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0); 3824 } , { 3825 SystemParametersInfoA(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0); 3826 }); 3867 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0); 3827 3868 if (i > INT_MAX) 3828 3869 i = INT_MAX; … … 3869 3910 return false; 3870 3911 3871 if (!effect_override && desktopSettingsAware() 3872 && !(QSysInfo::WindowsVersion == QSysInfo::WV_95 || QSysInfo::WindowsVersion == QSysInfo::WV_NT)) { 3912 if (!effect_override && desktopSettingsAware()) { 3873 3913 // we know that they can be used when we are here 3874 3914 BOOL enabled = false; … … 3879 3919 break; 3880 3920 case Qt::UI_FadeMenu: 3881 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)3882 return false;3883 3921 api = SPI_GETMENUFADE; 3884 3922 break; … … 3887 3925 break; 3888 3926 case Qt::UI_AnimateTooltip: 3889 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) 3890 api = SPI_GETMENUANIMATION; 3891 else 3892 api = SPI_GETTOOLTIPANIMATION; 3927 api = SPI_GETTOOLTIPANIMATION; 3893 3928 break; 3894 3929 case Qt::UI_FadeTooltip: 3895 if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)3896 return false;3897 3930 api = SPI_GETTOOLTIPFADE; 3898 3931 break; … … 3901 3934 break; 3902 3935 } 3903 QT_WA({ 3904 SystemParametersInfo(api, 0, &enabled, 0); 3905 } , { 3906 SystemParametersInfoA(api, 0, &enabled, 0); 3907 }); 3936 SystemParametersInfo(api, 0, &enabled, 0); 3908 3937 return enabled; 3909 3938 } … … 3954 3983 #endif //QT_NO_SESSIONMANAGER 3955 3984 3985 3986 PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0; 3987 PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0; 3988 PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0; 3989 3990 void QApplicationPrivate::initializeMultitouch_sys() 3991 { 3992 QLibrary library(QLatin1String("user32")); 3993 // MinGW (g++ 3.4.5) accepts only C casts. 3994 RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow")); 3995 GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo")); 3996 CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle")); 3997 3998 touchInputIDToTouchPointID.clear(); 3999 } 4000 4001 void QApplicationPrivate::cleanupMultitouch_sys() 4002 { 4003 touchInputIDToTouchPointID.clear(); 4004 } 4005 4006 bool QApplicationPrivate::translateTouchEvent(const MSG &msg) 4007 { 4008 QWidget *widgetForHwnd = QWidget::find(msg.hwnd); 4009 if (!widgetForHwnd) 4010 return false; 4011 4012 QRect screenGeometry = QApplication::desktop()->screenGeometry(widgetForHwnd); 4013 4014 QList<QTouchEvent::TouchPoint> touchPoints; 4015 4016 QVector<TOUCHINPUT> winTouchInputs(msg.wParam); 4017 memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchInputs.count()); 4018 Qt::TouchPointStates allStates = 0; 4019 QApplicationPrivate::GetTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT)); 4020 for (int i = 0; i < winTouchInputs.count(); ++i) { 4021 const TOUCHINPUT &touchInput = winTouchInputs.at(i); 4022 4023 int touchPointID = touchInputIDToTouchPointID.value(touchInput.dwID, -1); 4024 if (touchPointID == -1) { 4025 touchPointID = touchInputIDToTouchPointID.count(); 4026 touchInputIDToTouchPointID.insert(touchInput.dwID, touchPointID); 4027 } 4028 4029 QTouchEvent::TouchPoint touchPoint(touchPointID); 4030 4031 // update state 4032 QPointF screenPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.)); 4033 QRectF screenRect; 4034 if (touchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA) 4035 screenRect.setSize(QSizeF(qreal(touchInput.cxContact) / qreal(100.), 4036 qreal(touchInput.cyContact) / qreal(100.))); 4037 screenRect.moveCenter(screenPos); 4038 4039 Qt::TouchPointStates state; 4040 if (touchInput.dwFlags & TOUCHEVENTF_DOWN) { 4041 state = Qt::TouchPointPressed; 4042 } else if (touchInput.dwFlags & TOUCHEVENTF_UP) { 4043 state = Qt::TouchPointReleased; 4044 } else { 4045 state = (screenPos == touchPoint.screenPos() 4046 ? Qt::TouchPointStationary 4047 : Qt::TouchPointMoved); 4048 } 4049 if (touchInput.dwFlags & TOUCHEVENTF_PRIMARY) 4050 state |= Qt::TouchPointPrimary; 4051 touchPoint.setState(state); 4052 touchPoint.setScreenRect(screenRect); 4053 touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), 4054 screenPos.y() / screenGeometry.height())); 4055 4056 allStates |= state; 4057 4058 touchPoints.append(touchPoint); 4059 } 4060 QApplicationPrivate::CloseTouchInputHandle((HANDLE) msg.lParam); 4061 4062 if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) { 4063 // all touch points released, forget the ids we've seen, they may not be reused 4064 touchInputIDToTouchPointID.clear(); 4065 } 4066 4067 translateRawTouchEvent(widgetForHwnd, QTouchEvent::TouchScreen, touchPoints); 4068 return true; 4069 } 4070 3956 4071 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.