summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qapplication_win.cpp')
-rw-r--r--src/gui/kernel/qapplication_win.cpp1271
1 files changed, 683 insertions, 588 deletions
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index d0c986d..0a4869b 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#include "qguifunctions_wince.h"
#include "qmenubar.h"
extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
@@ -48,9 +48,12 @@ extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.c
extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.cpp
#endif
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
#include <windowsm.h>
#include <tpcshell.h>
+#ifdef QT_WINCE_GESTURES
+#include <gesture.h>
+#endif
#endif
#include "qapplication.h"
@@ -88,6 +91,7 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#include "qdebug.h"
#include <private/qkeymapper_p.h>
#include <private/qlocale_p.h>
+#include "qevent_p.h"
//#define ALIEN_DEBUG
@@ -104,32 +108,44 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#endif
#endif // QT_NO_ACCESSIBILITY
-#include <winuser.h>
#if !defined(WINABLEAPI)
-# if defined(Q_OS_WINCE)
+# if defined(Q_WS_WINCE)
# include <bldver.h>
# endif
# include <winable.h>
#endif
+#ifndef WM_TOUCH
+# define WM_TOUCH 0x0240
+
+# define TOUCHEVENTF_MOVE 0x0001
+# define TOUCHEVENTF_DOWN 0x0002
+# define TOUCHEVENTF_UP 0x0004
+# define TOUCHEVENTF_INRANGE 0x0008
+# define TOUCHEVENTF_PRIMARY 0x0010
+# define TOUCHEVENTF_NOCOALESCE 0x0020
+# define TOUCHEVENTF_PEN 0x0040
+# define TOUCHEVENTF_PALM 0x0080
-#ifndef FLASHW_STOP
-typedef struct {
- UINT cbSize;
- HWND hwnd;
+# define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001
+# define TOUCHINPUTMASKF_EXTRAINFO 0x0002
+# define TOUCHINPUTMASKF_CONTACTAREA 0x0004
+
+typedef struct tagTOUCHINPUT
+{
+ LONG x;
+ LONG y;
+ HANDLE hSource;
+ DWORD dwID;
DWORD dwFlags;
- UINT uCount;
- DWORD dwTimeout;
-} FLASHWINFO, *PFLASHWINFO;
-#define FLASHW_STOP 0
-#define FLASHW_CAPTION 0x00000001
-#define FLASHW_TRAY 0x00000002
-#define FLASHW_ALL (FLASHW_CAPTION | FLASHW_TRAY)
-#define FLASHW_TIMER 0x00000004
-#define FLASHW_TIMERNOFG 0x0000000C
-#endif /* FLASHW_STOP */
-typedef BOOL (WINAPI *PtrFlashWindowEx)(PFLASHWINFO pfwi);
-static PtrFlashWindowEx pFlashWindowEx = 0;
+ DWORD dwMask;
+ DWORD dwTime;
+ ULONG_PTR dwExtraInfo;
+ DWORD cxContact;
+ DWORD cyContact;
+} TOUCHINPUT, *PTOUCHINPUT;
+
+#endif
#include <windowsx.h>
#include <limits.h>
@@ -153,9 +169,16 @@ static PtrFlashWindowEx pFlashWindowEx = 0;
#include <mywinsock.h>
#endif
+#ifndef IMR_RECONVERTSTRING
+#define IMR_RECONVERTSTRING 4
+#endif
+
+#ifndef IMR_CONFIRMRECONVERTSTRING
+#define IMR_CONFIRMRECONVERTSTRING 0x0005
+#endif
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
#ifndef SHRG_RETURNCMD
struct SHRGINFO {
DWORD cbSize;
@@ -198,7 +221,7 @@ static void resolveAygLibs()
# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
#endif
-bool qt_cleartype_enabled;
+Q_GUI_EXPORT bool qt_cleartype_enabled;
Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default
typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL);
@@ -220,8 +243,12 @@ static PtrWTGet ptrWTGet = 0;
static PACKET localPacketBuf[QT_TABLET_NPACKETQSIZE]; // our own tablet packet queue.
HCTX qt_tablet_context; // the hardware context for the tablet (like a window handle)
bool qt_tablet_tilt_support;
-static void tabletInit(UINT wActiveCsr, HCTX hTab);
+
+#ifndef QT_NO_TABLETEVENT
+static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab);
+static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor);
static void initWinTabFunctions(); // resolve the WINTAB api functions
+#endif // QT_NO_TABLETEVENT
#ifndef QT_NO_ACCESSIBILITY
@@ -233,17 +260,13 @@ extern QWidget* qt_get_tablet_widget();
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
extern QRegion qt_dirtyRegion(QWidget *);
-typedef QHash<UINT, QTabletDeviceData> QTabletCursorInfo;
+typedef QHash<quint64, QTabletDeviceData> QTabletCursorInfo;
Q_GLOBAL_STATIC(QTabletCursorInfo, tCursorInfo)
QTabletDeviceData currentTabletPointer;
// from qregion_win.cpp
extern HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom);
-Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
- UINT wMsgFilterMax, UINT wRemoveMsg);
-Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
// support for on-the-fly changes of the XP theme engine
#ifndef WM_THEMECHANGED
#define WM_THEMECHANGED 0x031A
@@ -258,22 +281,24 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
#define WM_XBUTTONDOWN 0x020B
#define WM_XBUTTONUP 0x020C
#define WM_XBUTTONDBLCLK 0x020D
+#endif
+#ifndef GET_KEYSTATE_WPARAM
#define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
#define XBUTTON1 0x0001
#define XBUTTON2 0x0002
+#endif
+#ifndef MK_XBUTTON1
#define MK_XBUTTON1 0x0020
#define MK_XBUTTON2 0x0040
#endif
-#ifdef Q_OS_WINCE
-#define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
-#endif
-
-// support for multi-media-keys on ME/2000/XP
+// support for multi-media-keys
#ifndef WM_APPCOMMAND
#define WM_APPCOMMAND 0x0319
+#endif
+#ifndef FAPPCOMMAND_MOUSE
#define FAPPCOMMAND_MOUSE 0x8000
#define FAPPCOMMAND_KEY 0
#define FAPPCOMMAND_OEM 0x1000
@@ -307,6 +332,7 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
#define APPCOMMAND_BASS_UP 21
#define APPCOMMAND_TREBLE_DOWN 22
#define APPCOMMAND_TREBLE_UP 23
+#endif // FAPPCOMMAND_MOUSE
// New commands from Windows XP (some even Sp1)
#ifndef APPCOMMAND_MICROPHONE_VOLUME_MUTE
@@ -341,10 +367,6 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
#define APPCOMMAND_MEDIA_CHANNEL_DOWN 52
#endif // APPCOMMAND_MICROPHONE_VOLUME_MUTE
-#endif // WM_APPCOMMAND
-
-static UINT WM95_MOUSEWHEEL = 0;
-
#if (_WIN32_WINNT < 0x0400)
// This struct is defined in winuser.h if the _WIN32_WINNT >= 0x0400 -- in the
// other cases we have to define it on our own.
@@ -376,11 +398,6 @@ QRgb qt_colorref2qrgb(COLORREF col)
Internal variables and functions
*****************************************************************************/
-extern Q_CORE_EXPORT char theAppName[];
-extern Q_CORE_EXPORT char appFileName[];
-extern Q_CORE_EXPORT HINSTANCE appInst; // handle to app instance
-extern Q_CORE_EXPORT HINSTANCE appPrevInst; // handle to prev app instance
-extern Q_CORE_EXPORT int appCmdShow; // main window show command
static HWND curWin = 0; // current window
static HDC displayDC = 0; // display device context
@@ -422,11 +439,6 @@ extern QCursor *qt_grab_cursor();
#define __export
#endif
-QApplicationPrivate* getQApplicationPrivateInternal()
-{
- return qApp->d_func();
-}
-
extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
class QETWidget : public QWidget // event translator widget
@@ -448,6 +460,7 @@ public:
bool translateConfigEvent(const MSG &msg);
bool translateCloseEvent(const MSG &msg);
bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets);
+ bool translateGestureEvent(const MSG &msg, const GESTUREINFO &gi);
void repolishStyle(QStyle &style);
inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); }
inline void hideChildren(bool spontaneous) { d_func()->hideChildren(spontaneous); }
@@ -497,7 +510,7 @@ static void qt_set_windows_color_resources()
pal.setColor(QPalette::HighlightedText,
QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHTTEXT))));
-#if defined(Q_OS_WINCE)
+#if defined(Q_WS_WINCE)
// ### hardcoded until I find out how to get it from the system settings.
pal.setColor(QPalette::LinkVisited, pal.highlight().color().dark(150));
pal.setColor(QPalette::Link, pal.highlight().color().light(130));
@@ -516,14 +529,13 @@ static void qt_set_windows_color_resources()
pal.setColor(QPalette::Inactive, QPalette::Light, pal.light().color());
pal.setColor(QPalette::Inactive, QPalette::Dark, pal.dark().color());
- if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95) {
- if (pal.midlight() == pal.button())
- pal.setColor(QPalette::Midlight, pal.button().color().lighter(110));
- if (pal.background() != pal.base()) {
- pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Inactive, QPalette::Window));
- pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Inactive, QPalette::Text));
- }
+ if (pal.midlight() == pal.button())
+ pal.setColor(QPalette::Midlight, pal.button().color().lighter(110));
+ if (pal.background() != pal.base()) {
+ pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Inactive, QPalette::Window));
+ pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Inactive, QPalette::Text));
}
+
const QColor bg = pal.background().color();
const QColor fg = pal.foreground().color(), btn = pal.button().color();
QColor disabled((fg.red()+btn.red())/2,(fg.green()+btn.green())/2,
@@ -573,36 +585,19 @@ static void qt_set_windows_color_resources()
static void qt_set_windows_font_resources()
{
-#ifndef Q_OS_WINCE
- QFont menuFont;
- QFont messageFont;
- QFont statusFont;
- QFont titleFont;
- QFont iconTitleFont;
- QT_WA({
- NONCLIENTMETRICS ncm;
- ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONTW);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
- menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont,true);
- messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont,true);
- statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont,true);
- titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont,true);
- LOGFONTW lfIconTitleFont;
- SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
- iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont,true);
- } , {
- // A version
- NONCLIENTMETRICSA ncm;
- ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, lfMessageFont) + sizeof(LOGFONTA);
- SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- menuFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMenuFont,true);
- messageFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMessageFont,true);
- statusFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfStatusFont,true);
- titleFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfCaptionFont,true);
- LOGFONTA lfIconTitleFont;
- SystemParametersInfoA(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
- iconTitleFont = qt_LOGFONTtoQFont((LOGFONT&)lfIconTitleFont,true);
- });
+#ifndef Q_WS_WINCE
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
+
+ QFont menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont, true);
+ QFont messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont, true);
+ QFont statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont, true);
+ QFont titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont, true);
+
+ LOGFONT lfIconTitleFont;
+ SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
+ QFont iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont, true);
QApplication::setFont(menuFont, "QMenu");
QApplication::setFont(menuFont, "QMenuBar");
@@ -627,24 +622,19 @@ static void qt_set_windows_font_resources()
smallerFont.setBold(true);
QApplication::setFont(smallerFont, "QAbstractButton");
}
-#endif// Q_OS_WINCE
+#endif// Q_WS_WINCE
}
static void qt_win_read_cleartype_settings()
{
- QT_WA({
- UINT result;
- BOOL ok;
- ok = SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
- if (ok)
- qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
- }, {
- UINT result;
- BOOL ok;
- ok = SystemParametersInfoA(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
- if (ok)
- qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
- });
+ UINT result = 0;
+#ifdef Q_OS_WINCE
+ if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &result, 0))
+ qt_cleartype_enabled = result;
+#else
+ if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0))
+ qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
+#endif
}
@@ -661,10 +651,10 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
QPalette pal = *QApplicationPrivate::sys_pal;
QColor menuCol(qt_colorref2qrgb(GetSysColor(COLOR_MENU)));
QColor menuText(qt_colorref2qrgb(GetSysColor(COLOR_MENUTEXT)));
- BOOL isFlat = 0;
+ BOOL isFlat = false;
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- SystemParametersInfo(0x1022 /*SPI_GETFLATMENU*/, 0, &isFlat, 0);
+ SystemParametersInfo(SPI_GETFLATMENU, 0, &isFlat, 0);
QPalette menu(pal);
// we might need a special color group for the menu.
menu.setColor(QPalette::Active, QPalette::Button, menuCol);
@@ -679,8 +669,7 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
QColor(qt_colorref2qrgb(GetSysColor(
(QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
- && isFlat ? COLOR_MENUHILIGHT
- : COLOR_HIGHLIGHT))));
+ && isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT))));
menu.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
menu.setColor(QPalette::Disabled, QPalette::Button,
menu.color(QPalette::Active, QPalette::Button));
@@ -696,10 +685,8 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
menu.color(QPalette::Active, QPalette::Highlight));
menu.setColor(QPalette::Inactive, QPalette::HighlightedText,
menu.color(QPalette::Active, QPalette::HighlightedText));
-
- if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95)
- menu.setColor(QPalette::Inactive, QPalette::ButtonText,
- pal.color(QPalette::Inactive, QPalette::Dark));
+ menu.setColor(QPalette::Inactive, QPalette::ButtonText,
+ pal.color(QPalette::Inactive, QPalette::Dark));
QApplication::setPalette(menu, "QMenu");
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
@@ -716,11 +703,10 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
qt_init() - initializes Qt for Windows
*****************************************************************************/
-typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst,
- const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey,
- const Q_BLENDFUNCTION *pblend, DWORD dwflags);
-static PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0;
-
+typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID);
+static PtrSetProcessDPIAware ptrSetProcessDPIAware = 0;
+PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0;
+PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect = 0;
static BOOL WINAPI qt_updateLayeredWindowIndirect(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *info)
{
return (*ptrUpdateLayeredWindow)(hwnd, info->hdcDst, info->pptDst, info->psize, info->hdcSrc,
@@ -747,9 +733,6 @@ void qt_init(QApplicationPrivate *priv, int)
appNoGrab = !appNoGrab;
else
#endif // QT_DEBUG
- if (qstrcmp(argv[i], "-direct3d") == 0)
- QApplication::setAttribute(Qt::AA_MSWindowsUseDirect3DByDefault);
- else
argv[j++] = argv[i];
}
if(j < priv->argc) {
@@ -757,21 +740,12 @@ void qt_init(QApplicationPrivate *priv, int)
priv->argc = j;
}
- // Get the application name/instance if qWinMain() was not invoked
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// No message boxes but important ones
SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
#endif
- if (appInst == 0) {
- QT_WA({
- appInst = GetModuleHandle(0);
- }, {
- appInst = GetModuleHandleA(0);
- });
- }
-
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// Initialize OLE/COM
// S_OK means success and S_FALSE means that it has already
// been initialized
@@ -783,7 +757,7 @@ void qt_init(QApplicationPrivate *priv, int)
#endif
// Misc. initialization
-#if defined(QT_DEBUG) && !defined(Q_OS_WINCE)
+#if defined(QT_DEBUG) && !defined(Q_WS_WINCE)
GdiSetBatchLimit(1);
#endif
@@ -795,49 +769,35 @@ void qt_init(QApplicationPrivate *priv, int)
#ifndef QT_NO_CURSOR
QCursorData::initialize();
#endif
- qApp->setObjectName(QLatin1String(theAppName));
+ qApp->setObjectName(priv->appName());
-#if !defined(Q_OS_WINCE)
// default font
- HFONT hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- QFont f(QLatin1String("MS Sans Serif"),8);
- int result = 0;
- QT_WA({
- LOGFONT lf;
- if (result = GetObject(hfont, sizeof(lf), &lf))
- f = qt_LOGFONTtoQFont((LOGFONT&)lf,true);
- } , {
- LOGFONTA lf;
- if (result = GetObjectA(hfont, sizeof(lf), &lf))
- f = qt_LOGFONTtoQFont((LOGFONT&)lf,true);
- });
- if (result
- && QSysInfo::WindowsVersion >= QSysInfo::WV_2000
- && QSysInfo::WindowsVersion <= QSysInfo::WV_NT_based
- && f.family() == QLatin1String("MS Shell Dlg"))
- f.setFamily(QLatin1String("MS Shell Dlg 2"));
- QApplicationPrivate::setSystemFont(f);
-#else //Q_OS_WINCE
- LOGFONT lf;
- HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
- int result = 0;
- result = GetObject(stockFont, sizeof(lf), &lf);
- QFont font = qt_LOGFONTtoQFont(lf, true);
- if (result)
- QApplicationPrivate::setSystemFont(font);
-#endif //Q_OS_WINCE
+#ifndef Q_WS_WINCE
+ HGDIOBJ stockFont = GetStockObject(DEFAULT_GUI_FONT);
+#else
+ HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
+#endif
+
+ LOGFONT lf;
+ GetObject(stockFont, sizeof(lf), &lf);
+ QFont systemFont = qt_LOGFONTtoQFont(lf, true);
+
+#ifndef Q_WS_WINCE
+ if (systemFont.family() == QLatin1String("MS Shell Dlg")) {
+ systemFont.setFamily(QLatin1String("MS Shell Dlg 2"));
+ }
+#endif
+
+ QApplicationPrivate::setSystemFont(systemFont);
// QFont::locale_init(); ### Uncomment when it does something on Windows
if (QApplication::desktopSettingsAware())
qt_set_windows_resources();
- QT_WA({
- WM95_MOUSEWHEEL = RegisterWindowMessage(L"MSWHEEL_ROLLMSG");
- } , {
- WM95_MOUSEWHEEL = RegisterWindowMessageA("MSWHEEL_ROLLMSG");
- });
+#ifndef QT_NO_TABLETEVENT
initWinTabFunctions();
+#endif // QT_NO_TABLETEVENT
QApplicationPrivate::inputContext = new QWinInputContext(0);
// Read the initial cleartype settings...
@@ -857,6 +817,53 @@ void qt_init(QApplicationPrivate *priv, int)
if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect)
ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect;
+
+ // Notify Vista and Windows 7 that we support highter DPI settings
+ ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
+ QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
+ if (ptrSetProcessDPIAware)
+ ptrSetProcessDPIAware();
+#endif
+
+ priv->GetGestureInfo = 0;
+ priv->GetGestureExtraArgs = 0;
+ priv->CloseGestureInfoHandle = 0;
+ priv->SetGestureConfig = 0;
+ priv->GetGestureConfig = 0;
+ priv->BeginPanningFeedback = 0;
+ priv->UpdatePanningFeedback = 0;
+ priv->EndPanningFeedback = 0;
+
+#if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES)
+ priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo;
+ priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments;
+#elif !defined(Q_WS_WINCE)
+ #if !defined(QT_NO_NATIVE_GESTURES)
+ priv->GetGestureInfo =
+ (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
+ "GetGestureInfo");
+ priv->GetGestureExtraArgs =
+ (PtrGetGestureExtraArgs)QLibrary::resolve(QLatin1String("user32"),
+ "GetGestureExtraArgs");
+ priv->CloseGestureInfoHandle =
+ (PtrCloseGestureInfoHandle)QLibrary::resolve(QLatin1String("user32"),
+ "CloseGestureInfoHandle");
+ priv->SetGestureConfig =
+ (PtrSetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
+ "SetGestureConfig");
+ priv->GetGestureConfig =
+ (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
+ "GetGestureConfig");
+ #endif // QT_NO_NATIVE_GESTURES
+ priv->BeginPanningFeedback =
+ (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
+ "BeginPanningFeedback");
+ priv->UpdatePanningFeedback =
+ (PtrUpdatePanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
+ "UpdatePanningFeedback");
+ priv->EndPanningFeedback =
+ (PtrEndPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
+ "EndPanningFeedback");
#endif
}
@@ -882,7 +889,7 @@ void qt_cleanup()
delete QApplicationPrivate::inputContext;
QApplicationPrivate::inputContext = 0;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// Deinitialize OLE/COM
OleUninitialize();
#endif
@@ -893,12 +900,6 @@ void qt_cleanup()
Platform specific global and internal functions
*****************************************************************************/
-Q_GUI_EXPORT int qWinAppCmdShow() // get main window show command
-{
- return appCmdShow;
-}
-
-
Q_GUI_EXPORT HDC qt_win_display_dc() // get display DC
{
Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());
@@ -934,7 +935,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
} else if (flags & Qt::MSWindowsOwnDC) {
cname = QLatin1String("QWidgetOwnDC");
style = CS_DBLCLKS;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
style |= CS_OWNDC;
#endif
icon = true;
@@ -943,25 +944,25 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) {
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
- style |= 0x00020000; // CS_DROPSHADOW
+ style |= CS_DROPSHADOW;
}
cname = QLatin1String("QToolTip");
} else {
cname = QLatin1String("QTool");
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
style |= CS_SAVEBITS;
#endif
icon = false;
} else if (type == Qt::Popup) {
cname = QLatin1String("QPopup");
style = CS_DBLCLKS;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
style |= CS_SAVEBITS;
#endif
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- style |= 0x00020000; // CS_DROPSHADOW
+ style |= CS_DROPSHADOW;
icon = false;
} else {
cname = QLatin1String("QWidget");
@@ -969,7 +970,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
icon = true;
}
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
// force CS_OWNDC when the GL graphics system is
// used as the default renderer
if (qt_win_owndc_required)
@@ -981,11 +982,11 @@ const QString qt_reg_winclass(QWidget *w) // register window class
// unique ID on WinCE to make sure we can
// move the windows to the front when starting
// a second instance.
- wchar_t uniqueAppID[256];
- GetModuleFileNameW(0, uniqueAppID, 255);
- cname = QString::number(RegisterWindowMessageW(
- (const wchar_t *) QString::fromUtf16((const ushort *)uniqueAppID).toLower().replace(QString(QString::fromLatin1("\\")),
- QString(QString::fromLatin1("_"))).utf16()));
+ wchar_t uniqueAppID[MAX_PATH];
+ GetModuleFileName(0, uniqueAppID, MAX_PATH);
+ cname = QString::number(RegisterWindowMessage(
+ (const wchar_t *) QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1Char('\\'),
+ QLatin1Char('_')).utf16()));
#endif
// since multiple Qt versions can be used in one process
@@ -996,15 +997,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
static int classExists = -1;
if (classExists == -1) {
- QT_WA({
- WNDCLASS wcinfo;
- classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo);
- classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
- }, {
- WNDCLASSA wcinfo;
- classExists = GetClassInfoA((HINSTANCE)qWinAppInst(), cname.toLatin1(), &wcinfo);
- classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
- });
+ WNDCLASS wcinfo;
+ classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (wchar_t*)cname.utf16(), &wcinfo);
+ classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
}
if (classExists)
@@ -1013,73 +1008,37 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (winclassNames()->contains(cname)) // already registered in our list
return cname;
- ATOM atom;
-#ifndef Q_OS_WINCE
- HBRUSH bgBrush = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
- QT_WA({
- WNDCLASS wc;
- wc.style = style;
- wc.lpfnWndProc = (WNDPROC)QtWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
- if (icon) {
- wc.hIcon = LoadIcon(appInst, L"IDI_ICON1");
- if (!wc.hIcon)
- wc.hIcon = LoadIcon(0, IDI_APPLICATION);
- } else {
- wc.hIcon = 0;
- }
- wc.hCursor = 0;
- wc.hbrBackground= bgBrush;
- wc.lpszMenuName = 0;
- wc.lpszClassName= (TCHAR*)cname.utf16();
- atom = RegisterClass(&wc);
- } , {
- WNDCLASSA wc;
- wc.style = style;
- wc.lpfnWndProc = (WNDPROC)QtWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
- if (icon) {
- wc.hIcon = LoadIconA(appInst, (char*)"IDI_ICON1");
- if (!wc.hIcon)
- wc.hIcon = LoadIconA(0, (char*)IDI_APPLICATION);
- } else {
- wc.hIcon = 0;
- }
- wc.hCursor = 0;
- wc.hbrBackground= bgBrush;
- wc.lpszMenuName = 0;
- QByteArray tempArray = cname.toLatin1();
- wc.lpszClassName= tempArray;
- atom = RegisterClassA(&wc);
- });
+ WNDCLASS wc;
+ wc.style = style;
+ wc.lpfnWndProc = (WNDPROC)QtWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = qWinAppInst();
+ if (icon) {
+ wc.hIcon = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
+#ifndef Q_WS_WINCE
+ if (!wc.hIcon)
+ wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+#endif
+ } else {
+ wc.hIcon = 0;
+ }
+ wc.hCursor = 0;
+#ifndef Q_WS_WINCE
+ wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
#else
- WNDCLASS wc;
- wc.style = style;
- wc.lpfnWndProc = (WNDPROC)QtWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
- if (icon) {
- wc.hIcon = LoadIcon(appInst, L"IDI_ICON1");
-// if (!wc.hIcon)
-// wc.hIcon = LoadIcon(0, IDI_APPLICATION);
- } else {
- wc.hIcon = 0;
- }
- wc.hCursor = 0;
- wc.hbrBackground= 0;
- wc.lpszMenuName = 0;
- wc.lpszClassName= (TCHAR*)cname.utf16();
- atom = RegisterClass(&wc);
+ wc.hbrBackground = 0;
#endif
+ wc.lpszMenuName = 0;
+ wc.lpszClassName = (wchar_t*)cname.utf16();
+
+ ATOM atom = RegisterClass(&wc);
#ifndef QT_NO_DEBUG
if (!atom)
qErrnoWarning("QApplication::regClass: Registering window class failed.");
+#else
+ Q_UNUSED(atom);
#endif
winclassNames()->insert(cname, 1);
@@ -1097,11 +1056,7 @@ static void unregWinClasses()
WinClassNameHash *hash = winclassNames();
QHash<QString, int>::ConstIterator it = hash->constBegin();
while (it != hash->constEnd()) {
- QT_WA({
- UnregisterClass((TCHAR*)it.key().utf16(), (HINSTANCE)qWinAppInst());
- } , {
- UnregisterClassA(it.key().toLatin1(), (HINSTANCE)qWinAppInst());
- });
+ UnregisterClass((wchar_t*)it.key().utf16(), qWinAppInst());
++it;
}
hash->clear();
@@ -1135,7 +1090,7 @@ void qWinRequestConfig(WId id, int req, int x, int y, int w, int h)
configRequests->append(r); // store request in queue
}
-Q_GUI_EXPORT void qWinProcessConfigRequests() // perform requests in queue
+static void qWinProcessConfigRequests() // perform requests in queue
{
if (!configRequests)
return;
@@ -1318,16 +1273,13 @@ void QApplication::beep()
static void alert_widget(QWidget *widget, int duration)
{
+#ifdef Q_OS_WINCE
+ Q_UNUSED(widget);
+ Q_UNUSED(duration);
+#else
bool stopFlash = duration < 0;
- if (!pFlashWindowEx) {
-#ifndef Q_OS_WINCE
- QLibrary themeLib(QLatin1String("user32"));
- pFlashWindowEx = (PtrFlashWindowEx)themeLib.resolve("FlashWindowEx");
-#endif
- }
-
- if (pFlashWindowEx && widget && (!widget->isActiveWindow() || stopFlash)) {
+ if (widget && (!widget->isActiveWindow() || stopFlash)) {
DWORD timeOut = GetCaretBlinkTime();
if (timeOut <= 0)
timeOut = 250;
@@ -1345,8 +1297,9 @@ static void alert_widget(QWidget *widget, int duration)
info.dwTimeout = stopFlash ? 0 : timeOut;
info.uCount = stopFlash ? 0 : flashCount;
- pFlashWindowEx(&info);
+ FlashWindowEx(&info);
}
+#endif
}
void QApplication::alert(QWidget *widget, int duration)
@@ -1387,7 +1340,7 @@ void QApplication::winFocus(QWidget *widget, bool gotFocus)
&& (QApplicationPrivate::active_window->windowType() == Qt::Dialog)) {
// raise the entire application, not just the dialog
QWidget* mw = QApplicationPrivate::active_window;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
while(mw->parentWidget() && (mw->windowType() == Qt::Dialog))
mw = mw->parentWidget()->window();
if (mw->testAttribute(Qt::WA_WState_Created) && mw != QApplicationPrivate::active_window)
@@ -1434,12 +1387,13 @@ static int inputcharset = CP_ACP;
static bool qt_is_translatable_mouse_event(UINT message)
{
- return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST ||
- message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)
+ return (((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) ||
+ (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK))
&& message != WM_MOUSEWHEEL
+ && message != WM_MOUSEHWHEEL)
-#ifndef Q_OS_WINCE
- || message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK
+#ifndef Q_WS_WINCE
+ || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK)
#endif
;
}
@@ -1478,7 +1432,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
msg.pt.y = GET_Y_LPARAM(lParam);
// If it's a non-client-area message the coords are screen coords, otherwise they are
// client coords.
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
if (message < WM_NCMOUSEMOVE || message > WM_NCMBUTTONDBLCLK)
#endif
ClientToScreen(msg.hwnd, &msg.pt);
@@ -1508,7 +1462,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
if (imeParentWnd && QApplication::activePopupWidget()
&& (message == WM_MBUTTONDOWN || message == WM_XBUTTONDOWN
|| message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| message == WM_NCMBUTTONDOWN || message == WM_NCLBUTTONDOWN
|| message == WM_NCRBUTTONDOWN)) {
#else
@@ -1518,7 +1472,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
switch (message) {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_QUERYENDSESSION: {
if (sm_smActive) // bogus message from windows
RETURN(true);
@@ -1540,19 +1494,19 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// we receive the message for each toplevel window included internal hidden ones,
// but the aboutToQuit signal should be emitted only once.
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
if (endsession && !qAppPriv->aboutToQuitEmitted) {
qAppPriv->aboutToQuitEmitted = true;
int index = QApplication::staticMetaObject.indexOfSignal("aboutToQuit()");
qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0);
// since the process will be killed immediately quit() has no real effect
- qApp->quit();
+ QApplication::quit();
}
RETURN(0);
}
case WM_DISPLAYCHANGE:
- if (qApp->type() == QApplication::Tty)
+ if (QApplication::type() == QApplication::Tty)
break;
if (qt_desktopWidget) {
qt_desktopWidget->move(GetSystemMetrics(76), GetSystemMetrics(77));
@@ -1569,7 +1523,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#endif
case WM_SETTINGCHANGE:
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
// CE SIP hide/show
if (wParam == SPI_SETSIPINFO) {
QResizeEvent re(QSize(0, 0), QSize(0, 0)); // Calculated by QDesktopWidget
@@ -1578,7 +1532,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
#endif
// ignore spurious XP message when user logs in again after locking
- if (qApp->type() == QApplication::Tty)
+ if (QApplication::type() == QApplication::Tty)
break;
if (QApplication::desktopSettingsAware() && wParam != SPI_SETWORKAREA) {
widget = (QETWidget*)QWidget::find(hwnd);
@@ -1601,7 +1555,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
if (wParam == SPI_SETFONTSMOOTHINGTYPE) {
qt_win_read_cleartype_settings();
- foreach (QWidget *w, qApp->topLevelWidgets()) {
+ foreach (QWidget *w, QApplication::topLevelWidgets()) {
if (!w->isVisible())
continue;
((QETWidget *) w)->forceUpdate();
@@ -1610,7 +1564,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
case WM_SYSCOLORCHANGE:
- if (qApp->type() == QApplication::Tty)
+ if (QApplication::type() == QApplication::Tty)
break;
if (QApplication::desktopSettingsAware()) {
widget = (QETWidget*)QWidget::find(hwnd);
@@ -1662,7 +1616,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
RETURN(res);
if (qt_is_translatable_mouse_event(message)) {
- if (qApp->activePopupWidget() != 0) { // in popup mode
+ if (QApplication::activePopupWidget() != 0) { // in popup mode
POINT curPos = msg.pt;
QWidget* w = QApplication::widgetAt(curPos.x, curPos.y);
if (w)
@@ -1671,10 +1625,10 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
if (!qt_tabletChokeMouse) {
result = widget->translateMouseEvent(msg); // mouse event
-#if defined(Q_OS_WINCE) && !defined(QT_NO_CONTEXTMENU)
- if (message == WM_LBUTTONDOWN && widget != qApp->activePopupWidget()) {
+#if defined(Q_WS_WINCE) && !defined(QT_NO_CONTEXTMENU)
+ if (message == WM_LBUTTONDOWN && widget != QApplication::activePopupWidget()) {
QWidget* alienWidget = widget;
- if ((alienWidget != qApp->activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) {
+ if ((alienWidget != QApplication::activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) {
QPoint pos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
QPoint globalPos(msg.pt.x, msg.pt.y);
// In case we are using Alien, then the widget to
@@ -1693,8 +1647,8 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;
resolveAygLibs();
if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) {
- if (qApp->activePopupWidget())
- qApp->activePopupWidget()->close();
+ if (QApplication::activePopupWidget())
+ QApplication::activePopupWidget()->close();
QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
result = qt_sendSpontaneousEvent(alienWidget, &e);
}
@@ -1706,7 +1660,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// Sometimes we only get a WM_MOUSEMOVE message
// and sometimes we get both a WM_MOUSEMOVE and
// a WM_LBUTTONDOWN/UP, this creates a spurious mouse
- // press/release event, using the winPeekMessage
+ // press/release event, using the PeekMessage
// will help us fix this. This leaves us with a
// question:
// This effectively kills using the mouse AND the
@@ -1716,18 +1670,19 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
bool is_mouse_move = (message == WM_MOUSEMOVE);
if (is_mouse_move) {
MSG msg1;
- if (winPeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,
- WM_MOUSELAST, PM_NOREMOVE))
+ if (PeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,
+ WM_MOUSELAST, PM_NOREMOVE))
next_is_button = (msg1.message == WM_LBUTTONUP
|| msg1.message == WM_LBUTTONDOWN);
}
if (!is_mouse_move || (is_mouse_move && !next_is_button))
qt_tabletChokeMouse = false;
}
- } else if (message == WM95_MOUSEWHEEL) {
- result = widget->translateWheelEvent(msg);
} else {
switch (message) {
+ case WM_TOUCH:
+ result = QApplicationPrivate::instance()->translateTouchEvent(msg);
+ break;
case WM_KEYDOWN: // keyboard event
case WM_SYSKEYDOWN:
qt_keymapper_private()->updateKeyMap(msg);
@@ -1753,7 +1708,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
case WM_IME_KEYDOWN:
case WM_CHAR: {
MSG msg1;
- bool anyMsg = winPeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);
+ bool anyMsg = PeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);
if (anyMsg && msg1.message == WM_DEADCHAR) {
result = true; // consume event since there is a dead char next
break;
@@ -1772,7 +1727,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
widget = (QETWidget*)QApplication::activePopupWidget()->focusWidget()
? (QETWidget*)QApplication::activePopupWidget()->focusWidget()
: (QETWidget*)QApplication::activePopupWidget();
- else if (qApp->focusWidget())
+ else if (QApplication::focusWidget())
widget = (QETWidget*)QApplication::focusWidget();
else if (!widget || widget->internalWinId() == GetFocus()) // We faked the message to go to exactly that widget.
widget = (QETWidget*)widget->window();
@@ -1787,6 +1742,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
result = widget->translateWheelEvent(msg);
break;
@@ -1813,79 +1769,18 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
case APPCOMMAND_BASS_UP:
key = Qt::Key_BassUp;
break;
- case APPCOMMAND_BROWSER_BACKWARD:
- key = Qt::Key_Back;
- break;
- case APPCOMMAND_BROWSER_FAVORITES:
- key = Qt::Key_Favorites;
- break;
- case APPCOMMAND_BROWSER_FORWARD:
- key = Qt::Key_Forward;
- break;
- case APPCOMMAND_BROWSER_HOME:
- key = Qt::Key_HomePage;
- break;
- case APPCOMMAND_BROWSER_REFRESH:
- key = Qt::Key_Refresh;
- break;
- case APPCOMMAND_BROWSER_SEARCH:
- key = Qt::Key_Search;
- break;
- case APPCOMMAND_BROWSER_STOP:
- key = Qt::Key_Stop;
- break;
- case APPCOMMAND_LAUNCH_APP1:
- key = Qt::Key_Launch0;
- break;
- case APPCOMMAND_LAUNCH_APP2:
- key = Qt::Key_Launch1;
- break;
- case APPCOMMAND_LAUNCH_MAIL:
- key = Qt::Key_LaunchMail;
- break;
- case APPCOMMAND_LAUNCH_MEDIA_SELECT:
- key = Qt::Key_LaunchMedia;
- break;
- case APPCOMMAND_MEDIA_NEXTTRACK:
- key = Qt::Key_MediaNext;
- break;
- case APPCOMMAND_MEDIA_PLAY_PAUSE:
- key = Qt::Key_MediaPlay;
- break;
- case APPCOMMAND_MEDIA_PREVIOUSTRACK:
- key = Qt::Key_MediaPrevious;
- break;
- case APPCOMMAND_MEDIA_STOP:
- key = Qt::Key_MediaStop;
- break;
case APPCOMMAND_TREBLE_DOWN:
key = Qt::Key_TrebleDown;
break;
case APPCOMMAND_TREBLE_UP:
key = Qt::Key_TrebleUp;
break;
- case APPCOMMAND_VOLUME_DOWN:
- key = Qt::Key_VolumeDown;
- break;
- case APPCOMMAND_VOLUME_MUTE:
- key = Qt::Key_VolumeMute;
- break;
- case APPCOMMAND_VOLUME_UP:
- key = Qt::Key_VolumeUp;
- break;
- // Commands new in Windows XP
case APPCOMMAND_HELP:
key = Qt::Key_Help;
break;
case APPCOMMAND_FIND:
key = Qt::Key_Search;
break;
- case APPCOMMAND_PRINT:
- key = Qt::Key_Print;
- break;
- case APPCOMMAND_MEDIA_PLAY:
- key = Qt::Key_MediaPlay;
- break;
default:
break;
}
@@ -1894,8 +1789,8 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
QWidget *g = QWidget::keyboardGrabber();
if (g)
widget = (QETWidget*)g;
- else if (qApp->focusWidget())
- widget = (QETWidget*)qApp->focusWidget();
+ else if (QApplication::focusWidget())
+ widget = (QETWidget*)QApplication::focusWidget();
else
widget = (QETWidget*)widget->window();
if (widget->isEnabled()) {
@@ -1917,17 +1812,21 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_NCHITTEST:
if (widget->isWindow()) {
QPoint pos = widget->mapFromGlobal(QPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
// don't show resize-cursors for fixed-size widgets
QRect fs = widget->frameStrut();
if (!widget->isMinimized()) {
+ if (widget->minimumHeight() == widget->maximumHeight()) {
+ if (pos.y() < -(fs.top() - fs.left()))
+ return HTCAPTION;
+ if (pos.y() >= widget->height())
+ return HTBORDER;
+ }
if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width()))
- break;
- if (widget->minimumHeight() == widget->maximumHeight() && (pos.y() < -(fs.top() - fs.left()) || pos.y() >= widget->height()))
- break;
+ return HTBORDER;
}
}
@@ -1936,7 +1835,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#endif
case WM_SYSCOMMAND: {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
bool window_state_change = false;
Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state);
// MSDN:In WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are
@@ -1948,11 +1847,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#ifndef QT_NO_WHATSTHIS
QWhatsThis::enterWhatsThisMode();
#endif
- QT_WA({
- DefWindowProc(hwnd, WM_NCPAINT, 1, 0);
- } , {
- DefWindowProcA(hwnd, WM_NCPAINT, 1, 0);
- });
+ DefWindowProc(hwnd, WM_NCPAINT, 1, 0);
break;
#if defined(QT_NON_COMMERCIAL)
QT_NC_SYSCOMMAND
@@ -2006,12 +1901,11 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
case WM_SETTINGCHANGE:
- if ( qApp->type() == QApplication::Tty )
+ if ( QApplication::type() == QApplication::Tty )
break;
if (!msg.wParam) {
- QString area = QT_WA_INLINE(QString::fromUtf16((unsigned short *)msg.lParam),
- QString::fromLocal8Bit((char*)msg.lParam));
+ QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
if (area == QLatin1String("intl")) {
QLocalePrivate::updateSystemPrivate();
if (!widget->testAttribute(Qt::WA_SetLocale))
@@ -2019,7 +1913,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
}
else if (msg.wParam == SPI_SETICONTITLELOGFONT) {
- if (qApp->desktopSettingsAware()) {
+ if (QApplication::desktopSettingsAware()) {
widget = (QETWidget*)QWidget::find(hwnd);
if (widget && !widget->parentWidget()) {
qt_set_windows_font_resources();
@@ -2033,14 +1927,12 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
result = widget->translatePaintEvent(msg);
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_ENTERSIZEMOVE:
autoCaptureWnd = hwnd;
- QApplicationPrivate::inSizeMove = true;
break;
case WM_EXITSIZEMOVE:
autoCaptureWnd = 0;
- QApplicationPrivate::inSizeMove = false;
break;
#endif
case WM_MOVE: // move window
@@ -2062,7 +1954,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
case WM_ACTIVATE:
- if ( qApp->type() == QApplication::Tty )
+ if ( QApplication::type() == QApplication::Tty )
break;
if (ptrWTOverlap && ptrWTEnable) {
@@ -2088,19 +1980,28 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// WM_ACTIVATEAPP handles the "true" false case, as this is only when the application
// loses focus. Doing it here would result in the widget getting focus to not know
// where it got it from; it would simply get a 0 value as the old focus widget.
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
{
- if (widget->windowState() & Qt::WindowMinimized) {
- if (widget->windowState() & Qt::WindowMaximized)
- widget->showMaximized();
- else
- widget->show();
+#ifdef Q_WS_WINCE_WM
+ // On Windows mobile we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages.
+ // Thus we have to unset the minimized state explicitly. We must do this for all
+ // top-level widgets, because we get the HWND of a random widget here.
+ foreach (QWidget* tlw, QApplication::topLevelWidgets()) {
+ if (tlw->isMinimized())
+ tlw->setWindowState(tlw->windowState() & ~Qt::WindowMinimized);
}
#else
+ // On Windows CE we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages.
+ // Thus we have to unset the minimized state explicitly.
+ if (widget->windowState() & Qt::WindowMinimized)
+ widget->setWindowState(widget->windowState() & ~Qt::WindowMinimized);
+#endif // Q_WS_WINCE_WM
+
+#else
if (!(widget->windowState() & Qt::WindowMinimized)) {
#endif
// Ignore the activate message send by WindowsXP to a minimized window
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
if (widget->windowState() & Qt::WindowFullScreen)
qt_wince_hide_taskbar(widget->winId());
#endif
@@ -2127,7 +2028,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_MOUSEACTIVATE:
if (widget->window()->windowType() == Qt::Tool) {
QWidget *w = widget;
@@ -2216,7 +2117,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
result = false;
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_WINDOWPOSCHANGING:
{
result = false;
@@ -2297,12 +2198,12 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
QWidget *fw = QWidget::keyboardGrabber();
if (!fw) {
- if (qApp->activePopupWidget())
- fw = (qApp->activePopupWidget()->focusWidget()
- ? qApp->activePopupWidget()->focusWidget()
- : qApp->activePopupWidget());
- else if (qApp->focusWidget())
- fw = qApp->focusWidget();
+ if (QApplication::activePopupWidget())
+ fw = (QApplication::activePopupWidget()->focusWidget()
+ ? QApplication::activePopupWidget()->focusWidget()
+ : QApplication::activePopupWidget());
+ else if (QApplication::focusWidget())
+ fw = QApplication::focusWidget();
else if (widget)
fw = widget->window();
}
@@ -2319,7 +2220,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION:
case WM_IME_COMPOSITION: {
- QWidget *fw = qApp->focusWidget();
+ QWidget *fw = QApplication::focusWidget();
QWinInputContext *im = fw ? qobject_cast<QWinInputContext *>(fw->inputContext()) : 0;
if (fw && im) {
if(message == WM_IME_STARTCOMPOSITION)
@@ -2331,8 +2232,27 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
}
-
-#ifndef Q_OS_WINCE
+ case WM_IME_REQUEST: {
+ QWidget *fw = QApplication::focusWidget();
+ QWinInputContext *im = fw ? qobject_cast<QWinInputContext *>(fw->inputContext()) : 0;
+ if (fw && im) {
+ if(wParam == IMR_RECONVERTSTRING) {
+ int ret = im->reconvertString((RECONVERTSTRING *)lParam);
+ if (ret == -1) {
+ result = false;
+ } else {
+ return ret;
+ }
+ } else if (wParam == IMR_CONFIRMRECONVERTSTRING) {
+ RETURN(TRUE);
+ } else {
+ // in all other cases, call DefWindowProc()
+ result = false;
+ }
+ }
+ break;
+ }
+#ifndef Q_WS_WINCE
case WM_CHANGECBCHAIN:
case WM_DRAWCLIPBOARD:
#endif
@@ -2352,7 +2272,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
case WM_GETOBJECT:
{
// Ignoring all requests while starting up
- if (qApp->startingUp() || qApp->closingDown() || (DWORD)lParam != OBJID_CLIENT) {
+ if (QApplication::startingUp() || QApplication::closingDown() || (DWORD)lParam != OBJID_CLIENT) {
result = false;
break;
}
@@ -2395,11 +2315,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
text = widget->objectName();
ret = qMin<int>(wParam - 1, text.size());
text.resize(ret);
- QT_WA({
- memcpy((void *)lParam, text.utf16(), (text.size() + 1) * 2);
- }, {
- memcpy((void *)lParam, text.toLocal8Bit().data(), text.size() + 1);
- });
+ memcpy((void *)lParam, text.utf16(), (text.size() + 1) * sizeof(ushort));
delete acc;
}
if (!ret) {
@@ -2419,27 +2335,45 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
case WT_PROXIMITY:
- if (ptrWTPacketsGet) {
- bool enteredProximity = LOWORD(lParam) != 0;
- PACKET proximityBuffer[QT_TABLET_NPACKETQSIZE];
- int totalPacks = ptrWTPacketsGet(qt_tablet_context, QT_TABLET_NPACKETQSIZE, proximityBuffer);
- if (totalPacks > 0 && enteredProximity) {
- uint currentCursor = proximityBuffer[0].pkCursor;
- if (!tCursorInfo()->contains(currentCursor))
- tabletInit(currentCursor, qt_tablet_context);
- currentTabletPointer = tCursorInfo()->value(currentCursor);
+
+ #ifndef QT_NO_TABLETEVENT
+ if (ptrWTPacketsGet && ptrWTInfo) {
+ const bool enteredProximity = LOWORD(lParam) != 0;
+ PACKET proximityBuffer[1]; // we are only interested in the first packet in this case
+ const int totalPacks = ptrWTPacketsGet(qt_tablet_context, 1, proximityBuffer);
+ if (totalPacks > 0) {
+ const UINT currentCursor = proximityBuffer[0].pkCursor;
+
+ UINT csr_physid;
+ ptrWTInfo(WTI_CURSORS + currentCursor, CSR_PHYSID, &csr_physid);
+ UINT csr_type;
+ ptrWTInfo(WTI_CURSORS + currentCursor, CSR_TYPE, &csr_type);
+ const UINT deviceIdMask = 0xFF6; // device type mask && device color mask
+ quint64 uniqueId = (csr_type & deviceIdMask);
+ uniqueId = (uniqueId << 32) | csr_physid;
+
+ // initialising and updating the cursor should be done in response to
+ // WT_CSRCHANGE. We do it in WT_PROXIMITY because some wintab never send
+ // the event WT_CSRCHANGE even if asked with CXO_CSRMESSAGES
+ const QTabletCursorInfo *const globalCursorInfo = tCursorInfo();
+ if (!globalCursorInfo->contains(uniqueId))
+ tabletInit(uniqueId, csr_type, qt_tablet_context);
+
+ currentTabletPointer = globalCursorInfo->value(uniqueId);
+ tabletUpdateCursor(currentTabletPointer, currentCursor);
}
qt_tabletChokeMouse = false;
-#ifndef QT_NO_TABLETEVENT
+
QTabletEvent tabletProximity(enteredProximity ? QEvent::TabletEnterProximity
: QEvent::TabletLeaveProximity,
QPoint(), QPoint(), QPointF(), currentTabletPointer.currentDevice, currentTabletPointer.currentPointerType, 0, 0,
0, 0, 0, 0, 0, currentTabletPointer.llId);
QApplication::sendEvent(qApp, &tabletProximity);
-#endif // QT_NO_TABLETEVENT
}
+ #endif // QT_NO_TABLETEVENT
+
break;
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
case WM_SETFOCUS: {
HIMC hC;
hC = ImmGetContext(hwnd);
@@ -2452,7 +2386,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
case WM_KILLFOCUS:
if (!QWidget::find((HWND)wParam)) { // we don't get focus, so unset it now
if (!widget->hasFocus()) // work around Windows bug after minimizing/restoring
- widget = (QETWidget*)qApp->focusWidget();
+ widget = (QETWidget*)QApplication::focusWidget();
HWND focus = ::GetFocus();
//if there is a current widget and the new widget belongs to the same toplevel window
//or if the current widget was embedded into non-qt window (i.e. we won't get WM_ACTIVATEAPP)
@@ -2471,27 +2405,27 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
case WM_THEMECHANGED:
- if ((widget->windowType() == Qt::Desktop) || !qApp || qApp->closingDown()
- || qApp->type() == QApplication::Tty)
+ if ((widget->windowType() == Qt::Desktop) || !qApp || QApplication::closingDown()
+ || QApplication::type() == QApplication::Tty)
break;
if (widget->testAttribute(Qt::WA_WState_Polished))
- qApp->style()->unpolish(widget);
+ QApplication::style()->unpolish(widget);
if (widget->testAttribute(Qt::WA_WState_Polished))
- qApp->style()->polish(widget);
- widget->repolishStyle(*qApp->style());
+ QApplication::style()->polish(widget);
+ widget->repolishStyle(*QApplication::style());
if (widget->isVisible())
widget->update();
break;
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
case WM_INPUTLANGCHANGE: {
- char info[7];
- if (!GetLocaleInfoA(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
+ wchar_t info[7];
+ if (!GetLocaleInfo(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
inputcharset = CP_ACP;
} else {
- inputcharset = QString::fromLatin1(info).toInt();
+ inputcharset = QString::fromWCharArray(info).toInt();
}
QKeyMapper::changeKeyboard();
break;
@@ -2585,6 +2519,38 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
result = false;
break;
+ case WM_GESTURE: {
+ GESTUREINFO gi;
+ memset(&gi, 0, sizeof(GESTUREINFO));
+ gi.cbSize = sizeof(GESTUREINFO);
+
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ BOOL bResult = false;
+ if (qAppPriv->GetGestureInfo)
+ bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
+ if (bResult) {
+ if (gi.dwID == GID_BEGIN) {
+ // find the alien widget for the gesture position.
+ // This might not be accurate as the position is the center
+ // point of two fingers for multi-finger gestures.
+ QPoint pt(gi.ptsLocation.x, gi.ptsLocation.y);
+ QWidget *w = widget->childAt(widget->mapFromGlobal(pt));
+ qAppPriv->gestureWidget = w ? w : widget;
+ }
+ if (qAppPriv->gestureWidget)
+ static_cast<QETWidget*>(qAppPriv->gestureWidget)->translateGestureEvent(msg, gi);
+ if (qAppPriv->CloseGestureInfoHandle)
+ qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
+ if (gi.dwID == GID_END)
+ qAppPriv->gestureWidget = 0;
+ } else {
+ DWORD dwErr = GetLastError();
+ if (dwErr > 0)
+ qWarning() << "translateGestureEvent: error = " << dwErr;
+ }
+ result = true;
+ break;
+ }
default:
result = false; // event was not processed
break;
@@ -2683,19 +2649,19 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
int type = msg->message;
bool block_event = false;
-#ifndef Q_OS_WINCE
- if (type != WM_NCHITTEST)
+#ifndef Q_WS_WINCE
+ if (type != WM_NCHITTEST) {
#endif
if ((type >= WM_MOUSEFIRST && type <= WM_MOUSELAST) ||
- type == WM_MOUSEWHEEL || type == (int)WM95_MOUSEWHEEL ||
+ type == WM_MOUSEWHEEL || type == WM_MOUSEHWHEEL ||
type == WM_MOUSELEAVE ||
(type >= WM_KEYFIRST && type <= WM_KEYLAST)
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| type == WM_NCMOUSEMOVE
#endif
) {
if (type == WM_MOUSEMOVE
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
|| type == WM_NCMOUSEMOVE
#endif
) {
@@ -2713,18 +2679,19 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
} else if (type == WM_CLOSE) {
block_event = true;
}
-#ifndef Q_OS_WINCE
- else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){
- if (!top->isActiveWindow()) {
- top->activateWindow();
- } else {
- QApplication::beep();
- }
- block_event = true;
- ret = MA_NOACTIVATEANDEAT;
- } else if (type == WM_SYSCOMMAND) {
- if (!(msg->wParam == SC_RESTORE && widget->isMinimized()))
+#ifndef Q_WS_WINCE
+ else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){
+ if (!top->isActiveWindow()) {
+ top->activateWindow();
+ } else {
+ QApplication::beep();
+ }
block_event = true;
+ ret = MA_NOACTIVATEANDEAT;
+ } else if (type == WM_SYSCOMMAND) {
+ if (!(msg->wParam == SC_RESTORE && widget->isMinimized()))
+ block_event = true;
+ }
}
#endif
@@ -2768,9 +2735,9 @@ void QApplicationPrivate::openPopup(QWidget *popup)
if (popup->focusWidget()) {
popup->focusWidget()->setFocus(Qt::PopupFocusReason);
} else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup
- if (QWidget *fw = q_func()->focusWidget()) {
+ if (QWidget *fw = QApplication::focusWidget()) {
QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason);
- q_func()->sendEvent(fw, &e);
+ QApplication::sendEvent(fw, &e);
}
}
}
@@ -2797,13 +2764,13 @@ void QApplicationPrivate::closePopup(QWidget *popup)
if (!qt_nograb()) // grabbing not disabled
releaseAutoCapture();
QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget()
- : q_func()->focusWidget();
+ : QApplication::focusWidget();
if (fw) {
- if (fw != q_func()->focusWidget()) {
+ if (fw != QApplication::focusWidget()) {
fw->setFocus(Qt::PopupFocusReason);
} else {
QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
- q_func()->sendEvent(fw, &e);
+ QApplication::sendEvent(fw, &e);
}
}
} else {
@@ -2871,7 +2838,7 @@ static const ushort mouseTbl[] = {
WM_XBUTTONUP, QEvent::MouseButtonRelease, Qt::XButton1,
WM_XBUTTONDBLCLK, QEvent::MouseButtonDblClick, Qt::XButton1,
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
WM_NCMOUSEMOVE, QEvent::NonClientAreaMouseMove, 0,
WM_NCLBUTTONDOWN, QEvent::NonClientAreaMouseButtonPress, Qt::LeftButton,
WM_NCLBUTTONUP, QEvent::NonClientAreaMouseButtonRelease, Qt::LeftButton,
@@ -2926,20 +2893,11 @@ void qt_win_eatMouseMove()
// remove all those messages (usually 1) and post the last one with a
// reset button state
- MSG msg = {0, 0, 0, 0, 0, 0, 0};
- QT_WA( {
- while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
- ;
- if (msg.message == WM_MOUSEMOVE)
- PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
- }, {
- MSG msg;
- msg.message = 0;
- while (PeekMessageA(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
- ;
- if (msg.message == WM_MOUSEMOVE)
- PostMessageA(msg.hwnd, msg.message, 0, msg.lParam);
- } );
+ MSG msg = {0, 0, 0, 0, 0, {0, 0} };
+ while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
+ ;
+ if (msg.message == WM_MOUSEMOVE)
+ PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
}
// In DnD, the mouse release event never appears, so the
@@ -2974,8 +2932,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
// Compress mouse move events
if (msg.message == WM_MOUSEMOVE) {
MSG mouseMsg;
- while (winPeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST,
- WM_MOUSELAST, PM_NOREMOVE)) {
+ while (PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST,
+ WM_MOUSELAST, PM_NOREMOVE)) {
if (mouseMsg.message == WM_MOUSEMOVE) {
#define PEEKMESSAGE_IS_BROKEN 1
#ifdef PEEKMESSAGE_IS_BROKEN
@@ -2986,12 +2944,12 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
// key release events (kls 2003-05-13):
MSG keyMsg;
bool done = false;
- while (winPeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST,
- PM_NOREMOVE)) {
+ while (PeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST,
+ PM_NOREMOVE)) {
if (keyMsg.time < mouseMsg.time) {
if ((keyMsg.lParam & 0xC0000000) == 0x40000000) {
- winPeekMessage(&keyMsg, 0, keyMsg.message,
- keyMsg.message, PM_REMOVE);
+ PeekMessage(&keyMsg, 0, keyMsg.message,
+ keyMsg.message, PM_REMOVE);
} else {
done = true;
break;
@@ -3017,8 +2975,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
msgPtr->wParam = mouseMsg.wParam;
msgPtr->pt = mouseMsg.pt;
// Remove the mouse move message
- winPeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,
- WM_MOUSEMOVE, PM_REMOVE);
+ PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,
+ WM_MOUSEMOVE, PM_REMOVE);
} else {
break; // there was no more WM_MOUSEMOVE event
}
@@ -3047,7 +3005,9 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
if (alienWidget && alienWidget->internalWinId())
alienWidget = 0;
- if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove) {
+ if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove
+ || type == QEvent::TabletMove) {
+
if (!(state & Qt::MouseButtonMask))
qt_button_down = 0;
#ifndef QT_NO_CURSOR
@@ -3067,7 +3027,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
HWND id = effectiveWinId();
QWidget *mouseGrabber = QWidget::mouseGrabber();
- QWidget *activePopupWidget = qApp->activePopupWidget();
+ QWidget *activePopupWidget = QApplication::activePopupWidget();
if (mouseGrabber) {
if (!activePopupWidget || (activePopupWidget == this && !rect().contains(widgetPos)))
id = mouseGrabber->effectiveWinId();
@@ -3160,7 +3120,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
return false;
replayPopupMouseEvent = false;
- QWidget* activePopupWidget = qApp->activePopupWidget();
+ QWidget* activePopupWidget = QApplication::activePopupWidget();
QWidget *target = activePopupWidget;
const QPoint globalPos(gpos.x, gpos.y);
@@ -3178,6 +3138,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
popupButtonFocus = popupChild;
break;
case QEvent::MouseButtonRelease:
+ case QEvent::TabletRelease:
+
releaseAfter = true;
break;
default:
@@ -3188,10 +3150,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
if (popupButtonFocus) {
target = popupButtonFocus;
} else if (popupChild) {
- // forward mouse events to the popup child. mouse move events
- // are only forwarded to popup children that enable mouse tracking.
- if (type != QEvent::MouseMove || popupChild->hasMouseTracking())
- target = popupChild;
+ target = popupChild;
}
pos = target->mapFromGlobal(globalPos);
@@ -3221,7 +3180,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
}
if (type == QEvent::MouseButtonPress
- && qApp->activePopupWidget() != activePopupWidget
+ && QApplication::activePopupWidget() != activePopupWidget
&& replayPopupMouseEvent) {
// the popup dissappeared. Replay the event
QWidget* w = QApplication::widgetAt(gpos.x, gpos.y);
@@ -3235,10 +3194,10 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
POINT widgetpt = gpos;
ScreenToClient(hwndTarget, &widgetpt);
LPARAM lParam = MAKELPARAM(widgetpt.x, widgetpt.y);
- winPostMessage(hwndTarget, msg.message, msg.wParam, lParam);
+ PostMessage(hwndTarget, msg.message, msg.wParam, lParam);
}
} else if (type == QEvent::MouseButtonRelease && button == Qt::RightButton
- && qApp->activePopupWidget() == activePopupWidget) {
+ && QApplication::activePopupWidget() == activePopupWidget) {
// popup still alive and received right-button-release
#if !defined(QT_NO_CONTEXTMENU)
QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, globalPos,
@@ -3302,12 +3261,12 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
state = translateButtonState(GET_KEYSTATE_WPARAM(msg.wParam), 0, 0);
int delta;
- if (msg.message == WM_MOUSEWHEEL)
+ if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL)
delta = (short) HIWORD (msg.wParam);
else
delta = (int) msg.wParam;
- Qt::Orientation orient = (state&Qt::AltModifier
+ Qt::Orientation orient = (msg.message == WM_MOUSEHWHEEL || state&Qt::AltModifier
#if 0
// disabled for now - Trenton's one-wheel mouse makes trouble...
// "delta" for usual wheels is +-120. +-240 seems to indicate
@@ -3321,6 +3280,13 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
#endif
) ? Qt::Horizontal : Qt::Vertical;
+ // according to the MSDN documentation on WM_MOUSEHWHEEL:
+ // a positive value indicates that the wheel was rotated to the right;
+ // a negative value indicates that the wheel was rotated to the left.
+ // Qt defines this value as the exact opposite, so we have to flip the value!
+ if (msg.message == WM_MOUSEHWHEEL)
+ delta = -delta;
+
QPoint globalPos;
globalPos.rx() = (short)LOWORD (msg.lParam);
@@ -3341,7 +3307,7 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
// send the event to the widget or its ancestors
{
- QWidget* popup = qApp->activePopupWidget();
+ QWidget* popup = QApplication::activePopupWidget();
if (popup && w->window() != popup)
popup->close();
#ifndef QT_NO_WHEELEVENT
@@ -3357,8 +3323,8 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
}
// send the event to the widget that has the focus or its ancestors, if different
- if (w != qApp->focusWidget() && (w = qApp->focusWidget())) {
- QWidget* popup = qApp->activePopupWidget();
+ if (w != QApplication::focusWidget() && (w = QApplication::focusWidget())) {
+ QWidget* popup = QApplication::activePopupWidget();
if (popup && w->window() != popup)
popup->close();
#ifndef QT_NO_WHEELEVENT
@@ -3379,61 +3345,57 @@ bool QETWidget::translateWheelEvent(const MSG &msg)
// the following is adapted from the wintab syspress example (public domain)
/* -------------------------------------------------------------------------- */
-static void tabletInit(UINT wActiveCsr, HCTX hTab)
+// Initialize the "static" information of a cursor device (pen, airbrush, etc).
+// The QTabletDeviceData is initialized with the data that do not change in time
+// (number of button, type of device, etc) but do not initialize the variable data
+// (e.g.: pen or eraser)
+#ifndef QT_NO_TABLETEVENT
+
+static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab)
{
+ Q_ASSERT(ptrWTInfo);
+ Q_ASSERT(ptrWTGet);
+
+ Q_ASSERT(!tCursorInfo()->contains(uniqueId));
+
/* browse WinTab's many info items to discover pressure handling. */
- if (ptrWTInfo && ptrWTGet) {
- AXIS np;
- LOGCONTEXT lc;
- BYTE wPrsBtn;
- BYTE logBtns[32];
- UINT size;
-
- /* discover the LOGICAL button generated by the pressure channel. */
- /* get the PHYSICAL button from the cursor category and run it */
- /* through that cursor's button map (usually the identity map). */
- wPrsBtn = (BYTE)-1;
- ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_NPBUTTON, &wPrsBtn);
- size = ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_BUTTONMAP, &logBtns);
- if ((UINT)wPrsBtn < size)
- wPrsBtn = logBtns[wPrsBtn];
-
- /* get the current context for its device variable. */
- ptrWTGet(hTab, &lc);
-
- /* get the size of the pressure axis. */
- QTabletDeviceData tdd;
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_NPRESSURE, &np);
- tdd.minPressure = int(np.axMin);
- tdd.maxPressure = int(np.axMax);
-
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_TPRESSURE, &np);
- tdd.minTanPressure = int(np.axMin);
- tdd.maxTanPressure = int(np.axMax);
-
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_X, &np);
- tdd.minX = int(np.axMin);
- tdd.maxX = int(np.axMax);
-
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_Y, &np);
- tdd.minY = int(np.axMin);
- tdd.maxY = int(np.axMax);
-
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_Z, &np);
- tdd.minZ = int(np.axMin);
- tdd.maxZ = int(np.axMax);
-
- int csr_type,
- csr_physid;
- ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_TYPE, &csr_type);
- ptrWTInfo(WTI_CURSORS + wActiveCsr, CSR_PHYSID, &csr_physid);
- tdd.llId = csr_type & 0x0F06;
- tdd.llId = (tdd.llId << 24) | csr_physid;
-#ifndef QT_NO_TABLETEVENT
- if (((csr_type & 0x0006) == 0x0002) && ((csr_type & 0x0F06) != 0x0902)) {
- tdd.currentDevice = QTabletEvent::Stylus;
- } else {
- switch (csr_type & 0x0F06) {
+ AXIS np;
+ LOGCONTEXT lc;
+
+ /* get the current context for its device variable. */
+ ptrWTGet(hTab, &lc);
+
+ /* get the size of the pressure axis. */
+ QTabletDeviceData tdd;
+ tdd.llId = uniqueId;
+
+ ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_NPRESSURE, &np);
+ tdd.minPressure = int(np.axMin);
+ tdd.maxPressure = int(np.axMax);
+
+ ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_TPRESSURE, &np);
+ tdd.minTanPressure = int(np.axMin);
+ tdd.maxTanPressure = int(np.axMax);
+
+ LOGCONTEXT lcMine;
+
+ /* get default region */
+ ptrWTInfo(WTI_DEFCONTEXT, 0, &lcMine);
+
+ tdd.minX = 0;
+ tdd.maxX = int(lcMine.lcInExtX) - int(lcMine.lcInOrgX);
+
+ tdd.minY = 0;
+ tdd.maxY = int(lcMine.lcInExtY) - int(lcMine.lcInOrgY);
+
+ tdd.minZ = 0;
+ tdd.maxZ = int(lcMine.lcInExtZ) - int(lcMine.lcInOrgZ);
+
+ const uint cursorTypeBitMask = 0x0F06; // bitmask to find the specific cursor type (see Wacom FAQ)
+ if (((csr_type & 0x0006) == 0x0002) && ((csr_type & cursorTypeBitMask) != 0x0902)) {
+ tdd.currentDevice = QTabletEvent::Stylus;
+ } else {
+ switch (csr_type & cursorTypeBitMask) {
case 0x0802:
tdd.currentDevice = QTabletEvent::Stylus;
break;
@@ -3451,26 +3413,34 @@ static void tabletInit(UINT wActiveCsr, HCTX hTab)
break;
default:
tdd.currentDevice = QTabletEvent::NoDevice;
- }
- }
-
- switch (wActiveCsr % 3) {
- case 2:
- tdd.currentPointerType = QTabletEvent::Eraser;
- break;
- case 1:
- tdd.currentPointerType = QTabletEvent::Pen;
- break;
- case 0:
- tdd.currentPointerType = QTabletEvent::Cursor;
- break;
- default:
- tdd.currentPointerType = QTabletEvent::UnknownPointer;
}
+ }
+ tCursorInfo()->insert(uniqueId, tdd);
+}
#endif // QT_NO_TABLETEVENT
- tCursorInfo()->insert(wActiveCsr, tdd);
+
+// Update the "dynamic" informations of a cursor device (pen, airbrush, etc).
+// The dynamic information is the information of QTabletDeviceData that can change
+// in time (eraser or pen if a device is turned around).
+#ifndef QT_NO_TABLETEVENT
+
+static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor)
+{
+ switch (currentCursor % 3) { // %3 for dual track
+ case 0:
+ tdd.currentPointerType = QTabletEvent::Cursor;
+ break;
+ case 1:
+ tdd.currentPointerType = QTabletEvent::Pen;
+ break;
+ case 2:
+ tdd.currentPointerType = QTabletEvent::Eraser;
+ break;
+ default:
+ tdd.currentPointerType = QTabletEvent::UnknownPointer;
}
}
+#endif // QT_NO_TABLETEVENT
bool QETWidget::translateTabletEvent(const MSG &msg, PACKET *localPacketBuf,
int numPackets)
@@ -3531,13 +3501,34 @@ bool QETWidget::translateTabletEvent(const MSG &msg, PACKET *localPacketBuf,
}
QPoint globalPos(qRound(hiResGlobal.x()), qRound(hiResGlobal.y()));
+ if (t == QEvent::TabletPress)
+ {
+ qt_button_down = QApplication::widgetAt(globalPos);
+ }
+
// make sure the tablet event get's sent to the proper widget...
- QWidget *w = QApplication::widgetAt(globalPos);
+ QWidget *w = 0;
+
if (qt_button_down)
w = qt_button_down; // Pass it to the thing that's grabbed it.
+ else
+ w = QApplication::widgetAt(globalPos);
if (!w)
w = this;
+
+ if (t == QEvent::TabletRelease)
+ {
+ if (qt_win_ignoreNextMouseReleaseEvent) {
+ qt_win_ignoreNextMouseReleaseEvent = false;
+ if (qt_button_down && qt_button_down->internalWinId() == autoCaptureWnd) {
+ releaseAutoCapture();
+ qt_button_down = 0;
+ }
+ }
+
+ }
+
QPoint localPos = w->mapFromGlobal(globalPos);
#ifndef QT_NO_TABLETEVENT
if (currentTabletPointer.currentDevice == QTabletEvent::Airbrush) {
@@ -3585,6 +3576,10 @@ bool QETWidget::translateTabletEvent(const MSG &msg, PACKET *localPacketBuf,
}
extern bool qt_is_gui_used;
+
+
+#ifndef QT_NO_TABLETEVENT
+
static void initWinTabFunctions()
{
#if defined(Q_OS_WINCE)
@@ -3595,20 +3590,15 @@ static void initWinTabFunctions()
QLibrary library(QLatin1String("wintab32"));
if (library.load()) {
- QT_WA({
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
- ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
- } , {
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoA");
- ptrWTGet = (PtrWTGet)library.resolve("WTGetA");
- });
-
+ ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
+ ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable");
ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap");
ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet");
}
#endif // Q_OS_WINCE
}
+#endif // QT_NO_TABLETEVENT
//
@@ -3679,7 +3669,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
WORD b = HIWORD(msg.lParam);
QSize oldSize = size();
QSize newSize(a, b);
-#ifdef Q_OS_WINCE_WM
+#ifdef Q_WS_WINCE_WM
if (isFullScreen() && (oldSize.width() == newSize.height()) && (oldSize.height() == newSize.width()))
qt_wince_hide_taskbar(internalWinId());
#endif
@@ -3691,7 +3681,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
// Capture SIZE_MINIMIZED without preceding WM_SYSCOMMAND
// (like Windows+M)
if (msg.wParam == SIZE_MINIMIZED && !isMinimized()) {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
const QString title = windowIconText();
if (!title.isEmpty())
d_func()->setWindowTitle_helper(title);
@@ -3703,7 +3693,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
hideChildren(true);
}
} else if (msg.wParam != SIZE_MINIMIZED && isMinimized()) {
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
const QString title = windowTitle();
if (!title.isEmpty())
d_func()->setWindowTitle_helper(title);
@@ -3749,7 +3739,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
QPoint oldPos = geometry().topLeft();
QPoint newCPos(a, b);
// Ignore silly Windows move event to wild pos after iconify.
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
if (!IsIconic(internalWinId()) && newCPos != oldPos) {
#endif
cr.moveTopLeft(newCPos);
@@ -3761,7 +3751,7 @@ bool QETWidget::translateConfigEvent(const MSG &msg)
QMoveEvent * e = new QMoveEvent(newCPos, oldPos);
QApplication::postEvent(this, e);
}
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
}
#endif
}
@@ -3782,6 +3772,45 @@ bool QETWidget::translateCloseEvent(const MSG &)
return d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
+bool QETWidget::translateGestureEvent(const MSG &, const GESTUREINFO &gi)
+{
+ const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+ QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos);
+ if (alienWidget && alienWidget->internalWinId())
+ alienWidget = 0;
+ QWidget *widget = alienWidget ? alienWidget : this;
+
+ QNativeGestureEvent event;
+ event.sequenceId = gi.dwSequenceID;
+ event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+ event.argument = gi.ullArguments;
+
+ switch (gi.dwID) {
+ case GID_BEGIN:
+ event.gestureType = QNativeGestureEvent::GestureBegin;
+ break;
+ case GID_END:
+ event.gestureType = QNativeGestureEvent::GestureEnd;
+ break;
+ case GID_ZOOM:
+ event.gestureType = QNativeGestureEvent::Zoom;
+ break;
+ case GID_PAN:
+ event.gestureType = QNativeGestureEvent::Pan;
+ break;
+ case GID_ROTATE:
+ event.gestureType = QNativeGestureEvent::Rotate;
+ break;
+ case GID_TWOFINGERTAP:
+ case GID_ROLLOVER:
+ default:
+ break;
+ }
+ if (event.gestureType != QNativeGestureEvent::None)
+ qt_sendSpontaneousEvent(widget, &event);
+ return true;
+}
+
void QApplication::setCursorFlashTime(int msecs)
{
@@ -3803,7 +3832,7 @@ int QApplication::cursorFlashTime()
void QApplication::setDoubleClickInterval(int ms)
{
-#ifndef Q_OS_WINCE
+#ifndef Q_WS_WINCE
SetDoubleClickTime(ms);
#endif
QApplicationPrivate::mouse_double_click_time = ms;
@@ -3835,11 +3864,7 @@ void QApplication::setWheelScrollLines(int n)
#ifdef SPI_SETWHEELSCROLLLINES
if (n < 0)
n = 0;
- QT_WA({
- SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
- } , {
- SystemParametersInfoA(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
- });
+ SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
#else
QApplicationPrivate::wheel_scroll_lines = n;
#endif
@@ -3849,11 +3874,7 @@ int QApplication::wheelScrollLines()
{
#ifdef SPI_GETWHEELSCROLLLINES
uint i = 3;
- QT_WA({
- SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
- } , {
- SystemParametersInfoA(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
- });
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
if (i > INT_MAX)
i = INT_MAX;
return i;
@@ -3898,8 +3919,7 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect)
if (QColormap::instance().depth() < 16)
return false;
- if (!effect_override && desktopSettingsAware()
- && !(QSysInfo::WindowsVersion == QSysInfo::WV_95 || QSysInfo::WindowsVersion == QSysInfo::WV_NT)) {
+ if (!effect_override && desktopSettingsAware()) {
// we know that they can be used when we are here
BOOL enabled = false;
UINT api;
@@ -3908,33 +3928,22 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect)
api = SPI_GETMENUANIMATION;
break;
case Qt::UI_FadeMenu:
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- return false;
api = SPI_GETMENUFADE;
break;
case Qt::UI_AnimateCombo:
api = SPI_GETCOMBOBOXANIMATION;
break;
case Qt::UI_AnimateTooltip:
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- api = SPI_GETMENUANIMATION;
- else
- api = SPI_GETTOOLTIPANIMATION;
+ api = SPI_GETTOOLTIPANIMATION;
break;
case Qt::UI_FadeTooltip:
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- return false;
api = SPI_GETTOOLTIPFADE;
break;
default:
api = SPI_GETUIEFFECTS;
break;
}
- QT_WA({
- SystemParametersInfo(api, 0, &enabled, 0);
- } , {
- SystemParametersInfoA(api, 0, &enabled, 0);
- });
+ SystemParametersInfo(api, 0, &enabled, 0);
return enabled;
}
@@ -3983,4 +3992,90 @@ void QSessionManager::cancel()
#endif //QT_NO_SESSIONMANAGER
+
+PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0;
+PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0;
+PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0;
+
+void QApplicationPrivate::initializeMultitouch_sys()
+{
+ QLibrary library(QLatin1String("user32"));
+ // MinGW (g++ 3.4.5) accepts only C casts.
+ RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
+ GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
+ CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
+
+ touchInputIDToTouchPointID.clear();
+}
+
+void QApplicationPrivate::cleanupMultitouch_sys()
+{
+ touchInputIDToTouchPointID.clear();
+}
+
+bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
+{
+ QWidget *widgetForHwnd = QWidget::find(msg.hwnd);
+ if (!widgetForHwnd)
+ return false;
+
+ QRect screenGeometry = QApplication::desktop()->screenGeometry(widgetForHwnd);
+
+ QList<QTouchEvent::TouchPoint> touchPoints;
+
+ QVector<TOUCHINPUT> winTouchInputs(msg.wParam);
+ memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchInputs.count());
+ Qt::TouchPointStates allStates = 0;
+ QApplicationPrivate::GetTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
+ for (int i = 0; i < winTouchInputs.count(); ++i) {
+ const TOUCHINPUT &touchInput = winTouchInputs.at(i);
+
+ int touchPointID = touchInputIDToTouchPointID.value(touchInput.dwID, -1);
+ if (touchPointID == -1) {
+ touchPointID = touchInputIDToTouchPointID.count();
+ touchInputIDToTouchPointID.insert(touchInput.dwID, touchPointID);
+ }
+
+ QTouchEvent::TouchPoint touchPoint(touchPointID);
+
+ // update state
+ QPointF screenPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.));
+ QRectF screenRect;
+ if (touchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
+ screenRect.setSize(QSizeF(qreal(touchInput.cxContact) / qreal(100.),
+ qreal(touchInput.cyContact) / qreal(100.)));
+ screenRect.moveCenter(screenPos);
+
+ Qt::TouchPointStates state;
+ if (touchInput.dwFlags & TOUCHEVENTF_DOWN) {
+ state = Qt::TouchPointPressed;
+ } else if (touchInput.dwFlags & TOUCHEVENTF_UP) {
+ state = Qt::TouchPointReleased;
+ } else {
+ state = (screenPos == touchPoint.screenPos()
+ ? Qt::TouchPointStationary
+ : Qt::TouchPointMoved);
+ }
+ if (touchInput.dwFlags & TOUCHEVENTF_PRIMARY)
+ state |= Qt::TouchPointPrimary;
+ touchPoint.setState(state);
+ touchPoint.setScreenRect(screenRect);
+ touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(),
+ screenPos.y() / screenGeometry.height()));
+
+ allStates |= state;
+
+ touchPoints.append(touchPoint);
+ }
+ QApplicationPrivate::CloseTouchInputHandle((HANDLE) msg.lParam);
+
+ if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) {
+ // all touch points released, forget the ids we've seen, they may not be reused
+ touchInputIDToTouchPointID.clear();
+ }
+
+ translateRawTouchEvent(widgetForHwnd, QTouchEvent::TouchScreen, touchPoints);
+ return true;
+}
+
QT_END_NAMESPACE