|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: sw=2 ts=2 et : |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #ifndef IPC_GLUE_WINDOWSMESSAGELOOP_H |
|
9 #define IPC_GLUE_WINDOWSMESSAGELOOP_H |
|
10 |
|
11 // This file is only meant to compile on windows |
|
12 #include <windows.h> |
|
13 |
|
14 #include "base/basictypes.h" |
|
15 #include "nsISupportsImpl.h" |
|
16 |
|
17 namespace mozilla { |
|
18 namespace ipc { |
|
19 namespace windows { |
|
20 |
|
21 void InitUIThread(); |
|
22 |
|
23 class DeferredMessage |
|
24 { |
|
25 public: |
|
26 DeferredMessage() |
|
27 { |
|
28 MOZ_COUNT_CTOR(DeferredMessage); |
|
29 } |
|
30 |
|
31 virtual ~DeferredMessage() |
|
32 { |
|
33 MOZ_COUNT_DTOR(DeferredMessage); |
|
34 } |
|
35 |
|
36 virtual void Run() = 0; |
|
37 }; |
|
38 |
|
39 // Uses CallWndProc to deliver a message at a later time. Messages faked with |
|
40 // this class must not have pointers in their wParam or lParam members as they |
|
41 // may be invalid by the time the message actually runs. |
|
42 class DeferredSendMessage : public DeferredMessage |
|
43 { |
|
44 public: |
|
45 DeferredSendMessage(HWND aHWnd, |
|
46 UINT aMessage, |
|
47 WPARAM aWParam, |
|
48 LPARAM aLParam) |
|
49 : hWnd(aHWnd), |
|
50 message(aMessage), |
|
51 wParam(aWParam), |
|
52 lParam(aLParam) |
|
53 { } |
|
54 |
|
55 virtual void Run(); |
|
56 |
|
57 protected: |
|
58 HWND hWnd; |
|
59 UINT message; |
|
60 WPARAM wParam; |
|
61 LPARAM lParam; |
|
62 }; |
|
63 |
|
64 // Uses RedrawWindow to fake several painting-related messages. Flags passed |
|
65 // to the constructor go directly to RedrawWindow. |
|
66 class DeferredRedrawMessage : public DeferredMessage |
|
67 { |
|
68 public: |
|
69 DeferredRedrawMessage(HWND aHWnd, |
|
70 UINT aFlags) |
|
71 : hWnd(aHWnd), |
|
72 flags(aFlags) |
|
73 { } |
|
74 |
|
75 virtual void Run(); |
|
76 |
|
77 private: |
|
78 HWND hWnd; |
|
79 UINT flags; |
|
80 }; |
|
81 |
|
82 // Uses UpdateWindow to generate a WM_PAINT message if needed. |
|
83 class DeferredUpdateMessage : public DeferredMessage |
|
84 { |
|
85 public: |
|
86 DeferredUpdateMessage(HWND aHWnd); |
|
87 |
|
88 virtual void Run(); |
|
89 |
|
90 private: |
|
91 HWND mWnd; |
|
92 RECT mUpdateRect; |
|
93 }; |
|
94 |
|
95 // This class duplicates a string that may exist in the lParam member of the |
|
96 // message. |
|
97 class DeferredSettingChangeMessage : public DeferredSendMessage |
|
98 { |
|
99 public: |
|
100 DeferredSettingChangeMessage(HWND aHWnd, |
|
101 UINT aMessage, |
|
102 WPARAM aWParam, |
|
103 LPARAM aLParam); |
|
104 |
|
105 ~DeferredSettingChangeMessage(); |
|
106 private: |
|
107 wchar_t* lParamString; |
|
108 }; |
|
109 |
|
110 // This class uses SetWindowPos to fake various size-related messages. Flags |
|
111 // passed to the constructor go straight through to SetWindowPos. |
|
112 class DeferredWindowPosMessage : public DeferredMessage |
|
113 { |
|
114 public: |
|
115 DeferredWindowPosMessage(HWND aHWnd, |
|
116 LPARAM aLParam, |
|
117 bool aForCalcSize = false, |
|
118 WPARAM aWParam = 0); |
|
119 |
|
120 virtual void Run(); |
|
121 |
|
122 private: |
|
123 WINDOWPOS windowPos; |
|
124 }; |
|
125 |
|
126 // This class duplicates a data buffer for a WM_COPYDATA message. |
|
127 class DeferredCopyDataMessage : public DeferredSendMessage |
|
128 { |
|
129 public: |
|
130 DeferredCopyDataMessage(HWND aHWnd, |
|
131 UINT aMessage, |
|
132 WPARAM aWParam, |
|
133 LPARAM aLParam); |
|
134 |
|
135 ~DeferredCopyDataMessage(); |
|
136 private: |
|
137 COPYDATASTRUCT copyData; |
|
138 }; |
|
139 |
|
140 class DeferredStyleChangeMessage : public DeferredMessage |
|
141 { |
|
142 public: |
|
143 DeferredStyleChangeMessage(HWND aHWnd, |
|
144 WPARAM aWParam, |
|
145 LPARAM aLParam); |
|
146 |
|
147 virtual void Run(); |
|
148 |
|
149 private: |
|
150 HWND hWnd; |
|
151 int index; |
|
152 LONG_PTR style; |
|
153 }; |
|
154 |
|
155 class DeferredSetIconMessage : public DeferredSendMessage |
|
156 { |
|
157 public: |
|
158 DeferredSetIconMessage(HWND aHWnd, |
|
159 UINT aMessage, |
|
160 WPARAM aWParam, |
|
161 LPARAM aLParam); |
|
162 |
|
163 virtual void Run(); |
|
164 }; |
|
165 |
|
166 } /* namespace windows */ |
|
167 } /* namespace ipc */ |
|
168 } /* namespace mozilla */ |
|
169 |
|
170 #endif /* IPC_GLUE_WINDOWSMESSAGELOOP_H */ |