Windows QScreen: handle change in working area when the taskbar moves
[profile/ivi/qtbase.git] / src / plugins / platforms / windows / qtwindowsglobal.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins 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 #ifndef QTWINDOWSGLOBAL_H
43 #define QTWINDOWSGLOBAL_H
44
45 #include "qtwindows_additional.h"
46 #include <QtCore/qnamespace.h>
47 #ifdef Q_OS_WINCE
48 #  include "qplatformfunctions_wince.h"
49 #endif
50
51 QT_BEGIN_NAMESPACE
52
53 namespace QtWindows
54 {
55
56 enum
57 {
58     WindowEventFlag = 0x10000,
59     MouseEventFlag = 0x20000,
60     NonClientEventFlag = 0x40000,
61     InputMethodEventFlag = 0x80000,
62     KeyEventFlag = 0x100000,
63     KeyDownEventFlag = 0x200000,
64     TouchEventFlag = 0x400000,
65     ClipboardEventFlag = 0x800000,
66     ApplicationEventFlag = 0x1000000,
67     ThemingEventFlag = 0x2000000
68 };
69
70 enum WindowsEventType // Simplify event types
71 {
72     ExposeEvent = WindowEventFlag + 1,
73     ActivateWindowEvent = WindowEventFlag + 2,
74     DeactivateWindowEvent = WindowEventFlag + 3,
75     LeaveEvent = WindowEventFlag + 5,
76     CloseEvent = WindowEventFlag + 6,
77     ShowEvent = WindowEventFlag + 7,
78     HideEvent = WindowEventFlag + 8,
79     DestroyEvent = WindowEventFlag + 9,
80     MoveEvent = WindowEventFlag + 10,
81     ResizeEvent = WindowEventFlag + 12,
82     QuerySizeHints = WindowEventFlag + 15,
83     CalculateSize = WindowEventFlag + 16,
84     FocusInEvent = WindowEventFlag + 17,
85     FocusOutEvent = WindowEventFlag + 18,
86     MouseEvent = MouseEventFlag + 1,
87     MouseWheelEvent = MouseEventFlag + 2,
88     CursorEvent = MouseEventFlag + 3,
89     TouchEvent = TouchEventFlag + 1,
90     NonClientMouseEvent = NonClientEventFlag + MouseEventFlag + 1,
91     KeyEvent = KeyEventFlag + 1,
92     KeyDownEvent = KeyEventFlag + KeyDownEventFlag + 1,
93     InputMethodKeyEvent = InputMethodEventFlag + KeyEventFlag + 1,
94     InputMethodKeyDownEvent = InputMethodEventFlag + KeyEventFlag + KeyDownEventFlag + 1,
95     ClipboardEvent = ClipboardEventFlag + 1,
96     ActivateApplicationEvent = ApplicationEventFlag + 1,
97     DeactivateApplicationEvent = ApplicationEventFlag + 2,
98     AccessibleObjectFromWindowRequest = ApplicationEventFlag + 3,
99     InputMethodStartCompositionEvent = InputMethodEventFlag + 1,
100     InputMethodCompositionEvent = InputMethodEventFlag + 2,
101     InputMethodEndCompositionEvent = InputMethodEventFlag + 3,
102     InputMethodOpenCandidateWindowEvent = InputMethodEventFlag + 4,
103     InputMethodCloseCandidateWindowEvent = InputMethodEventFlag + 5,
104     InputMethodRequest = InputMethodEventFlag + 6,
105     ThemeChanged = ThemingEventFlag + 1,
106     DisplayChangedEvent = 437,
107     SettingChangedEvent = DisplayChangedEvent + 1,
108     UnknownEvent = 542
109 };
110
111 } // namespace QtWindows
112
113 inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamIn)
114 {
115     switch (message) {
116     case WM_PAINT:
117     case WM_ERASEBKGND:
118         return QtWindows::ExposeEvent;
119     case WM_CLOSE:
120         return QtWindows::CloseEvent;
121     case WM_DESTROY:
122         return QtWindows::DestroyEvent;
123     case WM_ACTIVATEAPP:
124         return (int)wParamIn ?
125         QtWindows::ActivateApplicationEvent : QtWindows::DeactivateApplicationEvent;
126     case WM_ACTIVATE:
127         return  LOWORD(wParamIn) == WA_INACTIVE ?
128             QtWindows::DeactivateWindowEvent : QtWindows::ActivateWindowEvent;
129     case WM_SETCURSOR:
130         return QtWindows::CursorEvent;
131     case WM_MOUSELEAVE:
132         return QtWindows::MouseEvent;
133     case WM_MOUSEWHEEL:
134     case WM_MOUSEHWHEEL:
135         return QtWindows::MouseWheelEvent;
136     case WM_MOVE:
137         return QtWindows::MoveEvent;
138     case WM_SHOWWINDOW:
139         return wParamIn ? QtWindows::ShowEvent : QtWindows::HideEvent;
140     case WM_SIZE:
141         return QtWindows::ResizeEvent;
142     case WM_NCCALCSIZE:
143         return QtWindows::CalculateSize;
144     case WM_GETMINMAXINFO:
145         return QtWindows::QuerySizeHints;
146     case WM_KEYDOWN:                        // keyboard event
147     case WM_SYSKEYDOWN:
148         return QtWindows::KeyDownEvent;
149     case WM_KEYUP:
150     case WM_SYSKEYUP:
151     case WM_CHAR:
152         return QtWindows::KeyEvent;
153     case WM_IME_CHAR:
154         return QtWindows::InputMethodKeyEvent;
155     case WM_IME_KEYDOWN:
156         return QtWindows::InputMethodKeyDownEvent;
157     case WM_TOUCH:
158         return QtWindows::TouchEvent;
159     case WM_CHANGECBCHAIN:
160     case WM_DRAWCLIPBOARD:
161     case WM_RENDERFORMAT:
162     case WM_RENDERALLFORMATS:
163     case WM_DESTROYCLIPBOARD:
164         return QtWindows::ClipboardEvent;
165     case WM_IME_STARTCOMPOSITION:
166         return QtWindows::InputMethodStartCompositionEvent;
167     case WM_IME_ENDCOMPOSITION:
168         return QtWindows::InputMethodEndCompositionEvent;
169     case WM_IME_COMPOSITION:
170         return QtWindows::InputMethodCompositionEvent;
171     case WM_IME_REQUEST:
172         return QtWindows::InputMethodRequest;
173     case WM_IME_NOTIFY:
174          switch (int(wParamIn)) {
175          case IMN_OPENCANDIDATE:
176              return QtWindows::InputMethodOpenCandidateWindowEvent;
177          case IMN_CLOSECANDIDATE:
178              return QtWindows::InputMethodCloseCandidateWindowEvent;
179          default:
180              break;
181          }
182     case WM_GETOBJECT:
183         return QtWindows::AccessibleObjectFromWindowRequest;
184     case WM_SETFOCUS:
185         return QtWindows::FocusInEvent;
186     case WM_KILLFOCUS:
187         return QtWindows::FocusOutEvent;
188     // Among other things, WM_SETTINGCHANGE happens when the taskbar is moved
189     // and therefore the "working area" changes.
190     // http://msdn.microsoft.com/en-us/library/ms695534(v=vs.85).aspx
191     case WM_SETTINGCHANGE:
192         return QtWindows::SettingChangedEvent;
193     case WM_DISPLAYCHANGE:
194         return QtWindows::DisplayChangedEvent;
195     case WM_THEMECHANGED:
196         return QtWindows::ThemeChanged;
197     default:
198         break;
199     }
200     if (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK)
201         return QtWindows::NonClientMouseEvent; //
202     if ((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST)
203          || (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK))
204         return QtWindows::MouseEvent;
205     return QtWindows::UnknownEvent;
206 }
207
208 QT_END_NAMESPACE
209
210 #endif // QTWINDOWSGLOBAL_H