Qt 4.8
qapplication_win.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifdef Q_WS_WINCE
43 #include "qguifunctions_wince.h"
44 #include "qmenubar.h"
45 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
46 extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp
47 extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.cpp
48 extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
49 extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.cpp
50 #endif
51 #ifdef Q_WS_WINCE_WM
52 #include <windowsm.h>
53 #include <tpcshell.h>
54 #ifdef QT_WINCE_GESTURES
55 #ifndef QT_NO_GESTURES
56 #include <gesture.h>
57 #endif
58 #endif
59 #endif
60 
61 #include "qapplication.h"
62 #include "qdesktopwidget.h"
63 #include "qevent.h"
64 #include "private/qeventdispatcher_win_p.h"
65 #include "qeventloop.h"
66 #include "qclipboard.h"
67 #include "qcursor.h"
68 #include "qdatetime.h"
69 #include "qpointer.h"
70 #include "qhash.h"
71 #include "qmetaobject.h"
72 #include "qmime.h"
73 #include "qpainter.h"
74 #include "qpixmapcache.h"
75 #include "qsessionmanager.h"
76 #include "qstyle.h"
77 #include "qwhatsthis.h" // ######## dependency
78 #include "qwidget.h"
79 #include "qcolormap.h"
80 #include "qlayout.h"
81 #include "qtooltip.h"
82 #include "qt_windows.h"
83 #include "qscrollbar.h"
84 #if defined(QT_NON_COMMERCIAL)
85 #include "qnc_win.h"
86 #endif
87 #include "private/qwininputcontext_p.h"
88 #include "private/qcursor_p.h"
89 #include "private/qmath_p.h"
90 #include "private/qapplication_p.h"
91 #include "private/qbackingstore_p.h"
92 #include "private/qwindowsurface_raster_p.h"
93 #include "qdebug.h"
94 #include <private/qkeymapper_p.h>
95 #include <private/qlocale_p.h>
96 #include <private/qsystemlibrary_p.h>
97 #include "qevent_p.h"
98 
99 //#define ALIEN_DEBUG
100 
101 #ifndef QT_NO_THREAD
102 #include "qmutex.h"
103 #endif
104 
105 #ifndef QT_NO_ACCESSIBILITY
106 #include "qaccessible.h"
107 
108 #include <oleacc.h>
109 #ifndef WM_GETOBJECT
110 #define WM_GETOBJECT 0x003D
111 #endif
112 #endif // QT_NO_ACCESSIBILITY
113 
114 #if !defined(WINABLEAPI)
115 # if defined(Q_WS_WINCE)
116 # include <bldver.h>
117 # endif
118 # if !defined(Q_WS_WINCE)
119 # include <winable.h>
120 # endif
121 #endif
122 
123 #ifndef QT_NO_GESTURES
124 # ifndef GID_ZOOM
125 # define GID_ZOOM 3
126 # define GID_TWOFINGERTAP 6
127 # define GID_PRESSANDTAP 7
128 # define GID_ROLLOVER GID_PRESSANDTAP
129 # endif
130 #endif
131 
132 #ifndef WM_TOUCH
133 # define WM_TOUCH 0x0240
134 #endif
135 
136 #ifndef TOUCHEVENTF_MOVE
137 # define TOUCHEVENTF_MOVE 0x0001
138 # define TOUCHEVENTF_DOWN 0x0002
139 # define TOUCHEVENTF_UP 0x0004
140 # define TOUCHEVENTF_INRANGE 0x0008
141 # define TOUCHEVENTF_PRIMARY 0x0010
142 # define TOUCHEVENTF_NOCOALESCE 0x0020
143 # define TOUCHEVENTF_PEN 0x0040
144 # define TOUCHEVENTF_PALM 0x0080
145 
146 # define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001
147 # define TOUCHINPUTMASKF_EXTRAINFO 0x0002
148 # define TOUCHINPUTMASKF_CONTACTAREA 0x0004
149 
150 typedef struct tagTOUCHINPUT
151 {
152  LONG x;
153  LONG y;
155  DWORD dwID;
156  DWORD dwFlags;
157  DWORD dwMask;
158  DWORD dwTime;
160  DWORD cxContact;
161  DWORD cyContact;
163 
164 #endif
165 
166 #include <windowsx.h>
167 #include <limits.h>
168 #include <string.h>
169 #include <ctype.h>
170 #include <stdio.h>
171 #include <math.h>
172 
173 #define PACKETDATA (PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE \
174  | PK_ORIENTATION | PK_CURSOR | PK_Z)
175 #define PACKETMODE 0
176 
177 #include <wintab.h>
178 #ifndef CSR_TYPE
179 #define CSR_TYPE 20 // Some old Wacom wintab.h may not provide this constant.
180 #endif
181 #include <pktdef.h>
182 
183 #if defined(__CYGWIN32__)
184 #define __INSIDE_CYGWIN32__
185 #include <mywinsock.h>
186 #endif
187 
188 #ifndef IMR_RECONVERTSTRING
189 #define IMR_RECONVERTSTRING 4
190 #endif
191 
192 #ifndef IMR_CONFIRMRECONVERTSTRING
193 #define IMR_CONFIRMRECONVERTSTRING 0x0005
194 #endif
196 
197 #ifdef Q_WS_WINCE
198 #ifndef SHRG_RETURNCMD
199 struct SHRGINFO {
200  DWORD cbSize;
202  POINT ptDown;
203  DWORD dwFlags;
204 };
205 #define GN_CONTEXTMENU 1000
206 #define SHRG_RETURNCMD 0x00000001
207 #define SHRG_NOANIMATION 0x00000010
208 #endif
209 
210 #ifndef SPI_SETSIPINFO
211 #define SPI_SETSIPINFO 224
212 #endif
213 
214 #ifndef QT_NO_GESTURES
215 typedef DWORD (API *AygRecognizeGesture)(SHRGINFO*);
217 static bool aygResolved = false;
218 static void resolveAygLibs()
219 {
220  if (!aygResolved) {
221  QSystemLibrary ayglib(QLatin1String("aygshell"));
222  ptrRecognizeGesture = (AygRecognizeGesture) ayglib.resolve("SHRecognizeGesture");
223  aygResolved = true;
224  }
225 }
226 #endif // QT_NO_GESTURES
227 
228 #endif
229 
230 #ifndef SPI_SETFONTSMOOTHINGTYPE
231 # define SPI_SETFONTSMOOTHINGTYPE 0x200B
232 #endif
233 #ifndef SPI_GETFONTSMOOTHINGTYPE
234 # define SPI_GETFONTSMOOTHINGTYPE 0x200A
235 #endif
236 #ifndef FE_FONTSMOOTHINGCLEARTYPE
237 # define FE_FONTSMOOTHINGCLEARTYPE 0x0002
238 #endif
239 
242 Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default
243 
244 typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL);
245 typedef BOOL (API *PtrWTClose)(HCTX);
246 typedef UINT (API *PtrWTInfo)(UINT, UINT, LPVOID);
247 typedef BOOL (API *PtrWTEnable)(HCTX, BOOL);
248 typedef BOOL (API *PtrWTOverlap)(HCTX, BOOL);
249 typedef int (API *PtrWTPacketsGet)(HCTX, int, LPVOID);
250 typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT);
251 typedef int (API *PtrWTQueueSizeGet)(HCTX);
252 typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int);
253 
254 static PtrWTInfo ptrWTInfo = 0;
258 static PtrWTGet ptrWTGet = 0;
259 
260 static PACKET localPacketBuf[QT_TABLET_NPACKETQSIZE]; // our own tablet packet queue.
261 HCTX qt_tablet_context; // the hardware context for the tablet (like a window handle)
264 
265 // flags for extensions for special Languages, currently only for RTL languages
267 
268 #ifndef QT_NO_TABLETEVENT
269 static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab);
270 static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor);
271 static void initWinTabFunctions(); // resolve the WINTAB api functions
272 #endif // QT_NO_TABLETEVENT
273 
274 
275 #ifndef QT_NO_ACCESSIBILITY
276 extern IAccessible *qt_createWindowsAccessible(QAccessibleInterface *object);
277 #endif // QT_NO_ACCESSIBILITY
278 
279 extern bool qt_tabletChokeMouse;
280 extern QWidget* qt_get_tablet_widget();
281 extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
282 extern QRegion qt_dirtyRegion(QWidget *);
283 
287 
288 // from qregion_win.cpp
289 extern HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom);
290 
291 // support for on-the-fly changes of the XP theme engine
292 #ifndef WM_THEMECHANGED
293 #define WM_THEMECHANGED 0x031A
294 #endif
295 #ifndef COLOR_MENUHILIGHT
296 #define COLOR_MENUHILIGHT 29
297 #define COLOR_MENUBAR 30
298 #endif
299 
300 // support for xbuttons
301 #ifndef WM_XBUTTONDOWN
302 #define WM_XBUTTONDOWN 0x020B
303 #define WM_XBUTTONUP 0x020C
304 #define WM_XBUTTONDBLCLK 0x020D
305 #endif
306 #ifndef GET_KEYSTATE_WPARAM
307 #define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
308 #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
309 #define XBUTTON1 0x0001
310 #define XBUTTON2 0x0002
311 #endif
312 #ifndef MK_XBUTTON1
313 #define MK_XBUTTON1 0x0020
314 #define MK_XBUTTON2 0x0040
315 #endif
316 
317 // support for multi-media-keys
318 #ifndef WM_APPCOMMAND
319 #define WM_APPCOMMAND 0x0319
320 #endif
321 
322 #ifndef FAPPCOMMAND_MOUSE
323 #define FAPPCOMMAND_MOUSE 0x8000
324 #define FAPPCOMMAND_KEY 0
325 #define FAPPCOMMAND_OEM 0x1000
326 #define FAPPCOMMAND_MASK 0xF000
327 #define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
328 #define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
329 #define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
330 #define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
331 #define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
332 
333 #define APPCOMMAND_BROWSER_BACKWARD 1
334 #define APPCOMMAND_BROWSER_FORWARD 2
335 #define APPCOMMAND_BROWSER_REFRESH 3
336 #define APPCOMMAND_BROWSER_STOP 4
337 #define APPCOMMAND_BROWSER_SEARCH 5
338 #define APPCOMMAND_BROWSER_FAVORITES 6
339 #define APPCOMMAND_BROWSER_HOME 7
340 #define APPCOMMAND_VOLUME_MUTE 8
341 #define APPCOMMAND_VOLUME_DOWN 9
342 #define APPCOMMAND_VOLUME_UP 10
343 #define APPCOMMAND_MEDIA_NEXTTRACK 11
344 #define APPCOMMAND_MEDIA_PREVIOUSTRACK 12
345 #define APPCOMMAND_MEDIA_STOP 13
346 #define APPCOMMAND_MEDIA_PLAY_PAUSE 14
347 #define APPCOMMAND_LAUNCH_MAIL 15
348 #define APPCOMMAND_LAUNCH_MEDIA_SELECT 16
349 #define APPCOMMAND_LAUNCH_APP1 17
350 #define APPCOMMAND_LAUNCH_APP2 18
351 #define APPCOMMAND_BASS_DOWN 19
352 #define APPCOMMAND_BASS_BOOST 20
353 #define APPCOMMAND_BASS_UP 21
354 #define APPCOMMAND_TREBLE_DOWN 22
355 #define APPCOMMAND_TREBLE_UP 23
356 #endif // FAPPCOMMAND_MOUSE
357 
358 // New commands from Windows XP (some even Sp1)
359 #ifndef APPCOMMAND_MICROPHONE_VOLUME_MUTE
360 #define APPCOMMAND_MICROPHONE_VOLUME_MUTE 24
361 #define APPCOMMAND_MICROPHONE_VOLUME_DOWN 25
362 #define APPCOMMAND_MICROPHONE_VOLUME_UP 26
363 #define APPCOMMAND_HELP 27
364 #define APPCOMMAND_FIND 28
365 #define APPCOMMAND_NEW 29
366 #define APPCOMMAND_OPEN 30
367 #define APPCOMMAND_CLOSE 31
368 #define APPCOMMAND_SAVE 32
369 #define APPCOMMAND_PRINT 33
370 #define APPCOMMAND_UNDO 34
371 #define APPCOMMAND_REDO 35
372 #define APPCOMMAND_COPY 36
373 #define APPCOMMAND_CUT 37
374 #define APPCOMMAND_PASTE 38
375 #define APPCOMMAND_REPLY_TO_MAIL 39
376 #define APPCOMMAND_FORWARD_MAIL 40
377 #define APPCOMMAND_SEND_MAIL 41
378 #define APPCOMMAND_SPELL_CHECK 42
379 #define APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE 43
380 #define APPCOMMAND_MIC_ON_OFF_TOGGLE 44
381 #define APPCOMMAND_CORRECTION_LIST 45
382 #define APPCOMMAND_MEDIA_PLAY 46
383 #define APPCOMMAND_MEDIA_PAUSE 47
384 #define APPCOMMAND_MEDIA_RECORD 48
385 #define APPCOMMAND_MEDIA_FAST_FORWARD 49
386 #define APPCOMMAND_MEDIA_REWIND 50
387 #define APPCOMMAND_MEDIA_CHANNEL_UP 51
388 #define APPCOMMAND_MEDIA_CHANNEL_DOWN 52
389 #endif // APPCOMMAND_MICROPHONE_VOLUME_MUTE
390 
391 #if (_WIN32_WINNT < 0x0400)
392 // This struct is defined in winuser.h if the _WIN32_WINNT >= 0x0400 -- in the
393 // other cases we have to define it on our own.
394 typedef struct tagTRACKMOUSEEVENT {
395  DWORD cbSize;
396  DWORD dwFlags;
397  HWND hwndTrack;
398  DWORD dwHoverTime;
400 #endif
401 #ifndef WM_MOUSELEAVE
402 #define WM_MOUSELEAVE 0x02A3
403 #endif
404 
406 #include "private/qwidget_p.h"
408 
409 static int translateButtonState(int s, int type, int button);
410 
411 // ##### get rid of this!
412 QRgb qt_colorref2qrgb(COLORREF col)
413 {
414  return qRgb(GetRValue(col),GetGValue(col),GetBValue(col));
415 }
416 
417 
418 /*****************************************************************************
419  Internal variables and functions
420  *****************************************************************************/
421 
422 static HWND curWin = 0; // current window
423 static HDC displayDC = 0; // display device context
424 
425 // Session management
426 static bool sm_blockUserInput = false;
427 static bool sm_smActive = false;
429 static bool sm_cancel;
430 
431 static bool replayPopupMouseEvent = false; // replay handling when popups close
432 
433 // ignore the next release event if return from a modal widget
435 
436 
437 #if defined(QT_DEBUG)
438 static bool appNoGrab = false; // mouse/keyboard grabbing
439 #endif
440 
441 static bool app_do_modal = false; // modal mode
445 static bool qt_try_modal(QWidget *, MSG *, int& ret);
446 
447 QWidget *qt_button_down = 0; // widget got last button-down
449 
450 static HWND autoCaptureWnd = 0;
451 static HWND imeParentWnd = 0;
452 static void setAutoCapture(HWND); // automatic capture
453 static void releaseAutoCapture();
454 
455 static void unregWinClasses();
456 
457 extern QCursor *qt_grab_cursor();
458 
459 #if defined(Q_WS_WIN)
460 #define __export
461 #endif
462 
463 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
464 
465 class QETWidget : public QWidget // event translator widget
466 {
467 public:
468  QWExtra *xtra() { return d_func()->extraData(); }
469  QTLWExtra *topData() { return d_func()->topData(); }
470  QTLWExtra *maybeTopData() { return d_func()->maybeTopData(); }
471  void syncBackingStore(const QRegion &rgn) { d_func()->syncBackingStore(rgn); }
472  void syncBackingStore() { d_func()->syncBackingStore(); }
473  QWidgetData *dataPtr() { return data; }
474  QWidgetPrivate *dptr() { return d_func(); }
475  QRect frameStrut() const { return d_func()->frameStrut(); }
476  bool winEvent(MSG *m, long *r) { return QWidget::winEvent(m, r); }
477  void markFrameStrutDirty() { data->fstrut_dirty = 1; }
478  bool translateMouseEvent(const MSG &msg);
479  bool translateWheelEvent(const MSG &msg);
480  bool translatePaintEvent(const MSG &msg);
481  bool translateConfigEvent(const MSG &msg);
482  bool translateCloseEvent(const MSG &msg);
483  bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets);
484 #ifndef QT_NO_GESTURES
485  bool translateGestureEvent(const MSG &msg, const GESTUREINFO &gi);
486 #endif
487  void repolishStyle(QStyle &style);
488  inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); }
489  inline void hideChildren(bool spontaneous) { d_func()->hideChildren(spontaneous); }
490  inline uint testWindowState(uint teststate){ return dataPtr()->window_state & teststate; }
491  inline void setWindowTitle_helper(const QString &title) { d_func()->setWindowTitle_helper(title); }
492  inline void forceUpdate() {
493  QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
494  if (tlwExtra && tlwExtra->backingStore)
495  tlwExtra->backingStore->markDirty(rect(), this, true, true);
496  }
497 };
498 
499 // need to get default font?
500 extern bool qt_app_has_font;
501 
502 extern QFont qt_LOGFONTtoQFont(LOGFONT& lf,bool scale);
503 
505 {
506  // Do the color settings
507  QPalette pal;
509  QColor(qt_colorref2qrgb(GetSysColor(COLOR_WINDOWTEXT))));
511  QColor(qt_colorref2qrgb(GetSysColor(COLOR_BTNFACE))));
513  QColor(qt_colorref2qrgb(GetSysColor(COLOR_BTNHIGHLIGHT))));
515  QColor(qt_colorref2qrgb(GetSysColor(COLOR_BTNSHADOW))));
516  pal.setColor(QPalette::Mid, pal.button().color().darker(150));
518  QColor(qt_colorref2qrgb(GetSysColor(COLOR_WINDOWTEXT))));
520  QColor(qt_colorref2qrgb(GetSysColor(COLOR_BTNHIGHLIGHT))));
522  QColor(qt_colorref2qrgb(GetSysColor(COLOR_WINDOW))));
524  QColor(qt_colorref2qrgb(GetSysColor(COLOR_BTNFACE))));
526  QColor(qt_colorref2qrgb(GetSysColor(COLOR_BTNTEXT))));
528  QColor(qt_colorref2qrgb(GetSysColor(COLOR_3DLIGHT))));
530  QColor(qt_colorref2qrgb(GetSysColor(COLOR_3DDKSHADOW))));
532  QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHT))));
534  QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHTTEXT))));
535 
536 #if defined(Q_WS_WINCE)
537  // ### hardcoded until I find out how to get it from the system settings.
539  pal.setColor(QPalette::Link, pal.highlight().color().light(130));
540  // Background == Base on Windows CE
542  pal.setColor(QPalette::Background, pal.base().color());
543 #else
546 #endif
547 
548 
549 
554 
555  if (pal.midlight() == pal.button())
556  pal.setColor(QPalette::Midlight, pal.button().color().lighter(110));
557  if (pal.background() != pal.base()) {
560  }
561 
562  const QColor bg = pal.background().color();
563  const QColor fg = pal.foreground().color(), btn = pal.button().color();
564  QColor disabled((fg.red()+btn.red())/2,(fg.green()+btn.green())/2,
565  (fg.blue()+btn.blue())/2);
566  pal.setColorGroup(QPalette::Disabled, pal.foreground(), pal.button(), pal.light(),
567  pal.dark(), pal.mid(), pal.text(), pal.brightText(), pal.base(), pal.background() );
572  QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHT))));
574  QColor(qt_colorref2qrgb(GetSysColor(COLOR_HIGHLIGHTTEXT))));
576 
578 
580 
581  QColor ttip(qt_colorref2qrgb(GetSysColor(COLOR_INFOBK)));
582 
583  QColor ttipText(qt_colorref2qrgb(GetSysColor(COLOR_INFOTEXT)));
584  {
585 #ifndef QT_NO_TOOLTIP
586  QPalette tiplabel(pal);
587  tiplabel.setColor(QPalette::All, QPalette::Button, ttip);
588  tiplabel.setColor(QPalette::All, QPalette::Window, ttip);
589  tiplabel.setColor(QPalette::All, QPalette::Text, ttipText);
590  tiplabel.setColor(QPalette::All, QPalette::WindowText, ttipText);
591  tiplabel.setColor(QPalette::All, QPalette::ButtonText, ttipText);
592  tiplabel.setColor(QPalette::All, QPalette::Button, ttip);
593  tiplabel.setColor(QPalette::All, QPalette::Window, ttip);
594  tiplabel.setColor(QPalette::All, QPalette::Text, ttipText);
595  tiplabel.setColor(QPalette::All, QPalette::WindowText, ttipText);
596  tiplabel.setColor(QPalette::All, QPalette::ButtonText, ttipText);
597  const QColor fg = tiplabel.foreground().color(), btn = tiplabel.button().color();
598  QColor disabled((fg.red()+btn.red())/2,(fg.green()+btn.green())/2,
599  (fg.blue()+btn.blue())/2);
600  tiplabel.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
601  tiplabel.setColor(QPalette::Disabled, QPalette::Text, disabled);
604  QToolTip::setPalette(tiplabel);
605 #endif //QT_NO_TOOLTIP
606  }
607 }
608 
610 {
611 #ifndef Q_WS_WINCE
612  NONCLIENTMETRICS ncm;
613  ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
614  SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
615 
616  QFont menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont, true);
617  QFont messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont, true);
618  QFont statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont, true);
619  QFont titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont, true);
620 
621  LOGFONT lfIconTitleFont;
622  SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
623  QFont iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont, true);
624 
625  QApplication::setFont(menuFont, "QMenu");
626  QApplication::setFont(menuFont, "QMenuBar");
627  QApplication::setFont(messageFont, "QMessageBox");
628  QApplication::setFont(statusFont, "QTipLabel");
629  QApplication::setFont(statusFont, "QStatusBar");
630  QApplication::setFont(titleFont, "Q3TitleBar");
631  QApplication::setFont(titleFont, "QWorkspaceTitleBar");
632  QApplication::setFont(iconTitleFont, "QAbstractItemView");
633  QApplication::setFont(iconTitleFont, "QDockWidgetTitle");
634 
635 #else
636  LOGFONT lf;
637  HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
638  GetObject(stockFont, sizeof(lf), &lf);
639  QFont systemFont = qt_LOGFONTtoQFont(lf, true);
641  QFont smallerFont = systemFont;
642  if (qt_wince_is_mobile()) {
643  smallerFont.setPointSize(systemFont.pointSize()-1);
644  QApplication::setFont(smallerFont, "QTabBar");
645  smallerFont.setBold(true);
646  QApplication::setFont(smallerFont, "QAbstractButton");
647  }
648 #endif// Q_WS_WINCE
649 }
650 
652 {
653  UINT result = 0;
654 #ifdef Q_OS_WINCE
655  if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &result, 0))
656  qt_cleartype_enabled = result;
657 #else
658  if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0))
660 #endif
661 
662  int winSmooth;
663  if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) {
664  qt_fontsmoothing_gamma = winSmooth / qreal(1000.0);
665  } else {
667  }
668 
669  // Safeguard ourselves against corrupt registry values...
672 }
673 
675 {
677  (void) QApplication::style(); // trigger creation of application style
680 }
681 
683 {
685  QColor menuCol(qt_colorref2qrgb(GetSysColor(COLOR_MENU)));
686  QColor menuText(qt_colorref2qrgb(GetSysColor(COLOR_MENUTEXT)));
687  BOOL isFlat = false;
690  SystemParametersInfo(SPI_GETFLATMENU, 0, &isFlat, 0);
691  QPalette menu(pal);
692  // we might need a special color group for the menu.
694  menu.setColor(QPalette::Active, QPalette::Text, menuText);
697  QColor disabled(qt_colorref2qrgb(GetSysColor(COLOR_GRAYTEXT)));
699  menu.setColor(QPalette::Disabled, QPalette::Text, disabled);
701  QColor(qt_colorref2qrgb(GetSysColor(
703  && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
704  && isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT))));
722  QApplication::setPalette(menu, "QMenu");
723 
725  && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) && isFlat) {
726  QColor menubar(qt_colorref2qrgb(GetSysColor(COLOR_MENUBAR)));
730  }
731  QApplication::setPalette(menu, "QMenuBar");
732 }
733 
735 {
736  QList<QObject*> children = widget->children();
737  for (int i = 0; i < children.size(); ++i) {
738  QObject *o = children.at(i);
739  if(!o->isWidgetType())
740  continue;
741  if (QWidget *w = static_cast<QWidget *>(o))
743  }
744 #ifndef QT_NO_SCROLLBAR
745  if (qobject_cast<QScrollBar*>(widget))
746  widget->updateGeometry();
747 #endif
748 }
749 
750 
751 /*****************************************************************************
752  qt_init() - initializes Qt for Windows
753  *****************************************************************************/
754 
755 typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID);
759 static BOOL WINAPI qt_updateLayeredWindowIndirect(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *info)
760 {
761  return (*ptrUpdateLayeredWindow)(hwnd, info->hdcDst, info->pptDst, info->psize, info->hdcSrc,
762  info->pptSrc, info->crKey, info->pblend, info->dwFlags);
763 }
764 
766 {
767 
768  int argc = priv->argc;
769  char **argv = priv->argv;
770  int i, j;
771 
772  // Get command line params
773 
774  j = argc ? 1 : 0;
775  for (i=1; i<argc; i++) {
776  if (argv[i] && *argv[i] != '-') {
777  argv[j++] = argv[i];
778  continue;
779  }
780 #if defined(QT_DEBUG)
781  if (qstrcmp(argv[i], "-nograb") == 0)
782  appNoGrab = !appNoGrab;
783  else
784 #endif // QT_DEBUG
785  argv[j++] = argv[i];
786  }
787  if(j < priv->argc) {
788  priv->argv[j] = 0;
789  priv->argc = j;
790  }
791 
792 #ifndef Q_WS_WINCE
793  // No message boxes but important ones
795 #endif
796 
797 #ifndef Q_WS_WINCE
798  // Initialize OLE/COM
799  // S_OK means success and S_FALSE means that it has already
800  // been initialized
801  HRESULT r;
802  r = OleInitialize(0);
803  if (r != S_OK && r != S_FALSE) {
804  qWarning("Qt: Could not initialize OLE (error %x)", (unsigned int)r);
805  }
806 #endif
807 
808  // Misc. initialization
809 #if defined(QT_DEBUG) && !defined(Q_WS_WINCE)
810  GdiSetBatchLimit(1);
811 #endif
812 
813  // initialize key mapper
815 
818 #ifndef QT_NO_CURSOR
821 #endif
822  qApp->setObjectName(priv->appName());
823 
824  // default font
825 #ifndef Q_WS_WINCE
826  HGDIOBJ stockFont = GetStockObject(DEFAULT_GUI_FONT);
827 #else
828  HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
829 #endif
830 
831  LOGFONT lf;
832  GetObject(stockFont, sizeof(lf), &lf);
833  QFont systemFont = qt_LOGFONTtoQFont(lf, true);
834 
835 #ifndef Q_WS_WINCE
836  if (systemFont.family() == QLatin1String("MS Shell Dlg")) {
837  systemFont.setFamily(QLatin1String("MS Shell Dlg 2"));
838  }
839 #endif
840 
842 
843  // QFont::locale_init(); ### Uncomment when it does something on Windows
844 
847 
848 #ifndef QT_NO_TABLETEVENT
850 #endif // QT_NO_TABLETEVENT
851 
852 #ifndef QT_NO_IM
854 #endif
855 
856  // Read the initial cleartype settings...
858  qt_win_owndc_required = false;
859 
860  extern void qt_win_initialize_directdraw();
862 
863 #ifndef Q_OS_WINCE
864  QSystemLibrary user32(QLatin1String("user32"));
865  ptrUpdateLayeredWindowIndirect = (PtrUpdateLayeredWindowIndirect)user32.resolve("UpdateLayeredWindowIndirect");
866  ptrUpdateLayeredWindow = (PtrUpdateLayeredWindow)user32.resolve("UpdateLayeredWindow");
867 
868  if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect)
869  ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect;
870 
871  // Notify Vista and Windows 7 that we support highter DPI settings
872  ptrSetProcessDPIAware = (PtrSetProcessDPIAware)user32.resolve("SetProcessDPIAware");
873  if (ptrSetProcessDPIAware)
875 #endif
876 
877 #ifndef QT_NO_GESTURES
878  priv->GetGestureInfo = 0;
879  priv->GetGestureExtraArgs = 0;
880  priv->CloseGestureInfoHandle = 0;
881  priv->SetGestureConfig = 0;
882  priv->GetGestureConfig = 0;
883  priv->BeginPanningFeedback = 0;
884  priv->UpdatePanningFeedback = 0;
885  priv->EndPanningFeedback = 0;
886 
887 #if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES)
888  priv->GetGestureInfo = (PtrGetGestureInfo) &TKGetGestureInfo;
889  priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments;
890 #elif !defined(Q_WS_WINCE)
891  #if !defined(QT_NO_NATIVE_GESTURES)
892  priv->GetGestureInfo = (PtrGetGestureInfo)user32.resolve("GetGestureInfo");
893  priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs)user32.resolve("GetGestureExtraArgs");
894  priv->CloseGestureInfoHandle = (PtrCloseGestureInfoHandle)user32.resolve("CloseGestureInfoHandle");
895  priv->SetGestureConfig = (PtrSetGestureConfig)user32.resolve("SetGestureConfig");
896  priv->GetGestureConfig = (PtrGetGestureConfig)user32.resolve("GetGestureConfig");
897  #endif // QT_NO_NATIVE_GESTURES
898  QSystemLibrary libTheme(QLatin1String("uxtheme"));
899  priv->BeginPanningFeedback = (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback");
900  priv->UpdatePanningFeedback = (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback");
901  priv->EndPanningFeedback = (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback");
902 #endif
903 #endif // QT_NO_GESTURES
904 }
905 
906 /*****************************************************************************
907  qt_cleanup() - cleans up when the application is finished
908  *****************************************************************************/
909 
911 {
912  unregWinClasses();
914 
915 #ifndef QT_NO_CURSOR
918 #endif
919  QFont::cleanup();
921  if (displayDC) {
922  ReleaseDC(0, displayDC);
923  displayDC = 0;
924  }
925 
926 #ifndef QT_NO_IM
929 #endif
930 
931 #ifndef Q_WS_WINCE
932  // Deinitialize OLE/COM
933  OleUninitialize();
934 #endif
935 }
936 
937 
938 /*****************************************************************************
939  Platform specific global and internal functions
940  *****************************************************************************/
941 
942 Q_GUI_EXPORT HDC qt_win_display_dc() // get display DC
943 {
944  Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());
945  if (!displayDC)
946  displayDC = GetDC(0);
947  return displayDC;
948 }
949 
950 bool qt_nograb() // application no-grab option
951 {
952 #if defined(QT_DEBUG)
953  return appNoGrab;
954 #else
955  return false;
956 #endif
957 }
958 
960 Q_GLOBAL_STATIC(WinClassNameHash, winclassNames)
961 
962 //
963 // If 0 is passed as the widget pointer, register a window class
964 // for QWidget as default. This is used in QGLTemporaryContext
965 // during GL initialization, where we don't want to use temporary
966 // QWidgets or QGLWidgets, neither do we want to have separate code
967 // to register window classes.
968 //
969 const QString qt_reg_winclass(QWidget *w) // register window class
970 {
971  Qt::WindowFlags flags = w ? w->windowFlags() : (Qt::WindowFlags)0;
972  Qt::WindowFlags type = flags & Qt::WindowType_Mask;
973 
974  uint style;
975  bool icon;
976  QString cname;
977  if (w && qt_widget_private(w)->isGLWidget) {
978  cname = QLatin1String("QGLWidget");
979  style = CS_DBLCLKS;
980 #ifndef Q_WS_WINCE
981  style |= CS_OWNDC;
982 #endif
983  icon = true;
984  } else if (w && (flags & Qt::MSWindowsOwnDC)) {
985  cname = QLatin1String("QWidgetOwnDC");
986  style = CS_DBLCLKS;
987 #ifndef Q_WS_WINCE
988  style |= CS_OWNDC;
989 #endif
990  icon = true;
991  } else if (w && (type == Qt::Tool || type == Qt::ToolTip)) {
992  style = CS_DBLCLKS;
993  if (type == Qt::ToolTip || w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) {
996  style |= CS_DROPSHADOW;
997  }
998  cname = QLatin1String("QToolTip");
999  } else {
1000  cname = QLatin1String("QTool");
1001  }
1002 #ifndef Q_WS_WINCE
1003  style |= CS_SAVEBITS;
1004 #endif
1005  icon = false;
1006  } else if (w && (type == Qt::Popup)) {
1007  cname = QLatin1String("QPopup");
1008  style = CS_DBLCLKS;
1009 #ifndef Q_WS_WINCE
1010  style |= CS_SAVEBITS;
1011 #endif
1014  style |= CS_DROPSHADOW;
1015  icon = false;
1016  } else {
1017  cname = QLatin1String("QWidget");
1018  style = CS_DBLCLKS;
1019  icon = true;
1020  }
1021 
1022 #ifndef Q_WS_WINCE
1023  // force CS_OWNDC when the GL graphics system is
1024  // used as the default renderer
1026  style |= CS_OWNDC;
1027 #endif
1028 
1029 #ifdef Q_OS_WINCE
1030  // We need to register the classes with the
1031  // unique ID on WinCE to make sure we can
1032  // move the windows to the front when starting
1033  // a second instance.
1034  wchar_t uniqueAppID[MAX_PATH];
1035  GetModuleFileName(0, uniqueAppID, MAX_PATH);
1036  cname = QString::number(RegisterWindowMessage(
1037  (const wchar_t *) QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1Char('\\'),
1038  QLatin1Char('_')).utf16()));
1039 #endif
1040 
1041  // since multiple Qt versions can be used in one process
1042  // each one has to have window class names with a unique name
1043  // The first instance gets the unmodified name; if the class
1044  // has already been registered by another instance of Qt then
1045  // add an instance-specific ID, the address of the window proc.
1046  static int classExists = -1;
1047 
1048  if (classExists == -1) {
1049  WNDCLASS wcinfo;
1050  classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (wchar_t*)cname.utf16(), &wcinfo);
1051  classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
1052  }
1053 
1054  if (classExists)
1055  cname += QString::number((quintptr)QtWndProc);
1056 
1057  if (winclassNames()->contains(cname)) // already registered in our list
1058  return cname;
1059 
1060 #ifndef Q_WS_WINCE
1061  WNDCLASSEX wc;
1062  wc.cbSize = sizeof(WNDCLASSEX);
1063 #else
1064  WNDCLASS wc;
1065 #endif
1066  wc.style = style;
1067  wc.lpfnWndProc = (WNDPROC)QtWndProc;
1068  wc.cbClsExtra = 0;
1069  wc.cbWndExtra = 0;
1070  wc.hInstance = qWinAppInst();
1071  if (icon) {
1072  wc.hIcon = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
1073 #ifndef Q_WS_WINCE
1074  if (wc.hIcon) {
1075  int sw = GetSystemMetrics(SM_CXSMICON);
1076  int sh = GetSystemMetrics(SM_CYSMICON);
1077  wc.hIconSm = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, sw, sh, 0);
1078  } else {
1079  wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
1080  wc.hIconSm = 0;
1081  }
1082 #endif
1083  } else {
1084  wc.hIcon = 0;
1085 #ifndef Q_WS_WINCE
1086  wc.hIconSm = 0;
1087 #endif
1088  }
1089  wc.hCursor = 0;
1090 #ifndef Q_WS_WINCE
1091  HBRUSH brush = 0;
1092  if (w && !qt_widget_private(w)->isGLWidget)
1093  brush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
1094  wc.hbrBackground = brush;
1095 #else
1096  wc.hbrBackground = 0;
1097 #endif
1098  wc.lpszMenuName = 0;
1099  wc.lpszClassName = (wchar_t*)cname.utf16();
1100 
1101 #ifndef Q_WS_WINCE
1102  ATOM atom = RegisterClassEx(&wc);
1103 #else
1104  ATOM atom = RegisterClass(&wc);
1105 #endif
1106 
1107 #ifndef QT_NO_DEBUG
1108  if (!atom)
1109  qErrnoWarning("QApplication::regClass: Registering window class failed.");
1110 #else
1111  Q_UNUSED(atom);
1112 #endif
1113 
1114  winclassNames()->insert(cname, 1);
1115  return cname;
1116 }
1117 
1119 {
1120  return qt_reg_winclass(0);
1121 }
1122 
1123 static void unregWinClasses()
1124 {
1125  WinClassNameHash *hash = winclassNames();
1127  while (it != hash->constEnd()) {
1128  UnregisterClass((wchar_t*)it.key().utf16(), qWinAppInst());
1129  ++it;
1130  }
1131  hash->clear();
1132 }
1133 
1134 
1135 /*****************************************************************************
1136  Safe configuration (move,resize,setGeometry) mechanism to avoid
1137  recursion when processing messages.
1138  *****************************************************************************/
1139 
1141  WId id; // widget to be configured
1142  int req; // 0=move, 1=resize, 2=setGeo
1143  int x, y, w, h; // request parameters
1144 };
1145 
1147 
1148 void qWinRequestConfig(WId id, int req, int x, int y, int w, int h)
1149 {
1150  if (!configRequests) // create queue
1151  configRequests = new QList<QWinConfigRequest*>;
1153  r->id = id; // create new request
1154  r->req = req;
1155  r->x = x;
1156  r->y = y;
1157  r->w = w;
1158  r->h = h;
1159  configRequests->append(r); // store request in queue
1160 }
1161 
1162 static void qWinProcessConfigRequests() // perform requests in queue
1163 {
1164  if (!configRequests)
1165  return;
1166  QWinConfigRequest *r;
1167  for (;;) {
1168  if (configRequests->isEmpty())
1169  break;
1170  r = configRequests->takeLast();
1171  QWidget *w = QWidget::find(r->id);
1172  QRect rect(r->x, r->y, r->w, r->h);
1173  int req = r->req;
1174  delete r;
1175 
1176  if ( w ) { // widget exists
1178  return; // biting our tail
1179  if (req == 0)
1180  w->move(rect.topLeft());
1181  else if (req == 1)
1182  w->resize(rect.size());
1183  else
1184  w->setGeometry(rect);
1185  }
1186  }
1187  delete configRequests;
1188  configRequests = 0;
1189 }
1190 
1191 
1192 /*****************************************************************************
1193  GUI event dispatcher
1194  *****************************************************************************/
1195 
1197 {
1199 public:
1200  QGuiEventDispatcherWin32(QObject *parent = 0);
1201  bool processEvents(QEventLoop::ProcessEventsFlags flags);
1202 };
1203 
1205  : QEventDispatcherWin32(parent)
1206 {
1208 }
1209 
1210 bool QGuiEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
1211 {
1213  return false;
1214 
1215  if (configRequests) // any pending configs?
1217 
1218  return true;
1219 }
1220 
1222 {
1223  Q_Q(QApplication);
1224  if (q->type() != QApplication::Tty)
1225  eventDispatcher = new QGuiEventDispatcherWin32(q);
1226  else
1227  eventDispatcher = new QEventDispatcherWin32(q);
1228 }
1229 
1230 /*****************************************************************************
1231  Platform specific QApplication members
1232  *****************************************************************************/
1233 
1234 #ifdef QT3_SUPPORT
1235 void QApplication::setMainWidget(QWidget *mainWidget)
1236 {
1237  QApplicationPrivate::main_widget = mainWidget;
1238  if (QApplicationPrivate::main_widget && windowIcon().isNull()
1240  setWindowIcon(QApplicationPrivate::main_widget->windowIcon());
1241 }
1242 #endif
1243 
1244 #ifndef QT_NO_CURSOR
1245 
1246 /*****************************************************************************
1247  QApplication cursor stack
1248  *****************************************************************************/
1249 
1250 void QApplication::setOverrideCursor(const QCursor &cursor)
1251 {
1252  qApp->d_func()->cursor_list.prepend(cursor);
1253  SetCursor(qApp->d_func()->cursor_list.first().handle());
1254 }
1255 
1257 {
1258  if (qApp->d_func()->cursor_list.isEmpty())
1259  return;
1260  qApp->d_func()->cursor_list.removeFirst();
1261 
1262  if (!qApp->d_func()->cursor_list.isEmpty()) {
1263  SetCursor(qApp->d_func()->cursor_list.first().handle());
1264  } else {
1265  QWidget *w = QWidget::find(curWin);
1266  if (w)
1267  SetCursor(w->cursor().handle());
1268  else
1269  SetCursor(QCursor(Qt::ArrowCursor).handle());
1270  }
1271 }
1272 
1273 #endif
1274 
1275 /*
1276  Internal function called from QWidget::setCursor()
1277  force is true if this function is called from dispatchEnterLeave, it means that the
1278  mouse is actually directly under this widget.
1279 */
1280 
1281 #ifndef QT_NO_CURSOR
1282 void qt_win_set_cursor(QWidget *w, bool force)
1283 {
1284  static QPointer<QWidget> lastUnderMouse = 0;
1285  if (force) {
1286  lastUnderMouse = w;
1287  } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
1288  && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
1289  w = lastUnderMouse;
1290  }
1291 
1292  if (!curWin && w && w->internalWinId())
1293  return;
1294  QWidget* cW = w && !w->internalWinId() ? w : QWidget::find(curWin);
1295  if (!cW || cW->window() != w->window() ||
1296  !cW->isVisible() || !cW->underMouse() || QApplication::overrideCursor())
1297  return;
1298 
1299  SetCursor(cW->cursor().handle());
1300 }
1301 #endif // QT_NO_CURSOR
1302 
1303 Qt::KeyboardModifiers qt_win_getKeyboardModifiers()
1304 {
1305  Qt::KeyboardModifiers modifiers = Qt::NoModifier;
1306  if (GetKeyState(VK_SHIFT) < 0)
1307  modifiers |= Qt::ShiftModifier;
1308  if (GetKeyState(VK_CONTROL) < 0)
1309  modifiers |= Qt::ControlModifier;
1310  if (GetKeyState(VK_MENU) < 0)
1311  modifiers |= Qt::AltModifier;
1312  return modifiers;
1313 }
1314 
1315 Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
1316 {
1317  return qt_win_getKeyboardModifiers();
1318 }
1319 
1320 /*****************************************************************************
1321  Routines to find a Qt widget from a screen position
1322  *****************************************************************************/
1323 
1325 {
1326  POINT p;
1327  HWND win;
1328  QWidget *w;
1329  p.x = pos.x();
1330  p.y = pos.y();
1331  win = WindowFromPoint(p);
1332  if (!win)
1333  return 0;
1334 
1335  w = QWidget::find(win);
1336  while (!w && win) {
1337  win = GetParent(win);
1338  w = QWidget::find(win);
1339  }
1340  return w ? w->window() : 0;
1341 }
1342 
1343 void QApplication::beep()
1344 {
1345  MessageBeep(MB_OK);
1346 }
1347 
1348 static void alert_widget(QWidget *widget, int duration)
1349 {
1350 #ifdef Q_OS_WINCE
1351  Q_UNUSED(widget);
1352  Q_UNUSED(duration);
1353 #else
1354  bool stopFlash = duration < 0;
1355 
1356  if (widget && (!widget->isActiveWindow() || stopFlash)) {
1357  DWORD timeOut = GetCaretBlinkTime();
1358  if (timeOut <= 0)
1359  timeOut = 250;
1360 
1361  UINT flashCount;
1362  if (duration == 0)
1363  flashCount = 10;
1364  else
1365  flashCount = duration/timeOut;
1366 
1367  FLASHWINFO info;
1368  info.cbSize = sizeof(info);
1369  info.hwnd = widget->window()->winId();
1370  info.dwFlags = stopFlash ? FLASHW_STOP : FLASHW_TRAY;
1371  info.dwTimeout = stopFlash ? 0 : timeOut;
1372  info.uCount = stopFlash ? 0 : flashCount;
1373 
1374  FlashWindowEx(&info);
1375  }
1376 #endif
1377 }
1378 
1379 void QApplication::alert(QWidget *widget, int duration)
1380 {
1381  if (!QApplicationPrivate::checkInstance("alert"))
1382  return;
1383 
1384  if (widget) {
1385  alert_widget(widget, duration);
1386  } else {
1387  const QWidgetList toplevels(topLevelWidgets());
1388  for (int i = 0; i < toplevels.count(); ++i) {
1389  QWidget *topLevel = toplevels.at(i);
1390  alert_widget(topLevel, duration);
1391  }
1392  }
1393 }
1394 
1396 {
1398 }
1399 
1400 
1401 /*****************************************************************************
1402  Main event loop
1403  *****************************************************************************/
1404 
1406 
1407 void QApplication::winFocus(QWidget *widget, bool gotFocus)
1408 {
1409  if (d_func()->inPopupMode()) // some delayed focus event to ignore
1410  return;
1411  if (gotFocus) {
1412  setActiveWindow(widget);
1414  && (QApplicationPrivate::active_window->windowType() == Qt::Dialog)) {
1415  // raise the entire application, not just the dialog
1417 #ifndef Q_WS_WINCE
1418  while(mw->parentWidget() && (mw->windowType() == Qt::Dialog))
1419  mw = mw->parentWidget()->window();
1421  SetWindowPos(mw->internalWinId(), HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1422 #else
1423  // On Desktop Windows, we set the first parent of the dialog on top
1424  // Child windows will be automatically set above again.
1425  // On Windows CE we pass no parent in CreateWindowEx as otherwise
1426  // dialogs get embedded into the parent window. Thus we need to
1427  // manually iterate and reactivate all windows from bottom up.
1428  QList<QWidget*> raiseList;
1429  raiseList.push_back(mw);
1430  while(mw->parentWidget() && (mw->windowType() == Qt::Dialog)) {
1431  mw = mw->parentWidget()->window();
1432  raiseList.push_back(mw);
1433  }
1434  while(!raiseList.isEmpty()) {
1435  mw = raiseList.takeLast();
1437  HWND state = HWND_TOP;
1439  state = HWND_BOTTOM;
1440  else if (mw->windowFlags() & Qt::WindowStaysOnTopHint)
1441  state = HWND_TOPMOST;
1442  SetWindowPos(mw->internalWinId(), state, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1443  }
1444  }
1445 #endif
1446  }
1447  } else {
1448  setActiveWindow(0);
1449  }
1450 }
1451 
1452 
1453 //
1454 // QtWndProc() receives all messages from the main event loop
1455 //
1456 
1457 static bool inLoop = false;
1458 static int inputcharset = CP_ACP;
1459 
1460 #define RETURN(x) { inLoop=false;return x; }
1461 
1462 static bool qt_is_translatable_mouse_event(UINT message)
1463 {
1464  return (((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) ||
1465  (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK))
1466  && message != WM_MOUSEWHEEL
1467  && message != WM_MOUSEHWHEEL)
1468 
1469 #ifndef Q_WS_WINCE
1470  || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK)
1471 #endif
1472  ;
1473 }
1474 
1475 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
1476 {
1477  bool result = true;
1478  QEvent::Type evt_type = QEvent::None;
1479  QETWidget *widget = 0;
1480 
1481  // there is no need to process pakcets from tablet unless
1482  // it is actually on the tablet, a flag to let us know...
1483  int nPackets; // the number of packets we get from the queue
1484 
1485  long res = 0;
1486  if (!qApp) // unstable app state
1487 #ifndef QT_NO_IM
1488  RETURN(QWinInputContext::DefWindowProc(hwnd,message,wParam,lParam))
1489 #else
1490  return res;
1491 #endif // QT_NO_IM
1492  QScopedLoopLevelCounter loopLevelCounter(QThreadData::get2(qApp->thread()));
1493 
1494 #if 0
1495  // make sure we update widgets also when the user resizes
1496  if (inLoop && qApp->loopLevel())
1497  qApp->sendPostedEvents(0, QEvent::Paint);
1498 #endif
1499 
1500  inLoop = true;
1501 
1502  MSG msg;
1503  msg.hwnd = hwnd; // create MSG structure
1504  msg.message = message; // time and pt fields ignored
1505  msg.wParam = wParam;
1506  msg.lParam = lParam;
1507  msg.pt.x = GET_X_LPARAM(lParam);
1508  msg.pt.y = GET_Y_LPARAM(lParam);
1509  // If it's a non-client-area message the coords are screen coords, otherwise they are
1510  // client coords.
1511 #ifndef Q_WS_WINCE
1512  if (message < WM_NCMOUSEMOVE || message > WM_NCMBUTTONDBLCLK)
1513 #endif
1514  ClientToScreen(msg.hwnd, &msg.pt);
1515 
1516  /*
1517  // sometimes the autograb is not released, so the clickevent is sent
1518  // to the wrong window. We ignore this for now, because it doesn't
1519  // cause any problems.
1520  if (msg.message == WM_LBUTTONDOWN || msg.message == WM_RBUTTONDOWN || msg.message == WM_MBUTTONDOWN) {
1521  HWND handle = WindowFromPoint(msg.pt);
1522  if (msg.hwnd != handle) {
1523  msg.hwnd = handle;
1524  hwnd = handle;
1525  }
1526  }
1527  */
1528 
1529 #if defined(QT_NON_COMMERCIAL)
1530  QT_NC_WNDPROC
1531 #endif
1532 
1533  // send through app filter
1534  if (qApp->filterEvent(&msg, &res))
1535  return res;
1536 
1537  // close any opened ime candidate window (enabled only on a popup widget)
1538  if (imeParentWnd && QApplication::activePopupWidget()
1539  && (message == WM_MBUTTONDOWN || message == WM_XBUTTONDOWN
1540  || message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN
1541 #ifndef Q_WS_WINCE
1542  || message == WM_NCMBUTTONDOWN || message == WM_NCLBUTTONDOWN
1543  || message == WM_NCRBUTTONDOWN)) {
1544 #else
1545  )) {
1546 #endif
1547  ::SendMessage(imeParentWnd, WM_IME_ENDCOMPOSITION, 0, 0);
1548  }
1549 
1550  switch (message) {
1551 #ifndef Q_WS_WINCE
1552 #ifndef QT_NO_SESSIONMANAGER
1553  case WM_QUERYENDSESSION: {
1554  if (sm_smActive) // bogus message from windows
1555  RETURN(true);
1556 
1557  sm_smActive = true;
1558  sm_blockUserInput = true; // prevent user-interaction outside interaction windows
1559  sm_cancel = false;
1560  if (qt_session_manager_self)
1561  qApp->commitData(*qt_session_manager_self);
1562  if (lParam & ENDSESSION_LOGOFF) {
1563  _flushall();
1564  }
1565  RETURN(!sm_cancel);
1566  }
1567  case WM_ENDSESSION: {
1568  sm_smActive = false;
1569  sm_blockUserInput = false;
1570  bool endsession = (bool) wParam;
1571 
1572  // we receive the message for each toplevel window included internal hidden ones,
1573  // but the aboutToQuit signal should be emitted only once.
1575  if (endsession && !qAppPriv->aboutToQuitEmitted) {
1576  qAppPriv->aboutToQuitEmitted = true;
1577  int index = QApplication::staticMetaObject.indexOfSignal("aboutToQuit()");
1578  qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0);
1579  // since the process will be killed immediately quit() has no real effect
1581  }
1582 
1583  RETURN(0);
1584  }
1585 #endif
1586  case WM_DISPLAYCHANGE:
1588  break;
1589  if (qt_desktopWidget) {
1590  qt_desktopWidget->move(GetSystemMetrics(76), GetSystemMetrics(77));
1591  QSize sz(GetSystemMetrics(78), GetSystemMetrics(79));
1592  if (sz == qt_desktopWidget->size()) {
1593  // a screen resized without changing size of the virtual desktop
1594  QResizeEvent rs(sz, qt_desktopWidget->size());
1595  QApplication::sendEvent(qt_desktopWidget, &rs);
1596  } else {
1597  qt_desktopWidget->resize(sz);
1598  }
1599  }
1600  break;
1601 #endif
1602 
1603  case WM_SETTINGCHANGE:
1604 #ifdef Q_WS_WINCE
1605  // CE SIP hide/show
1606  if (qt_desktopWidget && wParam == SPI_SETSIPINFO) {
1607  QResizeEvent re(QSize(0, 0), QSize(0, 0)); // Calculated by QDesktopWidget
1608  QApplication::sendEvent(qt_desktopWidget, &re);
1609  break;
1610  }
1611 #endif
1612  // ignore spurious XP message when user logs in again after locking
1614  break;
1615  if (QApplication::desktopSettingsAware() && wParam != SPI_SETWORKAREA) {
1616  widget = (QETWidget*)QWidget::find(hwnd);
1617  if (widget) {
1618  if (wParam == SPI_SETNONCLIENTMETRICS)
1619  widget->markFrameStrutDirty();
1620  }
1621  }
1622  else if (qt_desktopWidget && wParam == SPI_SETWORKAREA) {
1623  qt_desktopWidget->move(GetSystemMetrics(76), GetSystemMetrics(77));
1624  QSize sz(GetSystemMetrics(78), GetSystemMetrics(79));
1625  if (sz == qt_desktopWidget->size()) {
1626  // a screen resized without changing size of the virtual desktop
1627  QResizeEvent rs(sz, qt_desktopWidget->size());
1628  QApplication::sendEvent(qt_desktopWidget, &rs);
1629  } else {
1630  qt_desktopWidget->resize(sz);
1631  }
1632  }
1633 
1634  if (wParam == SPI_SETFONTSMOOTHINGTYPE) {
1636  foreach (QWidget *w, QApplication::topLevelWidgets()) {
1637  if (!w->isVisible())
1638  continue;
1639  ((QETWidget *) w)->forceUpdate();
1640  }
1641  }
1642 
1643  break;
1644  case WM_SYSCOLORCHANGE:
1646  break;
1648  widget = (QETWidget*)QWidget::find(hwnd);
1649  if (widget && !widget->parentWidget())
1651  }
1652  break;
1653 
1654  case WM_LBUTTONDOWN:
1655  case WM_MBUTTONDOWN:
1656  case WM_RBUTTONDOWN:
1657  case WM_XBUTTONDOWN:
1658  case WM_LBUTTONDBLCLK:
1659  case WM_RBUTTONDBLCLK:
1660  case WM_MBUTTONDBLCLK:
1661  case WM_XBUTTONDBLCLK:
1662  if (qt_win_ignoreNextMouseReleaseEvent)
1663  qt_win_ignoreNextMouseReleaseEvent = false;
1664  break;
1665 
1666  case WM_LBUTTONUP:
1667  case WM_MBUTTONUP:
1668  case WM_RBUTTONUP:
1669  case WM_XBUTTONUP:
1670  if (qt_win_ignoreNextMouseReleaseEvent) {
1671  qt_win_ignoreNextMouseReleaseEvent = false;
1672  if (qt_button_down && qt_button_down->internalWinId() == autoCaptureWnd) {
1674  qt_button_down = 0;
1675  }
1676 
1677  RETURN(0);
1678  }
1679  break;
1680 
1681  default:
1682  break;
1683  }
1684 
1685  if (!widget)
1686  widget = (QETWidget*)QWidget::find(hwnd);
1687  if (!widget) // don't know this widget
1688  goto do_default;
1689 
1690  if (app_do_modal) { // modal event handling
1691  int ret = 0;
1692  if (!qt_try_modal(widget, &msg, ret))
1693  RETURN(ret);
1694  }
1695 
1696  res = 0;
1697  if (widget->winEvent(&msg, &res)) // send through widget filter
1698  RETURN(res);
1699 
1700  if (qt_is_translatable_mouse_event(message)) {
1701  if (QApplication::activePopupWidget() != 0) { // in popup mode
1702  POINT curPos = msg.pt;
1703  QWidget* w = QApplication::widgetAt(curPos.x, curPos.y);
1704  if (w)
1705  widget = (QETWidget*)w;
1706  }
1707 
1708  if (!qt_tabletChokeMouse) {
1709  result = widget->translateMouseEvent(msg); // mouse event
1710 #if defined(Q_WS_WINCE) && !defined(QT_NO_CONTEXTMENU)
1711  if (message == WM_LBUTTONDOWN && widget != QApplication::activePopupWidget()) {
1712  QWidget* alienWidget = widget;
1713  if ((alienWidget != QApplication::activePopupWidget()) && (alienWidget->contextMenuPolicy() != Qt::PreventContextMenu)) {
1714  QPoint pos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1715  QPoint globalPos(msg.pt.x, msg.pt.y);
1716  // In case we are using Alien, then the widget to
1717  // send the context menu event is a different one
1718  if (!alienWidget->testAttribute(Qt::WA_NativeWindow) && !alienWidget->testAttribute(Qt::WA_PaintOnScreen)) {
1719  alienWidget = QApplication::widgetAt(globalPos);
1720  if (alienWidget)
1721  pos = alienWidget->mapFromGlobal(globalPos);
1722  }
1723  if (alienWidget) {
1724  SHRGINFO shrg;
1725  shrg.cbSize = sizeof(shrg);
1726  shrg.hwndClient = hwnd;
1727  shrg.ptDown.x = GET_X_LPARAM(lParam);
1728  shrg.ptDown.y = GET_Y_LPARAM(lParam);
1730 #ifndef QT_NO_GESTURES
1731  resolveAygLibs();
1735  QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
1736  result = qt_sendSpontaneousEvent(alienWidget, &e);
1737  }
1738 #endif // QT_NO_GESTURES
1739  }
1740  }
1741  }
1742 #endif
1743  } else {
1744  // Sometimes we only get a WM_MOUSEMOVE message
1745  // and sometimes we get both a WM_MOUSEMOVE and
1746  // a WM_LBUTTONDOWN/UP, this creates a spurious mouse
1747  // press/release event, using the PeekMessage
1748  // will help us fix this. This leaves us with a
1749  // question:
1750  // This effectively kills using the mouse AND the
1751  // tablet simultaneously, well creates wacky input.
1752  // Is this going to be a problem? (probably not)
1753  bool next_is_button = false;
1754  bool is_mouse_move = (message == WM_MOUSEMOVE);
1755  if (is_mouse_move) {
1756  MSG msg1;
1757  if (PeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,
1758  WM_MOUSELAST, PM_NOREMOVE))
1759  next_is_button = (msg1.message == WM_LBUTTONUP
1760  || msg1.message == WM_LBUTTONDOWN);
1761  }
1762  if (!is_mouse_move || (is_mouse_move && !next_is_button))
1763  qt_tabletChokeMouse = false;
1764  }
1765  } else {
1766  switch (message) {
1767  case WM_TOUCH:
1769  break;
1770  case WM_KEYDOWN: // keyboard event
1771  case WM_SYSKEYDOWN:
1773  // fall-through intended
1774  case WM_KEYUP:
1775  case WM_SYSKEYUP:
1776 #if Q_OS_WINCE_WM
1777  case WM_HOTKEY:
1778  if(HIWORD(msg.lParam) == VK_TBACK) {
1779  const bool hotKeyDown = !(LOWORD(msg.lParam) & MOD_KEYUP);
1780  msg.lParam = 0x69 << 16;
1781  msg.wParam = VK_BACK;
1782  if (hotKeyDown) {
1783  msg.message = WM_KEYDOWN;
1785  } else {
1786  msg.message = WM_KEYUP;
1787  }
1788  }
1789  // fall-through intended
1790 #endif
1791  case WM_IME_CHAR:
1792  case WM_IME_KEYDOWN:
1793  case WM_CHAR: {
1794  MSG msg1;
1795  bool anyMsg = PeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);
1796  if (anyMsg && msg1.message == WM_DEADCHAR) {
1797  result = true; // consume event since there is a dead char next
1798  break;
1799  }
1801  if (g && qt_get_tablet_widget() && hwnd == qt_get_tablet_widget()->winId()) {
1802  // if we get an event for the internal tablet widget,
1803  // then don't send it to the keyboard grabber, but
1804  // send it to the widget itself (we don't use it right
1805  // now, just in case).
1806  g = 0;
1807  }
1808  if (g)
1809  widget = (QETWidget*)g;
1814  else if (QApplication::focusWidget())
1815  widget = (QETWidget*)QApplication::focusWidget();
1816  else if (!widget || widget->internalWinId() == GetFocus()) // We faked the message to go to exactly that widget.
1817  widget = (QETWidget*)widget->window();
1818  if (widget->isEnabled())
1819  result = sm_blockUserInput
1820  ? true
1821  : qt_keymapper_private()->translateKeyEvent(widget, msg, g != 0);
1822  break;
1823  }
1824  case WM_SYSCHAR:
1825  result = true; // consume event
1826  break;
1827 
1828  case WM_MOUSEWHEEL:
1829  case WM_MOUSEHWHEEL:
1830  result = widget->translateWheelEvent(msg);
1831  break;
1832 
1833  case WM_APPCOMMAND:
1834  {
1835  uint cmd = GET_APPCOMMAND_LPARAM(lParam);
1836  uint uDevice = GET_DEVICE_LPARAM(lParam);
1837  uint dwKeys = GET_KEYSTATE_LPARAM(lParam);
1838 
1839  int state = translateButtonState(dwKeys, QEvent::KeyPress, 0);
1840 
1841  switch (uDevice) {
1842  case FAPPCOMMAND_KEY:
1843  {
1844  int key = 0;
1845 
1846  switch(cmd) {
1847  case APPCOMMAND_BASS_BOOST:
1848  key = Qt::Key_BassBoost;
1849  break;
1850  case APPCOMMAND_BASS_DOWN:
1851  key = Qt::Key_BassDown;
1852  break;
1853  case APPCOMMAND_BASS_UP:
1854  key = Qt::Key_BassUp;
1855  break;
1857  key = Qt::Key_TrebleDown;
1858  break;
1859  case APPCOMMAND_TREBLE_UP:
1860  key = Qt::Key_TrebleUp;
1861  break;
1862  case APPCOMMAND_HELP:
1863  key = Qt::Key_Help;
1864  break;
1865  case APPCOMMAND_FIND:
1866  key = Qt::Key_Search;
1867  break;
1868  default:
1869  break;
1870  }
1871  if (key) {
1872  bool res = false;
1874  if (g)
1875  widget = (QETWidget*)g;
1876  else if (QApplication::focusWidget())
1877  widget = (QETWidget*)QApplication::focusWidget();
1878  else
1879  widget = (QETWidget*)widget->window();
1880  if (widget->isEnabled()) {
1881  res = QKeyMapper::sendKeyEvent(widget, g != 0, QEvent::KeyPress, key,
1882  Qt::KeyboardModifier(state),
1883  QString(), false, 0, 0, 0, 0);
1884  }
1885  if (res)
1886  return true;
1887  }
1888  }
1889  break;
1890 
1891  default:
1892  break;
1893  }
1894 
1895  result = false;
1896  }
1897  break;
1898 
1899 #ifndef Q_WS_WINCE
1900  case WM_NCHITTEST:
1901  if (widget->isWindow()) {
1902  QPoint pos = widget->mapFromGlobal(QPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
1903  // don't show resize-cursors for fixed-size widgets
1904  QRect fs = widget->frameStrut();
1905  if (!widget->isMinimized()) {
1906  if (widget->minimumHeight() == widget->maximumHeight()) {
1907  if (pos.y() < -(fs.top() - fs.left()))
1908  return HTCAPTION;
1909  if (pos.y() >= widget->height())
1910  return HTBORDER;
1911  }
1912  if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width()))
1913  return HTBORDER;
1914  }
1915  }
1916 
1917  result = false;
1918  break;
1919 #endif
1920 
1921  case WM_SYSCOMMAND: {
1922 #ifndef Q_WS_WINCE
1923  bool window_state_change = false;
1924  Qt::WindowStates oldstate = Qt::WindowStates(widget->dataPtr()->window_state);
1925  // MSDN:In WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are
1926  // used internally by the system. To obtain the correct result when testing the value of
1927  // wParam, an application must combine the value 0xFFF0 with the wParam value by using
1928  // the bitwise AND operator.
1929  switch(0xfff0 & wParam) {
1930  case SC_CONTEXTHELP:
1931 #ifndef QT_NO_WHATSTHIS
1933 #endif
1934  DefWindowProc(hwnd, WM_NCPAINT, 1, 0);
1935  break;
1936 #if defined(QT_NON_COMMERCIAL)
1937  QT_NC_SYSCOMMAND
1938 #endif
1939  case SC_MINIMIZE:
1940  window_state_change = true;
1942  if (widget->isVisible()) {
1943  QHideEvent e;
1944  qt_sendSpontaneousEvent(widget, &e);
1945  widget->hideChildren(true);
1946  const QString title = widget->windowIconText();
1947  if (!title.isEmpty())
1948  widget->setWindowTitle_helper(title);
1949  }
1950  result = false;
1951  break;
1952  case SC_MAXIMIZE:
1953  if(widget->isWindow())
1954  widget->topData()->normalGeometry = widget->geometry();
1955  case SC_RESTORE:
1956  window_state_change = true;
1957  if ((0xfff0 & wParam) == SC_MAXIMIZE)
1959  else if (!widget->isMinimized())
1960  widget->dataPtr()->window_state &= ~Qt::WindowMaximized;
1961 
1962  if (widget->isMinimized()) {
1963  widget->dataPtr()->window_state &= ~Qt::WindowMinimized;
1964  widget->showChildren(true);
1965  QShowEvent e;
1966  qt_sendSpontaneousEvent(widget, &e);
1967  const QString title = widget->windowTitle();
1968  if (!title.isEmpty())
1969  widget->setWindowTitle_helper(title);
1970  }
1971  result = false;
1972  break;
1973  default:
1974  result = false;
1975  break;
1976  }
1977 
1978  if (window_state_change) {
1979  QWindowStateChangeEvent e(oldstate);
1980  qt_sendSpontaneousEvent(widget, &e);
1981  }
1982 #endif // #ifndef Q_OS_WINCE
1983 
1984  break;
1985  }
1986 
1987  case WM_SETTINGCHANGE:
1989  break;
1990 
1991  if (!msg.wParam) {
1992 #ifdef Q_WS_WINCE
1993  // On Windows CE, lParam parameter is a constant, not a char pointer.
1994  if (msg.lParam == INI_INTL) {
1995 #else
1996  QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
1997  if (area == QLatin1String("intl")) {
1998 #endif
2000  if (!widget->testAttribute(Qt::WA_SetLocale))
2001  widget->dptr()->setLocale_helper(QLocale(), true);
2004  }
2005  }
2006  else if (msg.wParam == SPI_SETICONTITLELOGFONT) {
2008  widget = (QETWidget*)QWidget::find(hwnd);
2009  if (widget && !widget->parentWidget()) {
2011  }
2012  }
2013  }
2014  else if (msg.wParam == SPI_SETNONCLIENTMETRICS) {
2015  widget = (QETWidget*)QWidget::find(hwnd);
2016  if (widget && !widget->parentWidget()) {
2019  QApplication::sendEvent(widget, &e);
2020  }
2021  }
2022 
2023  break;
2024 
2025  case WM_PAINT: // paint event
2026  case WM_ERASEBKGND: // erase window background
2027  result = widget->translatePaintEvent(msg);
2028  break;
2029 
2030 #ifndef Q_WS_WINCE
2031  case WM_ENTERSIZEMOVE:
2032  autoCaptureWnd = hwnd;
2033  break;
2034  case WM_EXITSIZEMOVE:
2035  autoCaptureWnd = 0;
2036  break;
2037 #endif
2038  case WM_MOVE: // move window
2039  case WM_SIZE: // resize window
2040  result = widget->translateConfigEvent(msg);
2041  break;
2042 
2043  case WM_ACTIVATEAPP:
2044  if (wParam == FALSE) {
2046  // Another application was activated while our popups are open,
2047  // then close all popups. In case some popup refuses to close,
2048  // we give up after 1024 attempts (to avoid an infinite loop).
2049  int maxiter = 1024;
2050  QWidget *popup;
2051  while ((popup=QApplication::activePopupWidget()) && maxiter--)
2052  popup->close();
2053  }
2054  break;
2055 
2056  case WM_ACTIVATE:
2058  break;
2059 
2060  if (ptrWTOverlap && ptrWTEnable) {
2061  // cooperate with other tablet applications, but when
2062  // we get focus, I want to use the tablet...
2063  if (qt_tablet_context && GET_WM_ACTIVATE_STATE(wParam, lParam)) {
2064  if (ptrWTEnable(qt_tablet_context, true))
2066  }
2067  }
2068  if (QApplication::activePopupWidget() && LOWORD(wParam) == WA_INACTIVE &&
2069  QWidget::find((HWND)lParam) == 0) {
2070  // Another application was activated while our popups are open,
2071  // then close all popups. In case some popup refuses to close,
2072  // we give up after 1024 attempts (to avoid an infinite loop).
2073  int maxiter = 1024;
2074  QWidget *popup;
2075  while ((popup=QApplication::activePopupWidget()) && maxiter--)
2076  popup->close();
2077  }
2078 
2079  if (LOWORD(wParam) != WA_INACTIVE) {
2080  // WM_ACTIVATEAPP handles the "true" false case, as this is only when the application
2081  // loses focus. Doing it here would result in the widget getting focus to not know
2082  // where it got it from; it would simply get a 0 value as the old focus widget.
2083 #ifdef Q_WS_WINCE
2084  {
2085 #ifdef Q_WS_WINCE_WM
2086  // On Windows mobile we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages.
2087  // Thus we have to unset the minimized state explicitly. We must do this for all
2088  // top-level widgets, because we get the HWND of a random widget here.
2089  foreach (QWidget* tlw, QApplication::topLevelWidgets()) {
2090  if (tlw->isMinimized())
2092  }
2093 #else
2094  // On Windows CE we do not receive WM_SYSCOMMAND / SC_MINIMIZE messages.
2095  // Thus we have to unset the minimized state explicitly.
2096  if (widget->windowState() & Qt::WindowMinimized)
2097  widget->setWindowState(widget->windowState() & ~Qt::WindowMinimized);
2098 #endif // Q_WS_WINCE_WM
2099 
2100 #else
2101  if (!(widget->windowState() & Qt::WindowMinimized)) {
2102 #endif
2103  // Ignore the activate message send by WindowsXP to a minimized window
2104 #ifdef Q_WS_WINCE_WM
2105  if (widget->windowState() & Qt::WindowFullScreen)
2106  qt_wince_hide_taskbar(widget->winId());
2107 #endif
2108  qApp->winFocus(widget, true);
2109  // reset any window alert flashes
2110  alert_widget(widget, -1);
2111  }
2112  }
2113 
2114  // Windows tries to activate a modally blocked window.
2115  // This happens when restoring an application after "Show Desktop"
2116  if (app_do_modal && LOWORD(wParam) == WA_ACTIVE) {
2117  QWidget *top = 0;
2118  if (!QApplicationPrivate::tryModalHelper(widget, &top) && top && widget != top) {
2119  if (top->isVisible()) {
2120  top->activateWindow();
2121  } else {
2122  // This is the case when native file dialogs are shown
2123  QWidget *p = (top->parentWidget() ? top->parentWidget()->window() : 0);
2124  if (p && p->isVisible())
2125  p->activateWindow();
2126  }
2127  }
2128  }
2129  break;
2130 
2131 #ifndef Q_WS_WINCE
2132  case WM_MOUSEACTIVATE:
2133  if (widget->window()->windowType() == Qt::Tool) {
2134  QWidget *w = widget;
2135  if (!w->window()->focusWidget()) {
2136  while (w && (w->focusPolicy() & Qt::ClickFocus) == 0) {
2137  if (w->isWindow()) {
2138  QWidget *fw = w;
2139  while ((fw = fw->nextInFocusChain()) != w && fw->focusPolicy() == Qt::NoFocus)
2140  ;
2141  if (fw != w)
2142  break;
2143  QWidget *pw = w->parentWidget();
2144  while (pw) {
2145  pw = pw->window();
2146  if (pw && pw->isVisible() && pw->focusWidget()) {
2148  SetWindowPos(pw->internalWinId(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
2149  break;
2150  }
2151  pw = pw->parentWidget();
2152  }
2153  RETURN(MA_NOACTIVATE);
2154  }
2155  w = w->parentWidget();
2156  }
2157  }
2158  }
2159  RETURN(MA_ACTIVATE);
2160  break;
2161 #endif
2162  case WM_SHOWWINDOW:
2163  if (lParam == SW_PARENTOPENING) {
2164  if (widget->testAttribute(Qt::WA_WState_Hidden))
2165  RETURN(0);
2166  }
2167  if (widget->isWindow() && widget->testAttribute(Qt::WA_WState_Visible)
2168  && !widget->testWindowState(Qt::WindowMinimized)) {
2169  if (lParam == SW_PARENTOPENING) {
2170  QShowEvent e;
2171  qt_sendSpontaneousEvent(widget, &e);
2172  widget->showChildren(true);
2173  } else if (lParam == SW_PARENTCLOSING) {
2174  QHideEvent e;
2175  qt_sendSpontaneousEvent(widget, &e);
2176  widget->hideChildren(true);
2177  }
2178  }
2179  if (!wParam && autoCaptureWnd == widget->internalWinId())
2181  result = false;
2182  break;
2183 
2184  case WM_PALETTECHANGED: // our window changed palette
2185  if (QColormap::hPal() && (WId)wParam == widget->internalWinId())
2186  RETURN(0); // otherwise: FALL THROUGH!
2187  // FALL THROUGH
2188  case WM_QUERYNEWPALETTE: // realize own palette
2189  if (QColormap::hPal()) {
2191  HDC hdc = GetDC(widget->internalWinId());
2192  HPALETTE hpalOld = SelectPalette(hdc, QColormap::hPal(), FALSE);
2193  uint n = RealizePalette(hdc);
2194  if (n)
2195  InvalidateRect(widget->internalWinId(), 0, TRUE);
2196  SelectPalette(hdc, hpalOld, TRUE);
2197  RealizePalette(hdc);
2198  ReleaseDC(widget->internalWinId(), hdc);
2199  RETURN(n);
2200  }
2201  break;
2202  case WM_CLOSE: // close window
2203  widget->translateCloseEvent(msg);
2204  RETURN(0); // always handled
2205 
2206  case WM_DESTROY: // destroy window
2207  if (hwnd == curWin) {
2208  QWidget *enter = QWidget::mouseGrabber();
2209  if (enter == widget)
2210  enter = 0;
2212  curWin = enter ? enter->effectiveWinId() : 0;
2213  qt_last_mouse_receiver = enter;
2214  }
2215  if (widget == popupButtonFocus)
2216  popupButtonFocus = 0;
2217  result = false;
2218  break;
2219 
2220 #ifndef Q_WS_WINCE
2221  case WM_WINDOWPOSCHANGING:
2222  {
2223  result = false;
2224  if (widget->isWindow()) {
2225  WINDOWPOS *winPos = (WINDOWPOS *)lParam;
2226  if (widget->layout() && widget->layout()->hasHeightForWidth()
2227  && !(winPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE))) {
2228  QRect fs = widget->frameStrut();
2229  QRect rect = widget->geometry();
2230  QRect newRect = QRect(winPos->x + fs.left(),
2231  winPos->y + fs.top(),
2232  winPos->cx - fs.left() - fs.right(),
2233  winPos->cy - fs.top() - fs.bottom());
2234 
2235  QSize newSize = QLayout::closestAcceptableSize(widget, newRect.size());
2236 
2237  int dh = newSize.height() - newRect.height();
2238  int dw = newSize.width() - newRect.width();
2239  if (!dw && ! dh)
2240  break; // Size OK
2241 
2242  if (rect.y() != newRect.y()) {
2243  newRect.setTop(newRect.top() - dh);
2244  } else {
2245  newRect.setBottom(newRect.bottom() + dh);
2246  }
2247 
2248  if (rect.x() != newRect.x()) {
2249  newRect.setLeft(newRect.left() - dw);
2250  } else {
2251  newRect.setRight(newRect.right() + dw);
2252  }
2253 
2254  winPos->x = newRect.x() - fs.left();
2255  winPos->y = newRect.y() - fs.top();
2256  winPos->cx = newRect.width() + fs.left() + fs.right();
2257  winPos->cy = newRect.height() + fs.top() + fs.bottom();
2258 
2259  RETURN(0);
2260  }
2261  if (widget->windowFlags() & Qt::WindowStaysOnBottomHint) {
2262  winPos->hwndInsertAfter = HWND_BOTTOM;
2263  }
2264  }
2265  }
2266  break;
2267 
2268  case WM_GETMINMAXINFO:
2269  if (widget->xtra()) {
2270  MINMAXINFO *mmi = (MINMAXINFO *)lParam;
2271  QWExtra *x = widget->xtra();
2272  QRect fs = widget->frameStrut();
2273  if ( x->minw > 0 )
2274  mmi->ptMinTrackSize.x = x->minw + fs.right() + fs.left();
2275  if ( x->minh > 0 )
2276  mmi->ptMinTrackSize.y = x->minh + fs.top() + fs.bottom();
2277  qint32 maxw = (x->maxw >= x->minw) ? x->maxw : x->minw;
2278  qint32 maxh = (x->maxh >= x->minh) ? x->maxh : x->minh;
2279  if ( maxw < QWIDGETSIZE_MAX ) {
2280  mmi->ptMaxTrackSize.x = maxw + fs.right() + fs.left();
2281  // windows with title bar have an implicit size limit of 112 pixels
2282  if (widget->windowFlags() & Qt::WindowTitleHint)
2283  mmi->ptMaxTrackSize.x = qMax<long>(mmi->ptMaxTrackSize.x, 112);
2284  }
2285  if ( maxh < QWIDGETSIZE_MAX )
2286  mmi->ptMaxTrackSize.y = maxh + fs.top() + fs.bottom();
2287  RETURN(0);
2288  }
2289  break;
2290 
2291 #ifndef QT_NO_CONTEXTMENU
2292  case WM_CONTEXTMENU:
2293  {
2294  // it's not VK_APPS or Shift+F10, but a click in the NC area
2295  if (lParam != (int)0xffffffff) {
2296  result = false;
2297  break;
2298  }
2299 
2301  if (!fw) {
2306  else if (QApplication::focusWidget())
2308  else if (widget)
2309  fw = widget->window();
2310  }
2311  if (fw && fw->isEnabled()) {
2315  result = qt_sendSpontaneousEvent(fw, &e);
2316  }
2317  }
2318  break;
2319 #endif
2320 #endif
2321 
2322 #ifndef QT_NO_IM
2323  case WM_IME_STARTCOMPOSITION:
2324  case WM_IME_ENDCOMPOSITION:
2325  case WM_IME_COMPOSITION: {
2328  if (fw && im) {
2329  if(message == WM_IME_STARTCOMPOSITION)
2330  result = im->startComposition();
2331  else if (message == WM_IME_ENDCOMPOSITION)
2332  result = im->endComposition();
2333  else if (message == WM_IME_COMPOSITION)
2334  result = im->composition(lParam);
2335  }
2336  break;
2337  }
2338  case WM_IME_REQUEST: {
2341  if (fw && im) {
2342  if(wParam == IMR_RECONVERTSTRING) {
2343  int ret = im->reconvertString((RECONVERTSTRING *)lParam);
2344  if (ret == -1) {
2345  result = false;
2346  } else {
2347  return ret;
2348  }
2349  } else if (wParam == IMR_CONFIRMRECONVERTSTRING) {
2350  RETURN(TRUE);
2351  } else {
2352  // in all other cases, call DefWindowProc()
2353  result = false;
2354  }
2355  }
2356  break;
2357  }
2358 #endif // QT_NO_IM
2359 #ifndef Q_WS_WINCE
2360  case WM_CHANGECBCHAIN:
2361  case WM_DRAWCLIPBOARD:
2362 #endif
2363  case WM_RENDERFORMAT:
2364  case WM_RENDERALLFORMATS:
2365 #ifndef QT_NO_CLIPBOARD
2366  case WM_DESTROYCLIPBOARD:
2367  if (qt_clipboard) {
2368  QClipboardEvent e(reinterpret_cast<QEventPrivate *>(&msg));
2370  RETURN(0);
2371  }
2372  result = false;
2373  break;
2374 #endif //QT_NO_CLIPBOARD
2375 #ifndef QT_NO_ACCESSIBILITY
2376  case WM_GETOBJECT:
2377  {
2378 #if !defined(Q_OS_WINCE)
2379  /* On Win64, lParam can be 0x00000000fffffffc or 0xfffffffffffffffc (!),
2380  but MSDN says that lParam should be converted to a DWORD
2381  before its compared against OBJID_CLIENT
2382  */
2383  const DWORD dwObjId = (DWORD)lParam;
2384  // Ignoring all requests while starting up
2385  if (QApplication::startingUp() || QApplication::closingDown() || dwObjId != OBJID_CLIENT) {
2386  result = false;
2387  break;
2388  }
2389 
2390  typedef LRESULT (WINAPI *PtrLresultFromObject)(REFIID, WPARAM, LPUNKNOWN);
2391  static PtrLresultFromObject ptrLresultFromObject = 0;
2392  static bool oleaccChecked = false;
2393  if (!oleaccChecked) {
2394  QSystemLibrary oleacclib(QLatin1String("oleacc"));
2395  ptrLresultFromObject = (PtrLresultFromObject)oleacclib.resolve("LresultFromObject");
2396  oleaccChecked = true;
2397  }
2398  if (ptrLresultFromObject) {
2400  if (!acc) {
2401  result = false;
2402  break;
2403  }
2404 
2405  // and get an instance of the IAccessibile implementation
2406  IAccessible *iface = qt_createWindowsAccessible(acc);
2407  res = ptrLresultFromObject(IID_IAccessible, wParam, iface); // ref == 2
2408  iface->Release(); // the client will release the object again, and then it will destroy itself
2409 
2410  if (res > 0)
2411  RETURN(res);
2412  }
2413 #endif
2414  }
2415  result = false;
2416  break;
2417  case WM_GETTEXT:
2418  if (!widget->isWindow()) {
2419  int ret = 0;
2421  if (acc) {
2422  QString text = acc->text(QAccessible::Name, 0);
2423  if (text.isEmpty())
2424  text = widget->objectName();
2425  ret = qMin<int>(wParam - 1, text.size());
2426  text.resize(ret);
2427  memcpy((void *)lParam, text.utf16(), (text.size() + 1) * sizeof(ushort));
2428  delete acc;
2429  }
2430  if (!ret) {
2431  result = false;
2432  break;
2433  }
2434  RETURN(ret);
2435  }
2436  result = false;
2437  break;
2438 #endif
2439  case WT_PACKET:
2440  if (ptrWTPacketsGet) {
2442  result = widget->translateTabletEvent(msg, localPacketBuf, nPackets);
2443  }
2444  }
2445  break;
2446  case WT_PROXIMITY:
2447 
2448  #ifndef QT_NO_TABLETEVENT
2449  if (ptrWTPacketsGet && ptrWTInfo) {
2450  const bool enteredProximity = LOWORD(lParam) != 0;
2451  PACKET proximityBuffer[1]; // we are only interested in the first packet in this case
2452  const int totalPacks = ptrWTPacketsGet(qt_tablet_context, 1, proximityBuffer);
2453  if (totalPacks > 0) {
2454  const UINT currentCursor = proximityBuffer[0].pkCursor;
2455 
2456  UINT csr_physid;
2457  ptrWTInfo(WTI_CURSORS + currentCursor, CSR_PHYSID, &csr_physid);
2458  UINT csr_type;
2459  ptrWTInfo(WTI_CURSORS + currentCursor, CSR_TYPE, &csr_type);
2460  const UINT deviceIdMask = 0xFF6; // device type mask && device color mask
2461  quint64 uniqueId = (csr_type & deviceIdMask);
2462  uniqueId = (uniqueId << 32) | csr_physid;
2463 
2464  // initialising and updating the cursor should be done in response to
2465  // WT_CSRCHANGE. We do it in WT_PROXIMITY because some wintab never send
2466  // the event WT_CSRCHANGE even if asked with CXO_CSRMESSAGES
2467  const QTabletCursorInfo *const globalCursorInfo = tCursorInfo();
2468  if (!globalCursorInfo->contains(uniqueId))
2469  tabletInit(uniqueId, csr_type, qt_tablet_context);
2470 
2471  currentTabletPointer = globalCursorInfo->value(uniqueId);
2472  tabletUpdateCursor(currentTabletPointer, currentCursor);
2473  }
2474  qt_tabletChokeMouse = false;
2475 
2476  QTabletEvent tabletProximity(enteredProximity ? QEvent::TabletEnterProximity
2478  QPoint(), QPoint(), QPointF(), currentTabletPointer.currentDevice, currentTabletPointer.currentPointerType, 0, 0,
2479  0, 0, 0, 0, 0, currentTabletPointer.llId);
2480  QApplication::sendEvent(qApp, &tabletProximity);
2481  }
2482  #endif // QT_NO_TABLETEVENT
2483 
2484  break;
2485 #ifdef Q_WS_WINCE_WM
2486  case WM_SETFOCUS: {
2487  HIMC hC;
2488  hC = ImmGetContext(hwnd);
2489  ImmSetOpenStatus(hC, TRUE);
2490  ImmEscape(NULL, hC, IME_ESC_SET_MODE, (LPVOID)IM_SPELL);
2491  result = false;
2492  }
2493  break;
2494 #endif
2495  case WM_KILLFOCUS:
2496  if (!QWidget::find((HWND)wParam)) { // we don't get focus, so unset it now
2497  if (!widget->hasFocus()) // work around Windows bug after minimizing/restoring
2498  widget = (QETWidget*)QApplication::focusWidget();
2499  HWND focus = ::GetFocus();
2500  //if there is a current widget and the new widget belongs to the same toplevel window
2501  //or if the current widget was embedded into non-qt window (i.e. we won't get WM_ACTIVATEAPP)
2502  //then we clear the focus on the widget
2503  //in case the new widget belongs to a different widget hierarchy, clearing the focus
2504  //will be handled because the active window will change
2505  const bool embedded = widget && ((QETWidget*)widget->window())->topData()->embedded;
2506  if (widget && (embedded || ::IsChild(widget->window()->internalWinId(), focus))) {
2507  widget->clearFocus();
2508  result = true;
2509  } else {
2510  result = false;
2511  }
2512  } else {
2513  result = false;
2514  }
2515  break;
2516  case WM_THEMECHANGED:
2517  if ((widget->windowType() == Qt::Desktop) || !qApp || QApplication::closingDown()
2519  break;
2520 
2522  QApplication::style()->unpolish(widget);
2523 
2525  QApplication::style()->polish(widget);
2526  widget->repolishStyle(*QApplication::style());
2527  if (widget->isVisible())
2528  widget->update();
2529  break;
2530 
2531 #ifndef Q_WS_WINCE
2532  case WM_INPUTLANGCHANGE: {
2533  wchar_t info[7];
2534  if (!GetLocaleInfo(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
2535  inputcharset = CP_ACP;
2536  } else {
2537  inputcharset = QString::fromWCharArray(info).toInt();
2538  }
2540  break;
2541  }
2542 #else
2543  case WM_COMMAND: {
2544  bool OkCommand = (LOWORD(wParam) == 0x1);
2545  bool CancelCommand = (LOWORD(wParam) == 0x2);
2546  if (OkCommand)
2548  if (CancelCommand)
2549  widget->showMinimized();
2550  else
2551 #ifndef QT_NO_MENUBAR
2552  QMenuBar::wceCommands(LOWORD(wParam));
2553 #endif
2554  result = true;
2555  }
2556  break;
2557  case WM_HELP:
2559  result = true;
2560  break;
2561 #endif
2562 
2563  case WM_MOUSELEAVE:
2564  // We receive a mouse leave for curWin, meaning
2565  // the mouse was moved outside our widgets
2566  if (widget->internalWinId() == curWin) {
2567  bool dispatch = !widget->underMouse();
2568  // hasMouse is updated when dispatching enter/leave,
2569  // so test if it is actually up-to-date
2570  if (!dispatch) {
2571  QRect geom = widget->geometry();
2572  if (widget->parentWidget() && !widget->isWindow()) {
2573  QPoint gp = widget->parentWidget()->mapToGlobal(widget->pos());
2574  geom.setX(gp.x());
2575  geom.setY(gp.y());
2576  }
2577  QPoint cpos = QCursor::pos();
2578  dispatch = !geom.contains(cpos);
2579  if ( !dispatch && !QWidget::mouseGrabber()) {
2580  QWidget *hittest = QApplication::widgetAt(cpos);
2581  dispatch = !hittest || hittest->internalWinId() != curWin;
2582  }
2583  if (!dispatch) {
2584  HRGN hrgn = qt_tryCreateRegion(QRegion::Rectangle, 0,0,0,0);
2585  if (GetWindowRgn(curWin, hrgn) != ERROR) {
2586  QPoint lcpos = widget->mapFromGlobal(cpos);
2587  dispatch = !PtInRegion(hrgn, lcpos.x(), lcpos.y());
2588  }
2589  DeleteObject(hrgn);
2590  }
2591  }
2592  if (dispatch) {
2593  if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
2594  QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver);
2595  else
2597  curWin = 0;
2598  qt_last_mouse_receiver = 0;
2599  }
2600  }
2601  break;
2602 
2603  case WM_CANCELMODE:
2604  {
2605  // this goes through QMenuBar's event filter
2608  }
2609  break;
2610 
2611  case WM_IME_NOTIFY:
2612  // special handling for ime, only for widgets in a popup
2613  if (wParam == IMN_OPENCANDIDATE) {
2614  imeParentWnd = hwnd;
2616  // temporarily disable the mouse grab to allow mouse input in
2617  // the ime candidate window. The actual handle is untouched
2618  if (autoCaptureWnd)
2619  ReleaseCapture();
2620  }
2621  } else if (wParam == IMN_CLOSECANDIDATE) {
2622  imeParentWnd = 0;
2624  // undo the action above, when candidate window is closed
2625  if (autoCaptureWnd)
2626  SetCapture(autoCaptureWnd);
2627  }
2628  }
2629  result = false;
2630  break;
2631 #ifndef QT_NO_GESTURES
2632 #if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
2633  case WM_GESTURE: {
2634  GESTUREINFO gi;
2635  memset(&gi, 0, sizeof(GESTUREINFO));
2636  gi.cbSize = sizeof(GESTUREINFO);
2637 
2639  BOOL bResult = false;
2640  if (qAppPriv->GetGestureInfo)
2641  bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
2642  if (bResult) {
2643  if (gi.dwID == GID_BEGIN) {
2644  // find the alien widget for the gesture position.
2645  // This might not be accurate as the position is the center
2646  // point of two fingers for multi-finger gestures.
2647  QPoint pt(gi.ptsLocation.x, gi.ptsLocation.y);
2648  QWidget *w = widget->childAt(widget->mapFromGlobal(pt));
2649  qAppPriv->gestureWidget = w ? w : widget;
2650  }
2651  if (qAppPriv->gestureWidget)
2652  static_cast<QETWidget*>(qAppPriv->gestureWidget)->translateGestureEvent(msg, gi);
2653  if (qAppPriv->CloseGestureInfoHandle)
2654  qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
2655  if (gi.dwID == GID_END)
2656  qAppPriv->gestureWidget = 0;
2657  } else {
2658  DWORD dwErr = GetLastError();
2659  if (dwErr > 0)
2660  qWarning() << "translateGestureEvent: error = " << dwErr;
2661  }
2662  result = true;
2663  break;
2664  }
2665 #endif // !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
2666 #endif // QT_NO_GESTURES
2667 #ifndef QT_NO_CURSOR
2668  case WM_SETCURSOR: {
2670  if (ovr) {
2671  SetCursor(ovr->handle());
2672  RETURN(TRUE);
2673  }
2674  result = false;
2675  break;
2676  }
2677 #endif
2678  default:
2679  result = false; // event was not processed
2680  break;
2681  }
2682  }
2683 
2684  if (evt_type != QEvent::None) { // simple event
2685  QEvent e(evt_type);
2686  result = qt_sendSpontaneousEvent(widget, &e);
2687  }
2688 
2689  if (result)
2690  RETURN(false);
2691 
2692 do_default:
2693 #ifndef QT_NO_IM
2694  RETURN(QWinInputContext::DefWindowProc(hwnd,message,wParam,lParam))
2695 #else
2696  RETURN(TRUE);
2697 #endif
2698 }
2699 
2700 
2701 /*****************************************************************************
2702  Modal widgets; We have implemented our own modal widget mechanism
2703  to get total control.
2704  A modal widget without a parent becomes application-modal.
2705  A modal widget with a parent becomes modal to its parent and grandparents..
2706 
2707  QApplicationPrivate::enterModal()
2708  Enters modal state
2709  Arguments:
2710  QWidget *widget A modal widget
2711 
2712  QApplicationPrivate::leaveModal()
2713  Leaves modal state for a widget
2714  Arguments:
2715  QWidget *widget A modal widget
2716  *****************************************************************************/
2717 
2719 {
2720  return app_do_modal;
2721 }
2722 
2724 {
2725  if (!qt_modal_stack)
2726  qt_modal_stack = new QWidgetList;
2727 
2729  ClipCursor(0);
2731  if (!leave)
2732  leave = QWidget::find((WId)curWin);
2734  qt_modal_stack->insert(0, widget);
2735  app_do_modal = true;
2736  curWin = 0;
2737  qt_last_mouse_receiver = 0;
2738  qt_win_ignoreNextMouseReleaseEvent = false;
2739 }
2740 
2742 {
2743  if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
2744  if (qt_modal_stack->isEmpty()) {
2745  delete qt_modal_stack;
2746  qt_modal_stack = 0;
2747  QPoint p(QCursor::pos());
2748  app_do_modal = false; // necessary, we may get recursively into qt_try_modal below
2749  QWidget* w = QApplication::widgetAt(p.x(), p.y());
2751  if (!leave)
2752  leave = QWidget::find((WId)curWin);
2753  if (QWidget *grabber = QWidget::mouseGrabber()) {
2754  w = grabber;
2755  if (leave == w)
2756  leave = 0;
2757  }
2758  QApplicationPrivate::dispatchEnterLeave(w, leave); // send synthetic enter event
2759  curWin = w ? w->effectiveWinId() : 0;
2760  qt_last_mouse_receiver = w;
2761  }
2762  qt_win_ignoreNextMouseReleaseEvent = true;
2763  }
2764  app_do_modal = qt_modal_stack != 0;
2765 }
2766 
2767 bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
2768 {
2769 #if defined(Q_OS_WINCE)
2770  Q_UNUSED(ret);
2771 #endif
2772  QWidget * top = 0;
2773 
2774  if (QApplicationPrivate::tryModalHelper(widget, &top))
2775  return true;
2776 
2777  int type = msg->message;
2778 
2779  bool block_event = false;
2780 #ifndef Q_WS_WINCE
2781  if (type != WM_NCHITTEST) {
2782 #endif
2783  if ((type >= WM_MOUSEFIRST && type <= WM_MOUSELAST) ||
2784  type == WM_MOUSEWHEEL || type == WM_MOUSEHWHEEL ||
2785  type == WM_MOUSELEAVE ||
2786  (type >= WM_KEYFIRST && type <= WM_KEYLAST)
2787 #ifndef Q_WS_WINCE
2788  || type == WM_NCMOUSEMOVE
2789 #endif
2790  ) {
2791  if (type == WM_MOUSEMOVE
2792 #ifndef Q_WS_WINCE
2793  || type == WM_NCMOUSEMOVE
2794 #endif
2795  ) {
2796 #ifndef QT_NO_CURSOR
2797  QCursor *c = qt_grab_cursor();
2798  if (!c)
2800  if (c) // application cursor defined
2801  SetCursor(c->handle());
2802  else
2803  SetCursor(QCursor(Qt::ArrowCursor).handle());
2804 #endif // QT_NO_CURSOR
2805  }
2806  block_event = true;
2807  } else if (type == WM_CLOSE) {
2808  block_event = true;
2809  }
2810 #ifndef Q_WS_WINCE
2811  else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){
2812  if (!top->isActiveWindow()) {
2813  top->activateWindow();
2814  } else {
2816  }
2817  block_event = true;
2818  ret = MA_NOACTIVATEANDEAT;
2819  } else if (type == WM_SYSCOMMAND) {
2820  if (!(msg->wParam == SC_RESTORE && widget->isMinimized()))
2821  block_event = true;
2822  }
2823  }
2824 #endif
2825 
2826  return !block_event;
2827 }
2828 
2829 
2830 /*****************************************************************************
2831  Popup widget mechanism
2832 
2833  openPopup()
2834  Adds a widget to the list of popup widgets
2835  Arguments:
2836  QWidget *widget The popup widget to be added
2837 
2838  closePopup()
2839  Removes a widget from the list of popup widgets
2840  Arguments:
2841  QWidget *widget The popup widget to be removed
2842  *****************************************************************************/
2843 
2845 {
2849  if (!popup->isEnabled())
2850  return;
2851 
2852  // close any opened 'ime candidate window'
2853  if (imeParentWnd)
2854  ::SendMessage(imeParentWnd, WM_IME_ENDCOMPOSITION, 0, 0);
2855 
2856  if (QApplicationPrivate::popupWidgets->count() == 1 && !qt_nograb()) {
2858  setAutoCapture(popup->internalWinId()); // grab mouse/keyboard
2859  }
2860  // Popups are not focus-handled by the window system (the first
2861  // popup grabbed the keyboard), so we have to do that manually: A
2862  // new popup gets the focus
2863  if (popup->focusWidget()) {
2865  } else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup
2866  if (QWidget *fw = QApplication::focusWidget()) {
2868  QApplication::sendEvent(fw, &e);
2869  }
2870  }
2871 }
2872 
2874 {
2876  return;
2878  POINT curPos;
2879  GetCursorPos(&curPos);
2880 
2881  // close any opened 'ime candidate window'
2882  if (imeParentWnd)
2883  ::SendMessage(imeParentWnd, WM_IME_ENDCOMPOSITION, 0, 0);
2884 
2885  if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup
2888  replayPopupMouseEvent = (!popup->geometry().contains(QPoint(curPos.x, curPos.y))
2889  && !popup->testAttribute(Qt::WA_NoMouseReplay));
2890  if (!popup->isEnabled())
2891  return;
2892  if (!qt_nograb()) // grabbing not disabled
2896  if (fw) {
2897  if (fw != QApplication::focusWidget()) {
2899  } else {
2901  QApplication::sendEvent(fw, &e);
2902  }
2903  }
2904  } else {
2905  // Popups are not focus-handled by the window system (the
2906  // first popup grabbed the keyboard), so we have to do that
2907  // manually: A popup was closed, so the previous popup gets
2908  // the focus.
2910  if (QApplicationPrivate::popupWidgets->count() == 1) {
2913  }
2914  if (QWidget *fw = aw->focusWidget())
2915  fw->setFocus(Qt::PopupFocusReason);
2916  }
2917 }
2918 
2919 
2920 
2921 
2922 /*****************************************************************************
2923  Event translation; translates Windows events to Qt events
2924  *****************************************************************************/
2925 
2926 //
2927 // Auto-capturing for mouse press and mouse release
2928 //
2929 
2930 static void setAutoCapture(HWND h)
2931 {
2932  if (autoCaptureWnd)
2934  autoCaptureWnd = h;
2935  SetCapture(h);
2936 }
2937 
2938 static void releaseAutoCapture()
2939 {
2940  if (autoCaptureWnd) {
2941  ReleaseCapture();
2942  autoCaptureWnd = 0;
2943  }
2944 }
2945 
2946 
2947 //
2948 // Mouse event translation
2949 //
2950 // Non-client mouse messages are not translated
2951 //
2952 
2953 static const ushort mouseTbl[] = {
2954  WM_MOUSEMOVE, QEvent::MouseMove, 0,
2955  WM_LBUTTONDOWN, QEvent::MouseButtonPress, Qt::LeftButton,
2957  WM_LBUTTONDBLCLK, QEvent::MouseButtonDblClick, Qt::LeftButton,
2958  WM_RBUTTONDOWN, QEvent::MouseButtonPress, Qt::RightButton,
2960  WM_RBUTTONDBLCLK, QEvent::MouseButtonDblClick, Qt::RightButton,
2961  WM_MBUTTONDOWN, QEvent::MouseButtonPress, Qt::MidButton,
2963  WM_MBUTTONDBLCLK, QEvent::MouseButtonDblClick, Qt::MidButton,
2964  // use XButton1 for now, the real X button is decided later
2968 
2969 #ifndef Q_WS_WINCE
2970  WM_NCMOUSEMOVE, QEvent::NonClientAreaMouseMove, 0,
2980 #endif
2981 
2982  0, 0, 0
2983 };
2984 
2985 static int translateButtonState(int s, int type, int button)
2986 {
2987  Q_UNUSED(type);
2988  Q_UNUSED(button);
2989  int bst = 0;
2990  if (s & MK_LBUTTON)
2991  bst |= Qt::LeftButton;
2992  if (s & MK_MBUTTON)
2993  bst |= Qt::MidButton;
2994  if (s & MK_RBUTTON)
2995  bst |= Qt::RightButton;
2996  if (s & MK_SHIFT)
2997  bst |= Qt::ShiftModifier;
2998  if (s & MK_CONTROL)
2999  bst |= Qt::ControlModifier;
3000 
3001  if (s & MK_XBUTTON1)
3002  bst |= Qt::XButton1;
3003  if (s & MK_XBUTTON2)
3004  bst |= Qt::XButton2;
3005 
3006  if (GetKeyState(VK_MENU) < 0)
3007  bst |= Qt::AltModifier;
3008 
3009  if ((GetKeyState(VK_LWIN) < 0) ||
3010  (GetKeyState(VK_RWIN) < 0))
3011  bst |= Qt::MetaModifier;
3012 
3013  return bst;
3014 }
3015 
3017 {
3018  // after closing a windows dialog with a double click (i.e. open a file)
3019  // the message queue still contains a dubious WM_MOUSEMOVE message where
3020  // the left button is reported to be down (wParam != 0).
3021  // remove all those messages (usually 1) and post the last one with a
3022  // reset button state
3023 
3024  MSG msg = {0, 0, 0, 0, 0, {0, 0} };
3025  while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
3026  ;
3027  if (msg.message == WM_MOUSEMOVE)
3028  PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
3029 }
3030 
3031 // In DnD, the mouse release event never appears, so the
3032 // mouse button state machine must be manually reset
3034 {
3035  qt_button_down = 0;
3037 }
3038 
3040 {
3042  QApplication::sendEvent(this, &e);
3043 }
3044 
3046 {
3047  if (!isWindow() && testAttribute(Qt::WA_NativeWindow))
3048  Q_ASSERT(internalWinId());
3049 
3050  static QPoint pos;
3051  static POINT gpos={-1,-1};
3052  QEvent::Type type; // event parameters
3053  int button;
3054  int state;
3055  int i;
3056 
3057  if (sm_blockUserInput) //block user interaction during session management
3058  return true;
3059 
3060  // Compress mouse move events
3061  if (msg.message == WM_MOUSEMOVE) {
3062  MSG mouseMsg;
3063  while (PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST,
3064  WM_MOUSELAST, PM_NOREMOVE)) {
3065  if (mouseMsg.message == WM_MOUSEMOVE) {
3066 #define PEEKMESSAGE_IS_BROKEN 1
3067 #ifdef PEEKMESSAGE_IS_BROKEN
3068  // Since the Windows PeekMessage() function doesn't
3069  // correctly return the wParam for WM_MOUSEMOVE events
3070  // if there is a key release event in the queue
3071  // _before_ the mouse event, we have to also consider
3072  // key release events (kls 2003-05-13):
3073  MSG keyMsg;
3074  bool done = false;
3075  while (PeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST,
3076  PM_NOREMOVE)) {
3077  if (keyMsg.time < mouseMsg.time) {
3078  if ((keyMsg.lParam & 0xC0000000) == 0x40000000) {
3079  PeekMessage(&keyMsg, 0, keyMsg.message,
3080  keyMsg.message, PM_REMOVE);
3081  } else {
3082  done = true;
3083  break;
3084  }
3085  } else {
3086  break; // no key event before the WM_MOUSEMOVE event
3087  }
3088  }
3089  if (done)
3090  break;
3091 #else
3092  // Actually the following 'if' should work instead of
3093  // the above key event checking, but apparently
3094  // PeekMessage() is broken :-(
3095  if (mouseMsg.wParam != msg.wParam)
3096  break; // leave the message in the queue because
3097  // the key state has changed
3098 #endif
3099  MSG *msgPtr = (MSG *)(&msg);
3100  // Update the passed in MSG structure with the
3101  // most recent one.
3102  msgPtr->lParam = mouseMsg.lParam;
3103  msgPtr->wParam = mouseMsg.wParam;
3104  // Extract the x,y coordinates from the lParam as we do in the WndProc
3105  msgPtr->pt.x = GET_X_LPARAM(mouseMsg.lParam);
3106  msgPtr->pt.y = GET_Y_LPARAM(mouseMsg.lParam);
3107  ClientToScreen(msg.hwnd, &(msgPtr->pt));
3108  // Remove the mouse move message
3109  PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,
3110  WM_MOUSEMOVE, PM_REMOVE);
3111  } else {
3112  break; // there was no more WM_MOUSEMOVE event
3113  }
3114  }
3115  }
3116 
3117  for (i=0; (UINT)mouseTbl[i] != msg.message && mouseTbl[i]; i += 3)
3118  ;
3119  if (!mouseTbl[i])
3120  return false;
3121  type = (QEvent::Type)mouseTbl[++i]; // event type
3122  button = mouseTbl[++i]; // which button
3123  if (button == Qt::XButton1) {
3124  switch(GET_XBUTTON_WPARAM(msg.wParam)) {
3125  case XBUTTON1:
3126  button = Qt::XButton1;
3127  break;
3128  case XBUTTON2:
3129  button = Qt::XButton2;
3130  break;
3131  }
3132  }
3133 #ifndef Q_OS_WINCE
3134  static bool trackMouseEventLookup = false;
3135  typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT);
3136  static PtrTrackMouseEvent ptrTrackMouseEvent = 0;
3137 #endif
3138  state = translateButtonState(msg.wParam, type, button); // button state
3139  const QPoint widgetPos = mapFromGlobal(QPoint(msg.pt.x, msg.pt.y));
3140  QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos);
3141  if (alienWidget && alienWidget->internalWinId())
3142  alienWidget = 0;
3143 
3144  if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove
3145  || type == QEvent::TabletMove) {
3146 
3147  if (!(state & Qt::MouseButtonMask))
3148  qt_button_down = 0;
3149 #ifndef QT_NO_CURSOR
3150  QCursor *c = qt_grab_cursor();
3151  if (!c)
3153  if (c) // application cursor defined
3154  SetCursor(c->handle());
3155  else if (type != QEvent::NonClientAreaMouseMove && !qt_button_down) {
3156  // use widget cursor if widget is enabled
3157  QWidget *w = alienWidget ? alienWidget : this;
3158  while (!w->isWindow() && !w->isEnabled())
3159  w = w->parentWidget();
3160  SetCursor(w->cursor().handle());
3161  }
3162 #endif // QT_NO_CURSOR
3163 
3164  HWND id = effectiveWinId();
3165  QWidget *mouseGrabber = QWidget::mouseGrabber();
3166  QWidget *activePopupWidget = QApplication::activePopupWidget();
3167  if (mouseGrabber) {
3168  if (!activePopupWidget || (activePopupWidget == this && !rect().contains(widgetPos)))
3169  id = mouseGrabber->effectiveWinId();
3170  } else if (type == QEvent::NonClientAreaMouseMove) {
3171  id = 0;
3172  }
3173 
3174  if (curWin != id) { // new current window
3175  if (id == 0) {
3177  if (!leave)
3178  leave = QWidget::find(curWin);
3180  qt_last_mouse_receiver = 0;
3181  curWin = 0;
3182  } else {
3183  QWidget *leave = 0;
3184  if (curWin && qt_last_mouse_receiver)
3185  leave = qt_last_mouse_receiver;
3186  else
3187  leave = QWidget::find(curWin);
3188  QWidget *enter = alienWidget ? alienWidget : this;
3189  if (mouseGrabber && activePopupWidget) {
3190  if (leave != mouseGrabber)
3191  enter = mouseGrabber;
3192  else
3193  enter = activePopupWidget == this ? this : mouseGrabber;
3194  }
3196  qt_last_mouse_receiver = enter;
3197  curWin = enter ? enter->effectiveWinId() : 0;
3198  }
3199 #ifndef Q_OS_WINCE
3200 
3201  if (curWin != 0) {
3202  if (!trackMouseEventLookup) {
3203  ptrTrackMouseEvent = (PtrTrackMouseEvent)QSystemLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");
3204  trackMouseEventLookup = true;
3205  }
3206  if (ptrTrackMouseEvent && !qApp->d_func()->inPopupMode()) {
3207  // We always have to set the tracking, since
3208  // Windows detects more leaves than we do..
3209  TRACKMOUSEEVENT tme;
3210  tme.cbSize = sizeof(TRACKMOUSEEVENT);
3211  tme.dwFlags = 0x00000002; // TME_LEAVE
3212  tme.hwndTrack = curWin; // Track on window receiving msgs
3213  tme.dwHoverTime = (DWORD)-1; // HOVER_DEFAULT
3214  ptrTrackMouseEvent(&tme);
3215  }
3216  }
3217 #endif // Q_OS_WINCE
3218  }
3219 
3220  POINT curPos = msg.pt;
3221  if (curPos.x == gpos.x && curPos.y == gpos.y)
3222  return true; // same global position
3223  gpos = curPos;
3224 
3225  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
3226  ScreenToClient(internalWinId(), &curPos);
3227 
3228  pos.rx() = curPos.x;
3229  pos.ry() = curPos.y;
3230  pos = d_func()->mapFromWS(pos);
3231  } else {
3232  gpos = msg.pt;
3233  pos = mapFromGlobal(QPoint(gpos.x, gpos.y));
3234 
3235  // mouse button pressed
3236  if (!qt_button_down && (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick)) {
3237  QWidget *tlw = window();
3238  if (QWidget *child = tlw->childAt(mapTo(tlw, pos)))
3239  qt_button_down = child;
3240  else
3241  qt_button_down = this;
3242  }
3243  }
3244 
3245  bool res = false;
3246 
3247  bool nonClientAreaEvent = type >= QEvent::NonClientAreaMouseMove
3249 
3250  if (qApp->d_func()->inPopupMode()) { // in popup mode
3251 
3252  if (nonClientAreaEvent)
3253  return false;
3254 
3255  replayPopupMouseEvent = false;
3256  QWidget* activePopupWidget = QApplication::activePopupWidget();
3257  QWidget *target = activePopupWidget;
3258  const QPoint globalPos(gpos.x, gpos.y);
3259 
3260  if (target != this) {
3261  if ((windowType() == Qt::Popup) && rect().contains(pos) && 0)
3262  target = this;
3263  else // send to last popup
3264  pos = target->mapFromGlobal(globalPos);
3265  }
3266  QWidget *popupChild = target->childAt(pos);
3267  bool releaseAfter = false;
3268  switch (type) {
3271  popupButtonFocus = popupChild;
3272  break;
3274  case QEvent::TabletRelease:
3275 
3276  releaseAfter = true;
3277  break;
3278  default:
3279  break; // nothing for mouse move
3280  }
3281 
3282  if (target->isEnabled()) {
3283  if (popupButtonFocus) {
3284  target = popupButtonFocus;
3285  } else if (popupChild) {
3286  target = popupChild;
3287  }
3288 
3289  pos = target->mapFromGlobal(globalPos);
3290  QMouseEvent e(type, pos, globalPos,
3291  Qt::MouseButton(button),
3292  Qt::MouseButtons(state & Qt::MouseButtonMask),
3293  Qt::KeyboardModifiers(state & Qt::KeyboardModifierMask));
3294  res = QApplicationPrivate::sendMouseEvent(target, &e, alienWidget, this, &qt_button_down,
3295  qt_last_mouse_receiver);
3296  res = res && e.isAccepted();
3297  } else {
3298  // close disabled popups when a mouse button is pressed or released
3299  switch (type) {
3303  target->close();
3304  break;
3305  default:
3306  break;
3307  }
3308  }
3309 
3310  if (releaseAfter) {
3311  popupButtonFocus = 0;
3312  qt_button_down = 0;
3313  }
3314 
3315 #ifndef Q_OS_WINCE
3316  if (type == QEvent::MouseButtonPress
3317  && QApplication::activePopupWidget() != activePopupWidget
3318  && ptrTrackMouseEvent
3319  && curWin) {
3320  // Since curWin is already the window we clicked on,
3321  // we have to setup the mouse tracking here.
3322  TRACKMOUSEEVENT tme;
3323  tme.cbSize = sizeof(TRACKMOUSEEVENT);
3324  tme.dwFlags = 0x00000002; // TME_LEAVE
3325  tme.hwndTrack = curWin; // Track on window receiving msgs
3326  tme.dwHoverTime = (DWORD)-1; // HOVER_DEFAULT
3327  ptrTrackMouseEvent(&tme);
3328  }
3329 #endif
3330  if (type == QEvent::MouseButtonPress
3331  && QApplication::activePopupWidget() != activePopupWidget
3332  && replayPopupMouseEvent) {
3333  // the popup disappeared. Replay the event
3334  QWidget* w = QApplication::widgetAt(gpos.x, gpos.y);
3337  HWND hwndTarget = w->effectiveWinId();
3338  if (QWidget::mouseGrabber() == 0)
3339  setAutoCapture(hwndTarget);
3340  if (!w->isActiveWindow())
3341  w->activateWindow();
3342  POINT widgetpt = gpos;
3343  ScreenToClient(hwndTarget, &widgetpt);
3344  LPARAM lParam = MAKELPARAM(widgetpt.x, widgetpt.y);
3345  PostMessage(hwndTarget, msg.message, msg.wParam, lParam);
3346  }
3347  } else if (type == QEvent::MouseButtonRelease && button == Qt::RightButton
3348  && QApplication::activePopupWidget() == activePopupWidget) {
3349  // popup still alive and received right-button-release
3350 #if !defined(QT_NO_CONTEXTMENU)
3351  QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, globalPos,
3353  bool res2 = QApplication::sendSpontaneousEvent( target, &e2 );
3354  if (!res) // RMB not accepted
3355  res = res2 && e2.isAccepted();
3356 #endif
3357  }
3358  } else { // not popup mode
3359  int bs = state & Qt::MouseButtonMask;
3360  if ((type == QEvent::MouseButtonPress ||
3361  type == QEvent::MouseButtonDblClick) && bs == button) {
3362  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
3363  if (QWidget::mouseGrabber() == 0)
3364  setAutoCapture(internalWinId());
3365  } else if (type == QEvent::MouseButtonRelease && bs == 0) {
3366  if (QWidget::mouseGrabber() == 0)
3368  }
3369 
3370  const QPoint globalPos(gpos.x,gpos.y);
3371  QWidget *widget = QApplicationPrivate::pickMouseReceiver(this, globalPos, pos, type,
3372  Qt::MouseButtons(bs),
3373  qt_button_down, alienWidget);
3374  if (!widget)
3375  return false; // don't send event
3376 
3377  QMouseEvent e(type, pos, globalPos, Qt::MouseButton(button),
3378  Qt::MouseButtons(state & Qt::MouseButtonMask),
3379  Qt::KeyboardModifiers(state & Qt::KeyboardModifierMask));
3380 
3381  res = QApplicationPrivate::sendMouseEvent(widget, &e, alienWidget, this, &qt_button_down,
3382  qt_last_mouse_receiver);
3383 
3384  // non client area events are only informational, you cannot "handle" them
3385  res = res && e.isAccepted() && !nonClientAreaEvent;
3386 #if !defined(QT_NO_CONTEXTMENU)
3387  if (type == QEvent::MouseButtonRelease && button == Qt::RightButton) {
3388  QContextMenuEvent e2(QContextMenuEvent::Mouse, pos, globalPos,
3390  bool res2 = QApplication::sendSpontaneousEvent(widget, &e2);
3391  if (!res)
3392  res = res2 && e2.isAccepted();
3393  }
3394 #endif
3395 
3396  if (type != QEvent::MouseMove)
3397  pos.rx() = pos.ry() = -9999; // init for move compression
3398  }
3399  return res;
3400 }
3401 
3403 {
3404  int state = 0;
3405 
3406  if (sm_blockUserInput) // block user interaction during session management
3407  return true;
3408 
3409  state = translateButtonState(GET_KEYSTATE_WPARAM(msg.wParam), 0, 0);
3410 
3411  int delta;
3412  if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL)
3413  delta = (short) HIWORD (msg.wParam);
3414  else
3415  delta = (int) msg.wParam;
3416 
3417  Qt::Orientation orient = (msg.message == WM_MOUSEHWHEEL || state&Qt::AltModifier
3418 #if 0
3419  // disabled for now - Trenton's one-wheel mouse makes trouble...
3420  // "delta" for usual wheels is +-120. +-240 seems to indicate
3421  // the second wheel see more recent MSDN for WM_MOUSEWHEEL
3422 
3423  ( // <- parantheses added to make update happy, remove if the
3424  // #if 0 is removed
3425  || delta == 240 || delta == -240)?Qt::Horizontal:Vertical;
3426  if (delta == 240 || delta == -240)
3427  delta /= 2;
3428 #endif
3430 
3431  // according to the MSDN documentation on WM_MOUSEHWHEEL:
3432  // a positive value indicates that the wheel was rotated to the right;
3433  // a negative value indicates that the wheel was rotated to the left.
3434  // Qt defines this value as the exact opposite, so we have to flip the value!
3435  if (msg.message == WM_MOUSEHWHEEL)
3436  delta = -delta;
3437 
3438  QPoint globalPos;
3439 
3440  globalPos.rx() = (short)LOWORD (msg.lParam);
3441  globalPos.ry() = (short)HIWORD (msg.lParam);
3442 
3443 
3444  // if there is a widget under the mouse and it is not shadowed
3445  // by modality, we send the event to it first
3446  int ret = 0;
3447  QWidget* w = QApplication::widgetAt(globalPos);
3448  if (!w || !qt_try_modal(w, (MSG*)&msg, ret)) {
3449  //synaptics touchpad shows its own widget at this position
3450  //so widgetAt() will fail with that HWND, try child of this widget
3451  w = this->childAt(this->mapFromGlobal(globalPos));
3452  if (!w)
3453  w = this;
3454  }
3455 
3456  // send the event to the widget or its ancestors
3457  {
3459  if (popup && w->window() != popup)
3460  popup->close();
3461 #ifndef QT_NO_WHEELEVENT
3462  QWheelEvent e(w->mapFromGlobal(globalPos), globalPos, delta,
3463  Qt::MouseButtons(state & Qt::MouseButtonMask),
3465 
3467 #else
3468  Q_UNUSED(orient);
3469 #endif //QT_NO_WHEELEVENT
3470  return true;
3471  }
3472 
3473  // send the event to the widget that has the focus or its ancestors, if different
3474  if (w != QApplication::focusWidget() && (w = QApplication::focusWidget())) {
3476  if (popup && w->window() != popup)
3477  popup->close();
3478 #ifndef QT_NO_WHEELEVENT
3479  QWheelEvent e(w->mapFromGlobal(globalPos), globalPos, delta,
3480  Qt::MouseButtons(state & Qt::MouseButtonMask),
3483 #endif //QT_NO_WHEELEVENT
3484  return true;
3485  }
3486  return false;
3487 }
3488 
3489 
3490 //
3491 // Windows Wintab to QTabletEvent translation
3492 //
3493 
3494 // the following is adapted from the wintab syspress example (public domain)
3495 /* -------------------------------------------------------------------------- */
3496 // Initialize the "static" information of a cursor device (pen, airbrush, etc).
3497 // The QTabletDeviceData is initialized with the data that do not change in time
3498 // (number of button, type of device, etc) but do not initialize the variable data
3499 // (e.g.: pen or eraser)
3500 #ifndef QT_NO_TABLETEVENT
3501 
3502 static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab)
3503 {
3505  Q_ASSERT(ptrWTGet);
3506 
3507  Q_ASSERT(!tCursorInfo()->contains(uniqueId));
3508 
3509  /* browse WinTab's many info items to discover pressure handling. */
3510  AXIS np;
3511  LOGCONTEXT lc;
3512 
3513  /* get the current context for its device variable. */
3514  ptrWTGet(hTab, &lc);
3515 
3516  /* get the size of the pressure axis. */
3517  QTabletDeviceData tdd;
3518  tdd.llId = uniqueId;
3519 
3520  ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_NPRESSURE, &np);
3521  tdd.minPressure = int(np.axMin);
3522  tdd.maxPressure = int(np.axMax);
3523 
3524  ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_TPRESSURE, &np);
3525  tdd.minTanPressure = int(np.axMin);
3526  tdd.maxTanPressure = int(np.axMax);
3527 
3528  LOGCONTEXT lcMine;
3529 
3530  /* get default region */
3531  ptrWTInfo(WTI_DEFCONTEXT, 0, &lcMine);
3532 
3533  tdd.minX = 0;
3534  tdd.maxX = int(lcMine.lcInExtX) - int(lcMine.lcInOrgX);
3535 
3536  tdd.minY = 0;
3537  tdd.maxY = int(lcMine.lcInExtY) - int(lcMine.lcInOrgY);
3538 
3539  tdd.minZ = 0;
3540  tdd.maxZ = int(lcMine.lcInExtZ) - int(lcMine.lcInOrgZ);
3541 
3542  const uint cursorTypeBitMask = 0x0F06; // bitmask to find the specific cursor type (see Wacom FAQ)
3543  if (((csr_type & 0x0006) == 0x0002) && ((csr_type & cursorTypeBitMask) != 0x0902)) {
3544  tdd.currentDevice = QTabletEvent::Stylus;
3545  } else {
3546  switch (csr_type & cursorTypeBitMask) {
3547  case 0x0802:
3548  tdd.currentDevice = QTabletEvent::Stylus;
3549  break;
3550  case 0x0902:
3551  tdd.currentDevice = QTabletEvent::Airbrush;
3552  break;
3553  case 0x0004:
3554  tdd.currentDevice = QTabletEvent::FourDMouse;
3555  break;
3556  case 0x0006:
3557  tdd.currentDevice = QTabletEvent::Puck;
3558  break;
3559  case 0x0804:
3560  tdd.currentDevice = QTabletEvent::RotationStylus;
3561  break;
3562  default:
3563  tdd.currentDevice = QTabletEvent::NoDevice;
3564  }
3565  }
3566  tCursorInfo()->insert(uniqueId, tdd);
3567 }
3568 #endif // QT_NO_TABLETEVENT
3569 
3570 // Update the "dynamic" information of a cursor device (pen, airbrush, etc).
3571 // The dynamic information is the information of QTabletDeviceData that can change
3572 // in time (eraser or pen if a device is turned around).
3573 #ifndef QT_NO_TABLETEVENT
3574 
3576 {
3577  switch (currentCursor % 3) { // %3 for dual track
3578  case 0:
3579  tdd.currentPointerType = QTabletEvent::Cursor;
3580  break;
3581  case 1:
3582  tdd.currentPointerType = QTabletEvent::Pen;
3583  break;
3584  case 2:
3585  tdd.currentPointerType = QTabletEvent::Eraser;
3586  break;
3587  default:
3588  tdd.currentPointerType = QTabletEvent::UnknownPointer;
3589  }
3590 }
3591 #endif // QT_NO_TABLETEVENT
3592 
3594  int numPackets)
3595 {
3596  Q_UNUSED(msg);
3597  POINT ptNew;
3598  static DWORD btnNew, btnOld, btnChange;
3599  qreal prsNew;
3600  ORIENTATION ort;
3601  static bool button_pressed = false;
3602  int i,
3603  tiltX,
3604  tiltY;
3605  bool sendEvent = false;
3606  QEvent::Type t;
3607  int z = 0;
3608  qreal rotation = 0.0;
3609  qreal tangentialPressure;
3610  // The tablet can be used in 2 different modes, depending on it settings:
3611  // 1) Absolute (pen) mode:
3612  // The coordinates are scaled to the virtual desktop (by default). The user
3613  // can also choose to scale to the monitor or a region of the screen.
3614  // When entering proximity, the tablet driver snaps the mouse pointer to the
3615  // tablet position scaled to that area and keeps it in sync.
3616  // 2) Relative (mouse) mode:
3617  // The pen follows the mouse. The constant 'absoluteRange' specifies the
3618  // manhattanLength difference for detecting if a tablet input device is in this mode,
3619  // in which case we snap the position to the mouse position.
3620  // It seems there is no way to find out the mode programmatically, the LOGCONTEXT orgX/Y/Ext
3621  // area is always the virtual desktop.
3622  enum { absoluteRange = 20 };
3623 
3624  // the most common event that we get...
3625  t = QEvent::TabletMove;
3626  for (i = 0; i < numPackets; i++) {
3627  // get the unique ID of the device...
3628  btnOld = btnNew;
3629  btnNew = localPacketBuf[i].pkButtons;
3630  btnChange = btnOld ^ btnNew;
3631 
3632  if (btnNew & btnChange) {
3633  button_pressed = true;
3634  t = QEvent::TabletPress;
3635  }
3636  ptNew.x = UINT(localPacketBuf[i].pkX);
3637  ptNew.y = UINT(localPacketBuf[i].pkY);
3638 #ifndef QT_NO_TABLETEVENT
3639  z = (currentTabletPointer.currentDevice == QTabletEvent::FourDMouse) ? UINT(localPacketBuf[i].pkZ) : 0;
3640 #else
3641  Q_UNUSED(z);
3642 #endif // QT_NO_TABLETEVENT
3643  prsNew = 0.0;
3644  QRect desktopArea = QApplication::desktop()->geometry();
3645 
3646  // This code is to delay the tablet data one cycle to sync with the mouse location.
3647  QPointF hiResTabletGlobalPosF = oldHiResTabletGlobalPosF;
3648  oldHiResTabletGlobalPosF =
3649  currentTabletPointer.scaleCoord(ptNew.x, ptNew.y, desktopArea.left(),
3650  desktopArea.width(), desktopArea.top(),
3651  desktopArea.height());
3652 
3653  if (btnNew) {
3654 #ifndef QT_NO_TABLETEVENT
3655  if (currentTabletPointer.currentPointerType == QTabletEvent::Pen || currentTabletPointer.currentPointerType == QTabletEvent::Eraser)
3656  prsNew = localPacketBuf[i].pkNormalPressure
3657  / qreal(currentTabletPointer.maxPressure
3658  - currentTabletPointer.minPressure);
3659  else
3660 #endif // QT_NO_TABLETEVENT
3661  prsNew = 0;
3662  } else if (button_pressed) {
3663  // One button press, should only give one button release
3665  button_pressed = false;
3666  }
3667  QPoint globalPos = hiResTabletGlobalPosF.toPoint();
3668 
3669  // Get Mouse Position and compare to tablet info
3670  // Positions should be almost the same if we are in absolute
3671  // mode. If they are not, use the mouse location.
3672 #ifndef Q_WS_WINCE
3673  POINT mouseLocationP;
3674  if (GetCursorPos(&mouseLocationP)) {
3675  const QPoint mouseLocation(mouseLocationP.x, mouseLocationP.y);
3676  if ((mouseLocation - globalPos).manhattanLength() > absoluteRange) {
3677  globalPos = mouseLocation;
3678  hiResTabletGlobalPosF = globalPos;
3679  }
3680  }
3681 #endif // !Q_WS_WINCE
3682 
3683  if (t == QEvent::TabletPress)
3684  {
3685  qt_button_down = QApplication::widgetAt(globalPos);
3686  }
3687 
3688  // make sure the tablet event get's sent to the proper widget...
3689  QWidget *w = 0;
3690 
3691  if (qt_button_down)
3692  w = qt_button_down; // Pass it to the thing that's grabbed it.
3693  else
3694  w = QApplication::widgetAt(globalPos);
3695 
3696  if (!w)
3697  w = this;
3698 
3699  if (t == QEvent::TabletRelease)
3700  {
3701  if (qt_win_ignoreNextMouseReleaseEvent) {
3702  qt_win_ignoreNextMouseReleaseEvent = false;
3703  if (qt_button_down && qt_button_down->internalWinId() == autoCaptureWnd) {
3705  qt_button_down = 0;
3706  }
3707  }
3708 
3709  }
3710 
3711  QPoint localPos = w->mapFromGlobal(globalPos);
3712 #ifndef QT_NO_TABLETEVENT
3713  if (currentTabletPointer.currentDevice == QTabletEvent::Airbrush) {
3714  tangentialPressure = localPacketBuf[i].pkTangentPressure
3715  / qreal(currentTabletPointer.maxTanPressure
3716  - currentTabletPointer.minTanPressure);
3717  } else {
3718  tangentialPressure = 0.0;
3719  }
3720 #else
3721  tangentialPressure = 0.0;
3722 #endif // QT_NO_TABLETEVENT
3723 
3724  if (!qt_tablet_tilt_support) {
3725  tiltX = tiltY = 0;
3726  rotation = 0.0;
3727  } else {
3728  ort = localPacketBuf[i].pkOrientation;
3729  // convert from azimuth and altitude to x tilt and y tilt
3730  // what follows is the optimized version. Here are the equations
3731  // I used to get to this point (in case things change :)
3732  // X = sin(azimuth) * cos(altitude)
3733  // Y = cos(azimuth) * cos(altitude)
3734  // Z = sin(altitude)
3735  // X Tilt = arctan(X / Z)
3736  // Y Tilt = arctan(Y / Z)
3737  double radAzim = (ort.orAzimuth / 10) * (Q_PI / 180);
3738  //double radAlt = abs(ort.orAltitude / 10) * (Q_PI / 180);
3739  double tanAlt = tan((abs(ort.orAltitude / 10)) * (Q_PI / 180));
3740 
3741  double degX = atan(sin(radAzim) / tanAlt);
3742  double degY = atan(cos(radAzim) / tanAlt);
3743  tiltX = int(degX * (180 / Q_PI));
3744  tiltY = int(-degY * (180 / Q_PI));
3745  rotation = ort.orTwist;
3746  }
3747 #ifndef QT_NO_TABLETEVENT
3748  QTabletEvent e(t, localPos, globalPos, hiResTabletGlobalPosF, currentTabletPointer.currentDevice,
3749  currentTabletPointer.currentPointerType, prsNew, tiltX, tiltY,
3750  tangentialPressure, rotation, z, QApplication::keyboardModifiers(), currentTabletPointer.llId);
3751  sendEvent = QApplication::sendSpontaneousEvent(w, &e);
3752 #endif // QT_NO_TABLETEVENT
3753  }
3754  return sendEvent;
3755 }
3756 
3757 extern bool qt_is_gui_used;
3758 
3759 
3760 #ifndef QT_NO_TABLETEVENT
3761 
3762 static void initWinTabFunctions()
3763 {
3764 #if defined(Q_OS_WINCE)
3765  return;
3766 #else
3767  if (!qt_is_gui_used)
3768  return;
3769 
3770  QSystemLibrary library(QLatin1String("wintab32"));
3771  ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
3772  ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
3773  ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable");
3774  ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap");
3775  ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet");
3776 #endif // Q_OS_WINCE
3777 }
3778 #endif // QT_NO_TABLETEVENT
3779 
3780 
3781 //
3782 // Paint event translation
3783 //
3785 {
3786  if (!isWindow() && testAttribute(Qt::WA_NativeWindow))
3787  Q_ASSERT(internalWinId());
3788 
3789  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
3790  if (!GetUpdateRect(internalWinId(), 0, FALSE)) { // The update bounding rect is invalid
3791  d_func()->hd = 0;
3792  setAttribute(Qt::WA_PendingUpdate, false);
3793  return false;
3794  }
3795 
3796  if (msg.message == WM_ERASEBKGND)
3797  return true;
3798 
3799  setAttribute(Qt::WA_PendingUpdate, false);
3800 
3801  if (d_func()->isGLWidget) {
3802  if (d_func()->usesDoubleBufferedGLContext)
3803  InvalidateRect(internalWinId(), 0, false);
3804  } else {
3805  const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
3806  // Make sure the invalidated region contains the region we're about to repaint.
3807  // BeginPaint will set the clip to the invalidated region and it is impossible
3808  // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
3809  // as it may return an invalid context (especially on Windows Vista).
3810  if (!dirtyInBackingStore.isEmpty())
3811  InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
3812  }
3813  PAINTSTRUCT ps;
3814  d_func()->hd = BeginPaint(internalWinId(), &ps);
3815 
3816  const QRect updateRect(QPoint(ps.rcPaint.left, ps.rcPaint.top),
3817  QPoint(ps.rcPaint.right, ps.rcPaint.bottom));
3818 
3819  // Mapping region from system to qt (32 bit) coordinate system.
3820  d_func()->syncBackingStore(updateRect.translated(data->wrect.topLeft()));
3821 
3822  d_func()->hd = 0;
3823  EndPaint(internalWinId(), &ps);
3824 
3825  return true;
3826 }
3827 
3828 //
3829 // Window move and resize (configure) events
3830 //
3831 
3833 {
3834  if (!testAttribute(Qt::WA_WState_Created)) // in QWidget::create()
3835  return true;
3836  if (testAttribute(Qt::WA_WState_ConfigPending))
3837  return true;
3838  if (testAttribute(Qt::WA_DontShowOnScreen))
3839  return true;
3840  if (!isWindow())
3841  return true;
3842  setAttribute(Qt::WA_WState_ConfigPending); // set config flag
3843  QRect cr = geometry();
3844  if (msg.message == WM_SIZE) { // resize event
3845  WORD a = LOWORD(msg.lParam);
3846  WORD b = HIWORD(msg.lParam);
3847  QSize oldSize = size();
3848  QSize newSize(a, b);
3849 #ifdef Q_WS_WINCE_WM
3850  if (isFullScreen() && (oldSize.width() == newSize.height()) && (oldSize.height() == newSize.width()))
3851  qt_wince_hide_taskbar(internalWinId());
3852 #endif
3853  cr.setSize(newSize);
3854  if (msg.wParam != SIZE_MINIMIZED)
3855  data->crect = cr;
3856  if (isWindow()) { // update title/icon text
3857  d_func()->createTLExtra();
3858  // Capture SIZE_MINIMIZED without preceding WM_SYSCOMMAND
3859  // (like Windows+M)
3860  if (msg.wParam == SIZE_MINIMIZED && !isMinimized()) {
3861 #ifndef Q_WS_WINCE
3862  const QString title = windowIconText();
3863  if (!title.isEmpty())
3864  d_func()->setWindowTitle_helper(title);
3865 #endif
3866  data->window_state |= Qt::WindowMinimized;
3867  if (isVisible()) {
3868  QHideEvent e;
3870  hideChildren(true);
3871  }
3872  } else if (msg.wParam != SIZE_MINIMIZED) {
3873  bool window_state_changed = false;
3874  Qt::WindowStates oldstate = Qt::WindowStates(dataPtr()->window_state);
3875  if (isMinimized()) {
3876 #ifndef Q_WS_WINCE
3877  const QString title = windowTitle();
3878  if (!title.isEmpty())
3879  d_func()->setWindowTitle_helper(title);
3880 #endif
3881  data->window_state &= ~Qt::WindowMinimized;
3882  showChildren(true);
3883  QShowEvent e;
3885  // Capture SIZE_MAXIMIZED and SIZE_RESTORED without preceding WM_SYSCOMMAND
3886  // (Aero Snap on Win7)
3887  } else if (msg.wParam == SIZE_MAXIMIZED && !isMaximized()) {
3888  data->window_state |= Qt::WindowMaximized;
3889  window_state_changed = true;
3890  } else if (msg.wParam == SIZE_RESTORED && isMaximized()) {
3891  data->window_state &= ~(Qt::WindowMaximized);
3892  window_state_changed = true;
3893  }
3894  if (window_state_changed) {
3895  QWindowStateChangeEvent e(oldstate);
3897  }
3898  }
3899  }
3900  if (msg.wParam != SIZE_MINIMIZED && oldSize != newSize) {
3901  if (isVisible()) {
3902  QTLWExtra *tlwExtra = maybeTopData();
3903  static bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt();
3904  const bool hasStaticContents = tlwExtra && tlwExtra->backingStore
3905  && tlwExtra->backingStore->hasStaticContents();
3906  // If we have a backing store with static contents, we have to disable the top-level
3907  // resize optimization in order to get invalidated regions for resized widgets.
3908  // The optimization discards all invalidateBuffer() calls since we're going to
3909  // repaint everything anyways, but that's not the case with static contents.
3910  if (!slowResize && tlwExtra && !hasStaticContents)
3911  tlwExtra->inTopLevelResize = true;
3912  QResizeEvent e(newSize, oldSize);
3914  if (d_func()->paintOnScreen()) {
3915  QRegion updateRegion(rect());
3916  if (testAttribute(Qt::WA_StaticContents))
3917  updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
3918  d_func()->syncBackingStore(updateRegion);
3919  } else {
3920  d_func()->syncBackingStore();
3921  }
3922  if (!slowResize && tlwExtra)
3923  tlwExtra->inTopLevelResize = false;
3924  } else {
3925  QResizeEvent *e = new QResizeEvent(newSize, oldSize);
3926  QApplication::postEvent(this, e);
3927  }
3928  }
3929  } else if (msg.message == WM_MOVE) { // move event
3930  int a = (int) (short) LOWORD(msg.lParam);
3931  int b = (int) (short) HIWORD(msg.lParam);
3932  QPoint oldPos = geometry().topLeft();
3933  QPoint newCPos(a, b);
3934  // Ignore silly Windows move event to wild pos after iconify.
3935 #if !defined(Q_WS_WINCE)
3936  if (!IsIconic(internalWinId()) && newCPos != oldPos) {
3937 #endif
3938  cr.moveTopLeft(newCPos);
3939  data->crect = cr;
3940  if (isVisible()) {
3941  QMoveEvent e(newCPos, oldPos); // cpos (client position)
3943  } else {
3944  QMoveEvent * e = new QMoveEvent(newCPos, oldPos);
3945  QApplication::postEvent(this, e);
3946  }
3947 #if !defined(Q_WS_WINCE)
3948  }
3949 #endif
3950  }
3951  setAttribute(Qt::WA_WState_ConfigPending, false); // clear config flag
3952  return true;
3953 }
3954 
3955 
3956 //
3957 // Close window event translation.
3958 //
3959 // This class is a friend of QApplication because it needs to emit the
3960 // lastWindowClosed() signal when the last top level widget is closed.
3961 //
3962 
3964 {
3965  return d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
3966 }
3967 
3968 #ifndef QT_NO_GESTURES
3970 {
3971  const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
3972  QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos);
3973  if (alienWidget && alienWidget->internalWinId())
3974  alienWidget = 0;
3975  QWidget *widget = alienWidget ? alienWidget : this;
3976 
3978  event.sequenceId = gi.dwSequenceID;
3979  event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
3980  event.argument = gi.ullArguments;
3981 
3982  switch (gi.dwID) {
3983  case GID_BEGIN:
3984  event.gestureType = QNativeGestureEvent::GestureBegin;
3985  break;
3986  case GID_END:
3987  event.gestureType = QNativeGestureEvent::GestureEnd;
3988  break;
3989  case GID_ZOOM:
3990  event.gestureType = QNativeGestureEvent::Zoom;
3991  break;
3992  case GID_PAN:
3993  event.gestureType = QNativeGestureEvent::Pan;
3994  break;
3995  case GID_ROTATE:
3996  event.gestureType = QNativeGestureEvent::Rotate;
3997  break;
3998  case GID_TWOFINGERTAP:
3999  case GID_ROLLOVER:
4000  default:
4001  break;
4002  }
4004  qt_sendSpontaneousEvent(widget, &event);
4005  return true;
4006 }
4007 #endif // QT_NO_GESTURES
4008 
4009 void QApplication::setCursorFlashTime(int msecs)
4010 {
4011  SetCaretBlinkTime(msecs / 2);
4013 }
4014 
4015 
4017 {
4018  int blink = (int)GetCaretBlinkTime();
4019  if (!blink)
4021  if (blink > 0)
4022  return 2*blink;
4023  return 0;
4024 }
4025 
4026 
4028 {
4029 #ifndef Q_WS_WINCE
4030  SetDoubleClickTime(ms);
4031 #endif
4033 }
4034 
4036 {
4037  int ms = GetDoubleClickTime();
4038  if (ms != 0)
4039  return ms;
4041 }
4042 
4043 
4045 {
4047 }
4048 
4050 {
4051  // FIXME: get from the system
4053 }
4054 
4055 #ifndef QT_NO_WHEELEVENT
4057 {
4058 #ifdef SPI_SETWHEELSCROLLLINES
4059  if (n < 0)
4060  n = 0;
4061  SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
4062 #else
4064 #endif
4065 }
4066 
4068 {
4069 #ifdef SPI_GETWHEELSCROLLLINES
4070  uint i = 3;
4071  SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
4072  if (i > INT_MAX)
4073  i = INT_MAX;
4074  return i;
4075 #else
4077 #endif
4078 }
4079 #endif //QT_NO_WHEELEVENT
4080 
4081 static bool effect_override = false;
4082 
4083 void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
4084 {
4085  effect_override = true;
4086  switch (effect) {
4087  case Qt::UI_AnimateMenu:
4089  break;
4090  case Qt::UI_FadeMenu:
4092  break;
4093  case Qt::UI_AnimateCombo:
4095  break;
4096  case Qt::UI_AnimateTooltip:
4098  break;
4099  case Qt::UI_FadeTooltip:
4101  break;
4102  case Qt::UI_AnimateToolBox:
4104  break;
4105  default:
4107  break;
4108  }
4109 }
4110 
4112 {
4113  if (QColormap::instance().depth() < 16)
4114  return false;
4115 
4116  if (!effect_override && desktopSettingsAware()) {
4117  // we know that they can be used when we are here
4118  BOOL enabled = false;
4119  UINT api;
4120  switch (effect) {
4121  case Qt::UI_AnimateMenu:
4122  api = SPI_GETMENUANIMATION;
4123  break;
4124  case Qt::UI_FadeMenu:
4125  api = SPI_GETMENUFADE;
4126  break;
4127  case Qt::UI_AnimateCombo:
4129  break;
4130  case Qt::UI_AnimateTooltip:
4132  break;
4133  case Qt::UI_FadeTooltip:
4134  api = SPI_GETTOOLTIPFADE;
4135  break;
4136  default:
4137  api = SPI_GETUIEFFECTS;
4138  break;
4139  }
4140  SystemParametersInfo(api, 0, &enabled, 0);
4141  return enabled;
4142  }
4143 
4144  switch(effect) {
4145  case Qt::UI_AnimateMenu:
4147  case Qt::UI_FadeMenu:
4149  case Qt::UI_AnimateCombo:
4151  case Qt::UI_AnimateTooltip:
4153  case Qt::UI_FadeTooltip:
4155  case Qt::UI_AnimateToolBox:
4157  default:
4159  }
4160 }
4161 
4162 #ifndef QT_NO_SESSIONMANAGER
4163 
4165 {
4166  sm_blockUserInput = false;
4167  return true;
4168 }
4169 
4171 {
4172  sm_blockUserInput = false;
4173  return true;
4174 }
4175 
4177 {
4178  if (sm_smActive)
4179  sm_blockUserInput = true;
4180 }
4181 
4183 {
4184  sm_cancel = true;
4185 }
4186 
4187 #endif //QT_NO_SESSIONMANAGER
4188 
4189 
4194 
4196 {
4199  static const int QT_SM_DIGITIZER = 94;
4200  int value = GetSystemMetrics(QT_SM_DIGITIZER);
4201  static const int QT_NID_INTEGRATED_TOUCH = 0x01;
4202  static const int QT_NID_EXTERNAL_TOUCH = 0x02;
4203  static const int QT_NID_MULTI_INPUT = 0x40;
4204  QApplicationPrivate::HasTouchSupport =
4205  value & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH | QT_NID_MULTI_INPUT);
4206  }
4207 
4208  QSystemLibrary library(QLatin1String("user32"));
4209  // MinGW (g++ 3.4.5) accepts only C casts.
4210  RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
4211  GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
4212  CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
4213 
4214  touchInputIDToTouchPointID.clear();
4215 }
4216 
4218 {
4219  touchInputIDToTouchPointID.clear();
4220 }
4221 
4223 {
4224  QWidget *widgetForHwnd = QWidget::find(msg.hwnd);
4225  if (!widgetForHwnd)
4226  return false;
4227 
4228  QRect screenGeometry = QApplication::desktop()->screenGeometry(widgetForHwnd);
4229 
4230  QList<QTouchEvent::TouchPoint> touchPoints;
4231 
4232  QVector<TOUCHINPUT> winTouchInputs(msg.wParam);
4233  memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchInputs.count());
4234  Qt::TouchPointStates allStates = 0;
4235  QApplicationPrivate::GetTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
4236  for (int i = 0; i < winTouchInputs.count(); ++i) {
4237  const TOUCHINPUT &touchInput = winTouchInputs.at(i);
4238 
4239  int touchPointID = touchInputIDToTouchPointID.value(touchInput.dwID, -1);
4240  if (touchPointID == -1) {
4241  touchPointID = touchInputIDToTouchPointID.count();
4242  touchInputIDToTouchPointID.insert(touchInput.dwID, touchPointID);
4243  }
4244 
4245  QTouchEvent::TouchPoint touchPoint(touchPointID);
4246 
4247  // update state
4248  QPointF screenPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.));
4249  QRectF screenRect;
4250  if (touchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
4251  screenRect.setSize(QSizeF(qreal(touchInput.cxContact) / qreal(100.),
4252  qreal(touchInput.cyContact) / qreal(100.)));
4253  screenRect.moveCenter(screenPos);
4254 
4255  Qt::TouchPointStates state;
4256  if (touchInput.dwFlags & TOUCHEVENTF_DOWN) {
4257  state = Qt::TouchPointPressed;
4258  } else if (touchInput.dwFlags & TOUCHEVENTF_UP) {
4259  state = Qt::TouchPointReleased;
4260  } else {
4261  state = (screenPos == touchPoint.screenPos()
4264  }
4265  if (touchInput.dwFlags & TOUCHEVENTF_PRIMARY)
4266  state |= Qt::TouchPointPrimary;
4267  touchPoint.setState(state);
4268  touchPoint.setScreenRect(screenRect);
4269  touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(),
4270  screenPos.y() / screenGeometry.height()));
4271 
4272  allStates |= state;
4273 
4274  touchPoints.append(touchPoint);
4275  }
4277 
4278  if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) {
4279  // all touch points released, forget the ids we've seen, they may not be reused
4280  touchInputIDToTouchPointID.clear();
4281  }
4282 
4283  translateRawTouchEvent(widgetForHwnd, QTouchEvent::TouchScreen, touchPoints);
4284  return true;
4285 }
4286 
#define SPI_GETTOOLTIPFADE
Definition: qt_windows.h:101
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QPointF oldHiResTabletGlobalPosF
#define GID_BEGIN
static void qt_set_windows_font_resources()
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QPoint pos() const
static int keyboardInputInterval()
#define WM_MOUSEWHEEL
Definition: qt_windows.h:116
static void updateSystemPrivate()
Definition: qlocale.cpp:478
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
int(API * PtrWTQueueSizeGet)(HCTX)
#define CSR_TYPE
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
static QWidget * main_widget
bool qt_app_has_font
bool allowsErrorInteraction()
Returns true if error interaction is permitted; otherwise returns false.
static HWND autoCaptureWnd
static void setAutoCapture(HWND)
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
void hideChildren(bool spontaneous)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
int minimumHeight() const
static QColormap instance(int screen=-1)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
int reconvertString(RECONVERTSTRING *reconv)
unsigned int QRgb
Definition: qrgb.h:53
static QWidgetList topLevelWidgets()
BOOL(API * PtrWTEnable)(HCTX, BOOL)
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
unsigned long WId
Definition: qwindowdefs.h:119
#define WM_GETOBJECT
static bool checkInstance(const char *method)
static void setPalette(const QPalette &, const char *className=0)
Changes the default application palette to palette.
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
void push_back(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:296
const QBrush & brightText() const
Returns the bright text foreground brush of the current color group.
Definition: qpalette.h:137
int type
Definition: qmetatype.cpp:239
static void beep()
Sounds the bell, using the default volume and sound.
void qWinRequestConfig(WId id, int req, int x, int y, int w, int h)
bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags)
Processes pending events that match flags until there are no more events to process.
double qreal
Definition: qglobal.h:1193
#define SPI_GETMENUFADE
Definition: qt_windows.h:92
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
#define disabled
BOOL(WINAPI * PtrEndPanningFeedback)(HWND, BOOL)
PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
HCTX qt_tablet_context
static mach_timebase_info_data_t info
unsigned char c[8]
Definition: qnumeric_p.h:62
#define WM_TOUCH
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int qint32
Definition: qglobal.h:937
QSize size() const
QPointer< QWidget > widget
QTabletDeviceData currentTabletPointer
void clear()
Removes all items from the hash.
Definition: qhash.h:574
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
static QWidget * pickMouseReceiver(QWidget *candidate, const QPoint &globalPos, QPoint &pos, QEvent::Type type, Qt::MouseButtons buttons, QWidget *buttonDown, QWidget *alienWidget)
bool qt_wince_is_smartphone()
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
static bool sm_cancel
static bool qt_is_translatable_mouse_event(UINT message)
static bool fade_tooltip
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
static PtrWTEnable ptrWTEnable
#define WM_MOUSEHWHEEL
Definition: qt_windows.h:119
#define it(className, varName)
static PtrCloseTouchInputHandle CloseTouchInputHandle
#define ULONG_PTR
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define WM_THEMECHANGED
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:89
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
#define WM_DRAWCLIPBOARD
bool isVisible() const
Definition: qwidget.h:1005
static void initializeWidgetPaletteHash()
void markFrameStrutDirty()
#define LR_SHARED
Definition: qt_windows.h:147
BOOL(WINAPI * PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int)
QRegion qt_dirtyRegion(QWidget *)
Definition: qwidget.cpp:1111
Q_GUI_EXPORT bool qt_cleartype_enabled
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent
QFont qt_LOGFONTtoQFont(LOGFONT &lf, bool scale)
Definition: qfont_win.cpp:64
static void qWinProcessConfigRequests()
static HPALETTE hPal()
void qt_wince_hide_taskbar(HWND hwnd)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define FAPPCOMMAND_KEY
QString windowIconText() const
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
bool translateGestureEvent(const MSG &msg, const GESTUREINFO &gi)
QRgb qt_colorref2qrgb(COLORREF col)
uint window_state
Definition: qwidget.h:120
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define TOUCHEVENTF_UP
void setLocale_helper(const QLocale &l, bool forceUpdate=false)
Definition: qwidget.cpp:6128
#define SEM_FAILCRITICALERRORS
static int wheel_scroll_lines
PtrSetGestureConfig SetGestureConfig
static WinVersion windowsVersion()
Returns the version of the Windows operating system on which the application is run (Windows only)...
PtrUpdatePanningFeedback UpdatePanningFeedback
#define COLOR_MENUBAR
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
uint inTopLevelResize
Definition: qwidget_p.h:188
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
bool winEvent(MSG *m, long *r)
This special event handler can be reimplemented in a subclass to receive native Windows events which ...
static void wceCommands(uint command)
This function sends native Windows CE commands to Qt menu bars and all their child menus...
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QGuiEventDispatcherWin32(QObject *parent=0)
#define TOUCHEVENTF_DOWN
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
#define FE_FONTSMOOTHINGCLEARTYPE
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
QWidget * nextInFocusChain() const
Returns the next widget in this widget&#39;s focus chain.
Definition: qwidget.cpp:6873
HCTX(API * PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL)
static QWidget * active_window
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
void syncBackingStore(const QRegion &rgn)
static QApplicationPrivate * instance()
static void cleanup()
Internal function that cleans up the font system.
Definition: qfont_mac.cpp:93
long ASN1_INTEGER_get ASN1_INTEGER * a
bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define SPI_SETNONCLIENTMETRICS
static QStyle * style()
Returns the application&#39;s style object.
BOOL(API * PtrWTQueueSizeSet)(HCTX, int)
bool underMouse() const
Returns true if the widget is under the mouse cursor; otherwise returns false.
Definition: qwidget.h:996
void closePopup(QWidget *popup)
BOOL(WINAPI * PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT)
KeyboardModifier
Definition: qnamespace.h:127
BOOL(WINAPI * PtrCloseTouchInputHandle)(HANDLE)
#define GID_ROTATE
static int cursorFlashTime()
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
QString appName() const
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool hasFocus() const
Definition: qwidget.cpp:6583
static QList< QWinConfigRequest * > * configRequests
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
#define APPCOMMAND_TREBLE_DOWN
QClipboard * qt_clipboard
static bool animate_ui
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
void setNormalizedPos(const QPointF &normalizedPos)
Definition: qevent.cpp:4703
QWidget * qt_get_tablet_widget()
QEventDispatcherWin32(QObject *parent=0)
static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab)
void updateKeyMap(const MSG &msg)
static void resolveAygLibs()
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
PtrEndPanningFeedback EndPanningFeedback
bool qt_wince_is_pocket_pc()
BOOL(WINAPI * PtrBeginPanningFeedback)(HWND)
ULONGLONG ullArguments
#define MK_XBUTTON1
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
static PtrWTGet ptrWTGet
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
#define APPCOMMAND_BASS_UP
int height() const
static int wheelScrollLines()
static QSize closestAcceptableSize(const QWidget *w, const QSize &s)
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is ...
Definition: qlayout.cpp:1586
BOOL(WINAPI * PtrRegisterTouchWindow)(HWND, ULONG)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
PtrGetGestureInfo GetGestureInfo
BOOL(WINAPI * PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst, const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey, const BLENDFUNCTION *pblend, DWORD dwflags)
#define WM_SETCURSOR
static HDC displayDC
qint32 minw
Definition: qwidget_p.h:264
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
Q_GUI_EXPORT bool qt_win_owndc_required
bool event(QEvent *e)
This virtual function receives events to an object and should return true if the event e was recogniz...
static BOOL WINAPI qt_updateLayeredWindowIndirect(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *info)
static HWND curWin
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool allowsInteraction()
Asks the session manager for permission to interact with the user.
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void showChildren(bool spontaneous)
#define Q_Q(Class)
Definition: qglobal.h:2483
BOOL(WINAPI * PtrCloseGestureInfoHandle)(HANDLE)
#define SPI_GETFLATMENU
Definition: qt_windows.h:133
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
#define ATOM(x)
Definition: qt_x11_p.h:723
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
#define SW_PARENTOPENING
void clearFocus()
Takes keyboard input focus from the widget.
Definition: qwidget.cpp:6757
void release()
Releases the session manager&#39;s interaction semaphore after an interaction phase.
static int keyboard_input_time
static void quit()
Tells the application to exit with return code 0 (success).
BOOL(API * PtrWTOverlap)(HCTX, BOOL)
void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately=false, bool invalidateBuffer=false)
Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest e...
uint qGlobalPostedEventsCount()
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
void setWindowTitle_helper(const QString &title)
static bool inLoop
#define XBUTTON1
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
static void unregWinClasses()
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
UINT(API * PtrWTInfo)(UINT, UINT, LPVOID)
#define DEFAULT_GUI_FONT
bool qt_wince_is_mobile()
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
static QThreadData * get2(QThread *thread)
Definition: qthread_p.h:219
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static void setSystemFont(const QFont &font)
The QSessionManager class provides access to the session manager.
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
#define QT_WIN_CALLBACK
Definition: qglobal.h:1178
struct tagTRACKMOUSEEVENT * LPTRACKMOUSEEVENT
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual QString appName() const
QRect normalGeometry
Definition: qwidget_p.h:181
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QTLWExtra * topData()
#define HWND_TOPMOST
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
#define SPI_GETMENUANIMATION
Definition: qt_windows.h:89
bool isAccepted() const
Definition: qcoreevent.h:307
static bool isEmpty(const char *str)
#define SHRG_RETURNCMD
QDesktopWidget * qt_desktopWidget
static AygRecognizeGesture ptrRecognizeGesture
#define APPCOMMAND_HELP
static PACKET localPacketBuf[QT_TABLET_NPACKETQSIZE]
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
unsigned __int64 quint64
Definition: qglobal.h:943
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
static QCursorData * currentCursor
Definition: qcursor_mac.mm:106
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
qint32 maxw
Definition: qwidget_p.h:266
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QPointer< QWidget > qt_last_mouse_receiver
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
static void initialize()
Internal function that initializes the font system.
Definition: qfont_mac.cpp:131
#define qApp
struct tagGESTUREINFO GESTUREINFO
int width() const
bool translateWheelEvent(const QWSMouseEvent *me)
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
#define APPCOMMAND_FIND
static const ushort mouseTbl[]
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static bool qt_try_modal(QWidget *, MSG *, int &ret)
#define SPI_GETCOMBOBOXANIMATION
Definition: qt_windows.h:95
static QWidgetList * popupWidgets
qint32 maxh
Definition: qwidget_p.h:267
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QColor dark(int f=200) const
Use darker(factor) instead.
Definition: qcolor.cpp:2447
#define GID_ROLLOVER
BOOL(WINAPI * PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL)
const QString qt_reg_winclass(QWidget *w)
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition: qpalette.h:136
static void clear()
Removes all pixmaps from the cache.
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
Qt::KeyboardModifiers qt_win_getKeyboardModifiers()
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
static int mouse_double_click_time
#define WM_XBUTTONUP
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
#define GET_XBUTTON_WPARAM(wParam)
static HWND imeParentWnd
Q_CORE_EXPORT void qWarning(const char *,...)
void qt_win_eatMouseMove()
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
#define GET_X_LPARAM(lp)
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
static void setKeyboardInputInterval(int)
int(API * PtrWTPacketsGet)(HCTX, int, LPVOID)
PtrGetGestureExtraArgs GetGestureExtraArgs
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
static bool animate_combo
static void alert(QWidget *widget, int duration=0)
Q_GUI_EXPORT qreal qt_fontsmoothing_gamma
static bool HasTouchSupport
QString windowTitle() const
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
QCursor * qt_grab_cursor()
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
#define LR_DEFAULTSIZE
Definition: qt_windows.h:144
struct tagTOUCHINPUT TOUCHINPUT
#define GET_DEVICE_LPARAM(lParam)
#define COLOR_MENUHILIGHT
DWORD(API * AygRecognizeGesture)(SHRGINFO *)
QPointF screenPos() const
Returns the screen position of this touch point.
Definition: qevent.cpp:4498
#define APPCOMMAND_BASS_DOWN
#define IMR_CONFIRMRECONVERTSTRING
#define WM_GESTURE
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
#define SPI_SETICONTITLELOGFONT
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.
static QPalette * sys_pal
BOOL(WINAPI * PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE)
#define WM_CHANGECBCHAIN
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
bool hasStaticContents() const
Qt::ContextMenuPolicy contextMenuPolicy
how the widget shows a context menu
Definition: qwidget.h:189
#define GID_END
UIEffect
Definition: qnamespace.h:1252
static PtrRegisterTouchWindow RegisterTouchWindow
void * HANDLE
Definition: qnamespace.h:1671
QHash< QString, int > WinClassNameHash
void setScreenRect(const QRectF &screenRect)
Definition: qevent.cpp:4791
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
static void tabletUpdateCursor(QTabletDeviceData &tdd, const UINT currentCursor)
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
#define IMR_RECONVERTSTRING
static void releaseAutoCapture()
Q_GUI_EXPORT HDC qt_win_display_dc()
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
QWidgetPrivate * dptr()
#define GET_KEYSTATE_WPARAM(wParam)
void syncBackingStore()
void showMinimized()
Shows the widget minimized, as an icon.
Definition: qwidget.cpp:3038
static PtrGetTouchInputInfo GetTouchInputInfo
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
void setSize(const QSizeF &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:790
bool isEnabled() const
Definition: qwidget.h:948
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window)
Sets a the group at cg.
Definition: qpalette.cpp:1246
static bool startingUp()
Returns true if an application object has not been created yet; otherwise returns false...
static void enterModal_sys(QWidget *)
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
#define SetErrorMode(a)
static void initWinTabFunctions()
static bool animate_tooltip
bool qt_use_rtl_extensions
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
static bool sm_smActive
QWidgetList * qt_modal_stack
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
static PtrWTPacketsGet ptrWTPacketsGet
bool composition(LPARAM lparam)
QWExtra * xtra()
struct tagMSG MSG
long HRESULT
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
void qt_init(QApplicationPrivate *priv, int)
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static Qt::KeyboardModifiers queryKeyboardModifiers()
Queries and returns the state of the modifier keys on the keyboard.
static void setCursorFlashTime(int)
uint testWindowState(uint teststate)
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
void * resolve(const char *symbol)
const QRect screenGeometry(int screen=-1) const
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static QWidget * activePopupWidget()
Returns the active popup widget.
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
bool qt_nograb()
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
static bool app_do_modal
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
void qt_win_set_cursor(QWidget *w, bool force)
#define SPI_SETFONTSMOOTHINGTYPE
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static bool isBlockedByModal(QWidget *widget)
Returns true if widget is blocked by a modal window.
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
virtual bool winEvent(MSG *message, long *result)
This special event handler can be reimplemented in a subclass to receive native Windows events which ...
Definition: qwidget.cpp:9941
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
static QInputContext * inputContext
#define APPCOMMAND_TREBLE_UP
#define XBUTTON2
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
BOOL(WINAPI * PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
bool processEvents(QEventLoop::ProcessEventsFlags flags)
Processes pending events that match flags until there are no more events to process.
unsigned short ushort
Definition: qglobal.h:995
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
BOOL(WINAPI * PtrGetGestureInfo)(HANDLE, PVOID)
static void changeKeyboard()
Definition: qkeymapper.cpp:90
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
BOOL(API * PtrWTClose)(HCTX)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
static bool animate_toolbox
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
static PtrWTInfo ptrWTInfo
PtrCloseGestureInfoHandle CloseGestureInfoHandle
static void initialize()
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
#define GET_APPCOMMAND_LPARAM(lParam)
static void qt_win_read_cleartype_settings()
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void setWheelScrollLines(int)
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
virtual QString text(Text t, int child) const =0
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
int maximumHeight() const
static const QMetaObjectPrivate * priv(const uint *data)
QString objectName() const
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static HFONT systemFont()
#define SEM_NOOPENFILEERRORBOX
#define MK_XBUTTON2
Definition: qnamespace.h:54
#define GID_PAN
QTLWExtra * maybeTopData()
void qt_cleanup()
static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
bool translateTouchEvent(const MSG &msg)
static bool replayPopupMouseEvent
bool translatePaintEvent(const MSG &msg)
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
QHash< quint64, QTabletDeviceData > QTabletCursorInfo
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
#define GN_CONTEXTMENU
static void setSystemPalette(const QPalette &pal)
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
quint16 index
static PtrWTOverlap ptrWTOverlap
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...
static bool sendKeyEvent(QWidget *widget, bool grab, QEvent::Type type, int code, Qt::KeyboardModifiers modifiers, const QString &text, bool autorepeat, int count, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, bool *unusedExceptForCocoa=0)
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
Q_GUI_EXPORT const QString qt_getRegisteredWndClass()
Q_CORE_EXPORT HINSTANCE qWinAppInst()
static void cleanup()
Definition: qcursor.cpp:402
qint32 minh
Definition: qwidget_p.h:265
BOOL(WINAPI * PtrSetProcessDPIAware)(VOID)
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
static void initialize()
Definition: qcursor.cpp:417
bool translateMouseEvent(const QWSMouseEvent *, int oldstate)
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
The QClipboardEvent class provides the parameters used in a clipboard event.
Definition: qevent.h:695
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
static PtrSetProcessDPIAware ptrSetProcessDPIAware
void qt_win_initialize_directdraw()
API
Definition: qegl_p.h:190
bool qt_is_gui_used
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
#define WM_APPCOMMAND
bool qt_tablet_tilt_support
#define Q_WS_WINCE
Definition: qglobal.h:895
static void setDoubleClickInterval(int)
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
#define SPI_GETUIEFFECTS
Definition: qt_windows.h:104
#define GET_Y_LPARAM(lp)
#define WM_XBUTTONDBLCLK
struct tagTOUCHINPUT * PTOUCHINPUT
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static void qt_set_windows_resources()
#define SHRG_NOANIMATION
#define RETURN(x)
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
#define TOUCHEVENTF_PRIMARY
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
#define TOUCHINPUTMASKF_CONTACTAREA
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
void repolishStyle(QStyle &style)
#define SPI_GETFONTSMOOTHINGTYPE
#define GID_ZOOM
QWidgetBackingStoreTracker backingStore
Definition: qwidget_p.h:166
static bool appNoGrab
QWidgetData * dataPtr()
#define GET_KEYSTATE_LPARAM(lParam)
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
bool qt_wince_is_high_dpi()
const QRect & geometry() const
QSessionManager * qt_session_manager_self
static void leaveModal_sys(QWidget *)
static void setFont(const QFont &, const char *className=0)
Changes the default application font to font.
static void alert_widget(QWidget *widget, int duration)
static QPointer< QWidget > popupButtonFocus
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
#define SPI_SETSIPINFO
static bool sm_blockUserInput
static void winMouseButtonUp()
Orientation
Definition: qnamespace.h:174
QRect frameStrut() const
void moveCenter(const QPointF &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.h:705
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true)
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom)
Definition: qregion_win.cpp:55
int minimumWidth() const
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
static int doubleClickInterval()
static void setPalette(const QPalette &)
Sets the palette used to render tooltips.
Definition: qtooltip.cpp:586
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
BOOL(WINAPI * PtrUpdateLayeredWindowIndirect)(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *pULWInfo)
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
void winFocus(QWidget *, bool)
#define GID_TWOFINGERTAP
BOOL(API * PtrWTGet)(HCTX, LPLOGCONTEXT)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
IAccessible * qt_createWindowsAccessible(QAccessibleInterface *object)
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
PtrGetGestureConfig GetGestureConfig
static int inputcharset
void cancel()
Tells the session manager to cancel the shutdown process.
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static int translateButtonState(int s, int type, int button)
static bool effect_override
#define INT_MAX
static void qt_set_windows_updateScrollBar(QWidget *widget)
#define APPCOMMAND_BASS_BOOST
bool translateConfigEvent(const MSG &msg)
PtrUpdateLayeredWindow ptrUpdateLayeredWindow
PtrBeginPanningFeedback BeginPanningFeedback
#define enabled
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
Enables the UI effect effect if enable is true, otherwise the effect will not be used.
#define SPI_GETTOOLTIPANIMATION
Definition: qt_windows.h:98
static void enterWhatsThisMode()
This function switches the user interface into "What&#39;s This?" mode.
Definition: qwhatsthis.cpp:633
static void cleanup()
void openPopup(QWidget *popup)
QWidget * qt_button_down
static bool animate_menu
static void qt_set_windows_color_resources()
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
Handle handle() const
Returns a platform-specific region handle.
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
#define text
Definition: qobjectdefs.h:80
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
#define WM_ACTIVATEAPP
#define WM_MOUSELEAVE
#define SW_PARENTCLOSING
#define WM_XBUTTONDOWN
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
static int area(const QSize &s)
Definition: qicon.cpp:155
bool translateCloseEvent(const MSG &msg)
bool qt_tabletChokeMouse
static int cursor_flash_time
QColor light(int f=150) const
Use lighter(factor) instead.
Definition: qcolor.cpp:2391
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
#define CS_DROPSHADOW
Definition: qt_windows.h:136
void qErrnoWarning(const char *msg,...)
Definition: qglobal.cpp:2954
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
MouseButton
Definition: qnamespace.h:150
int maximumWidth() const
static const qreal Q_PI
Definition: qmath_p.h:61
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
static bool aygResolved