Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1048)

Side by Side Diff: ui/views/widget/hwnd_message_handler.cc

Issue 10828397: Revert 152374 - Move more message handlers from NativeWidgetWin to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/hwnd_message_handler.h ('k') | ui/views/widget/hwnd_message_handler_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/hwnd_message_handler.h" 5 #include "ui/views/widget/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h>
8
9 #include "base/system_monitor/system_monitor.h" 7 #include "base/system_monitor/system_monitor.h"
10 #include "ui/gfx/path.h"
11 #include "ui/base/native_theme/native_theme_win.h" 8 #include "ui/base/native_theme/native_theme_win.h"
12 #include "ui/views/ime/input_method_win.h" 9 #include "ui/views/ime/input_method_win.h"
13 #include "ui/views/widget/hwnd_message_handler_delegate.h" 10 #include "ui/views/widget/hwnd_message_handler_delegate.h"
14 #include "ui/views/widget/native_widget_win.h" 11 #include "ui/views/widget/native_widget_win.h"
15 12
16 namespace views { 13 namespace views {
17 14
18 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
19 // HWNDMessageHandler, public: 16 // HWNDMessageHandler, public:
20 17
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return 0; 125 return 0;
129 } 126 }
130 127
131 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method); 128 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method);
132 BOOL handled = FALSE; 129 BOOL handled = FALSE;
133 LRESULT result = ime_win->OnImeMessages(message, w_param, l_param, &handled); 130 LRESULT result = ime_win->OnImeMessages(message, w_param, l_param, &handled);
134 SetMsgHandled(handled); 131 SetMsgHandled(handled);
135 return result; 132 return result;
136 } 133 }
137 134
138 void HWNDMessageHandler::OnInitMenu(HMENU menu) {
139 bool is_fullscreen = delegate_->AsNativeWidgetWin()->IsFullscreen();
140 bool is_minimized = delegate_->AsNativeWidgetWin()->IsMinimized();
141 bool is_maximized = delegate_->AsNativeWidgetWin()->IsMaximized();
142 bool is_restored = !is_fullscreen && !is_minimized && !is_maximized;
143
144 EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized);
145 EnableMenuItem(menu, SC_MOVE, is_restored);
146 EnableMenuItem(menu, SC_SIZE, delegate_->CanResize() && is_restored);
147 EnableMenuItem(menu, SC_MAXIMIZE, delegate_->CanMaximize() &&
148 !is_fullscreen && !is_maximized);
149 EnableMenuItem(menu, SC_MINIMIZE, delegate_->CanMaximize() && !is_minimized);
150 }
151
152 void HWNDMessageHandler::OnInitMenuPopup() {
153 SetMsgHandled(FALSE);
154 }
155
156 void HWNDMessageHandler::OnInputLangChange(DWORD character_set, 135 void HWNDMessageHandler::OnInputLangChange(DWORD character_set,
157 HKL input_language_id) { 136 HKL input_language_id) {
158 InputMethod* input_method = delegate_->GetInputMethod(); 137 InputMethod* input_method = delegate_->GetInputMethod();
159 if (input_method && !input_method->IsMock()) { 138 if (input_method && !input_method->IsMock()) {
160 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( 139 static_cast<InputMethodWin*>(input_method)->OnInputLangChange(
161 character_set, input_language_id); 140 character_set, input_language_id);
162 } 141 }
163 } 142 }
164 143
165 LRESULT HWNDMessageHandler::OnKeyEvent(UINT message,
166 WPARAM w_param,
167 LPARAM l_param) {
168 MSG msg = { hwnd(), message, w_param, l_param };
169 ui::KeyEvent key(msg, message == WM_CHAR);
170 InputMethod* input_method = delegate_->GetInputMethod();
171 if (input_method)
172 input_method->DispatchKeyEvent(key);
173 else
174 delegate_->AsNativeWidgetWin()->DispatchKeyEventPostIME(key);
175 return 0;
176 }
177
178 void HWNDMessageHandler::OnKillFocus(HWND focused_window) {
179 delegate_->HandleNativeBlur(focused_window);
180
181 InputMethod* input_method = delegate_->GetInputMethod();
182 if (input_method)
183 input_method->OnBlur();
184 SetMsgHandled(FALSE);
185 }
186
187 void HWNDMessageHandler::OnMove(const CPoint& point) { 144 void HWNDMessageHandler::OnMove(const CPoint& point) {
188 delegate_->HandleMove(); 145 delegate_->HandleMove();
189 SetMsgHandled(FALSE); 146 SetMsgHandled(FALSE);
190 } 147 }
191 148
192 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) { 149 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) {
193 delegate_->HandleMove(); 150 delegate_->HandleMove();
194 } 151 }
195 152
196 LRESULT HWNDMessageHandler::OnNCHitTest(const CPoint& point) {
197 if (!delegate_->IsWidgetWindow()) {
198 SetMsgHandled(FALSE);
199 return 0;
200 }
201
202 // If the DWM is rendering the window controls, we need to give the DWM's
203 // default window procedure first chance to handle hit testing.
204 if (!remove_standard_frame_ && !delegate_->IsUsingCustomFrame()) {
205 LRESULT result;
206 if (DwmDefWindowProc(hwnd(), WM_NCHITTEST, 0,
207 MAKELPARAM(point.x, point.y), &result)) {
208 return result;
209 }
210 }
211
212 // First, give the NonClientView a chance to test the point to see if it
213 // provides any of the non-client area.
214 POINT temp = point;
215 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1);
216 int component = delegate_->GetNonClientComponent(gfx::Point(temp));
217 if (component != HTNOWHERE)
218 return component;
219
220 // Otherwise, we let Windows do all the native frame non-client handling for
221 // us.
222 SetMsgHandled(FALSE);
223 return 0;
224 }
225
226 LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message, 153 LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message,
227 WPARAM w_param, 154 WPARAM w_param,
228 LPARAM l_param) { 155 LPARAM l_param) {
229 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for 156 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
230 // an explanation about why we need to handle this message. 157 // an explanation about why we need to handle this message.
231 SetMsgHandled(delegate_->IsUsingCustomFrame()); 158 SetMsgHandled(delegate_->IsUsingCustomFrame());
232 return 0; 159 return 0;
233 } 160 }
234 161
235 LRESULT HWNDMessageHandler::OnNCUAHDrawFrame(UINT message, 162 LRESULT HWNDMessageHandler::OnNCUAHDrawFrame(UINT message,
236 WPARAM w_param, 163 WPARAM w_param,
237 LPARAM l_param) { 164 LPARAM l_param) {
238 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for 165 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
239 // an explanation about why we need to handle this message. 166 // an explanation about why we need to handle this message.
240 SetMsgHandled(delegate_->IsUsingCustomFrame()); 167 SetMsgHandled(delegate_->IsUsingCustomFrame());
241 return 0; 168 return 0;
242 } 169 }
243 170
244 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { 171 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
245 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 172 base::SystemMonitor* monitor = base::SystemMonitor::Get();
246 if (monitor) 173 if (monitor)
247 monitor->ProcessWmPowerBroadcastMessage(power_event); 174 monitor->ProcessWmPowerBroadcastMessage(power_event);
248 SetMsgHandled(FALSE); 175 SetMsgHandled(FALSE);
249 return 0; 176 return 0;
250 } 177 }
251 178
252 LRESULT HWNDMessageHandler::OnSetCursor(UINT message,
253 WPARAM w_param,
254 LPARAM l_param) {
255 // Using ScopedRedrawLock here frequently allows content behind this window to
256 // paint in front of this window, causing glaring rendering artifacts.
257 // If omitting ScopedRedrawLock here triggers caption rendering artifacts via
258 // DefWindowProc message handling, we'll need to find a better solution.
259 SetMsgHandled(FALSE);
260 return 0;
261 }
262
263 void HWNDMessageHandler::OnSetFocus(HWND last_focused_window) {
264 delegate_->HandleNativeFocus(last_focused_window);
265 InputMethod* input_method = delegate_->GetInputMethod();
266 if (input_method)
267 input_method->OnFocus();
268 SetMsgHandled(FALSE);
269 }
270
271 LRESULT HWNDMessageHandler::OnSetIcon(UINT size_type, HICON new_icon) {
272 // Use a ScopedRedrawLock to avoid weird non-client painting.
273 return DefWindowProcWithRedrawLock(WM_SETICON, size_type,
274 reinterpret_cast<LPARAM>(new_icon));
275 }
276
277 LRESULT HWNDMessageHandler::OnSetText(const wchar_t* text) {
278 // Use a ScopedRedrawLock to avoid weird non-client painting.
279 return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL,
280 reinterpret_cast<LPARAM>(text));
281 }
282
283 void HWNDMessageHandler::OnSize(UINT param, const CSize& size) { 179 void HWNDMessageHandler::OnSize(UINT param, const CSize& size) {
284 RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); 180 RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
285 // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've 181 // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
286 // invoked OnSize we ensure the RootView has been laid out. 182 // invoked OnSize we ensure the RootView has been laid out.
287 ResetWindowRegion(false); 183 ResetWindowRegion(false);
288 } 184 }
289 185
290 void HWNDMessageHandler::OnThemeChanged() { 186 void HWNDMessageHandler::OnThemeChanged() {
291 ui::NativeThemeWin::instance()->CloseHandles(); 187 ui::NativeThemeWin::instance()->CloseHandles();
292 } 188 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 w_param, 249 w_param,
354 l_param); 250 l_param);
355 } 251 }
356 252
357 void HWNDMessageHandler::SetMsgHandled(BOOL handled) { 253 void HWNDMessageHandler::SetMsgHandled(BOOL handled) {
358 delegate_->AsNativeWidgetWin()->SetMsgHandled(handled); 254 delegate_->AsNativeWidgetWin()->SetMsgHandled(handled);
359 } 255 }
360 256
361 } // namespace views 257 } // namespace views
362 258
OLDNEW
« no previous file with comments | « ui/views/widget/hwnd_message_handler.h ('k') | ui/views/widget/hwnd_message_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698