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

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

Issue 10828398: Revert 152388 - Revert 152374 - Move more message handlers from NativeWidgetWin to HWNDMessageHandl… (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
7 #include "base/system_monitor/system_monitor.h" 9 #include "base/system_monitor/system_monitor.h"
10 #include "ui/gfx/path.h"
8 #include "ui/base/native_theme/native_theme_win.h" 11 #include "ui/base/native_theme/native_theme_win.h"
9 #include "ui/views/ime/input_method_win.h" 12 #include "ui/views/ime/input_method_win.h"
10 #include "ui/views/widget/hwnd_message_handler_delegate.h" 13 #include "ui/views/widget/hwnd_message_handler_delegate.h"
11 #include "ui/views/widget/native_widget_win.h" 14 #include "ui/views/widget/native_widget_win.h"
12 15
13 namespace views { 16 namespace views {
14 17
15 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
16 // HWNDMessageHandler, public: 19 // HWNDMessageHandler, public:
17 20
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return 0; 128 return 0;
126 } 129 }
127 130
128 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method); 131 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method);
129 BOOL handled = FALSE; 132 BOOL handled = FALSE;
130 LRESULT result = ime_win->OnImeMessages(message, w_param, l_param, &handled); 133 LRESULT result = ime_win->OnImeMessages(message, w_param, l_param, &handled);
131 SetMsgHandled(handled); 134 SetMsgHandled(handled);
132 return result; 135 return result;
133 } 136 }
134 137
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
135 void HWNDMessageHandler::OnInputLangChange(DWORD character_set, 156 void HWNDMessageHandler::OnInputLangChange(DWORD character_set,
136 HKL input_language_id) { 157 HKL input_language_id) {
137 InputMethod* input_method = delegate_->GetInputMethod(); 158 InputMethod* input_method = delegate_->GetInputMethod();
138 if (input_method && !input_method->IsMock()) { 159 if (input_method && !input_method->IsMock()) {
139 static_cast<InputMethodWin*>(input_method)->OnInputLangChange( 160 static_cast<InputMethodWin*>(input_method)->OnInputLangChange(
140 character_set, input_language_id); 161 character_set, input_language_id);
141 } 162 }
142 } 163 }
143 164
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
144 void HWNDMessageHandler::OnMove(const CPoint& point) { 187 void HWNDMessageHandler::OnMove(const CPoint& point) {
145 delegate_->HandleMove(); 188 delegate_->HandleMove();
146 SetMsgHandled(FALSE); 189 SetMsgHandled(FALSE);
147 } 190 }
148 191
149 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) { 192 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) {
150 delegate_->HandleMove(); 193 delegate_->HandleMove();
151 } 194 }
152 195
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
153 LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message, 226 LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message,
154 WPARAM w_param, 227 WPARAM w_param,
155 LPARAM l_param) { 228 LPARAM l_param) {
156 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for 229 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
157 // an explanation about why we need to handle this message. 230 // an explanation about why we need to handle this message.
158 SetMsgHandled(delegate_->IsUsingCustomFrame()); 231 SetMsgHandled(delegate_->IsUsingCustomFrame());
159 return 0; 232 return 0;
160 } 233 }
161 234
162 LRESULT HWNDMessageHandler::OnNCUAHDrawFrame(UINT message, 235 LRESULT HWNDMessageHandler::OnNCUAHDrawFrame(UINT message,
163 WPARAM w_param, 236 WPARAM w_param,
164 LPARAM l_param) { 237 LPARAM l_param) {
165 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for 238 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
166 // an explanation about why we need to handle this message. 239 // an explanation about why we need to handle this message.
167 SetMsgHandled(delegate_->IsUsingCustomFrame()); 240 SetMsgHandled(delegate_->IsUsingCustomFrame());
168 return 0; 241 return 0;
169 } 242 }
170 243
171 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { 244 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
172 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 245 base::SystemMonitor* monitor = base::SystemMonitor::Get();
173 if (monitor) 246 if (monitor)
174 monitor->ProcessWmPowerBroadcastMessage(power_event); 247 monitor->ProcessWmPowerBroadcastMessage(power_event);
175 SetMsgHandled(FALSE); 248 SetMsgHandled(FALSE);
176 return 0; 249 return 0;
177 } 250 }
178 251
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
179 void HWNDMessageHandler::OnSize(UINT param, const CSize& size) { 283 void HWNDMessageHandler::OnSize(UINT param, const CSize& size) {
180 RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); 284 RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
181 // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've 285 // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
182 // invoked OnSize we ensure the RootView has been laid out. 286 // invoked OnSize we ensure the RootView has been laid out.
183 ResetWindowRegion(false); 287 ResetWindowRegion(false);
184 } 288 }
185 289
186 void HWNDMessageHandler::OnThemeChanged() { 290 void HWNDMessageHandler::OnThemeChanged() {
187 ui::NativeThemeWin::instance()->CloseHandles(); 291 ui::NativeThemeWin::instance()->CloseHandles();
188 } 292 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 w_param, 353 w_param,
250 l_param); 354 l_param);
251 } 355 }
252 356
253 void HWNDMessageHandler::SetMsgHandled(BOOL handled) { 357 void HWNDMessageHandler::SetMsgHandled(BOOL handled) {
254 delegate_->AsNativeWidgetWin()->SetMsgHandled(handled); 358 delegate_->AsNativeWidgetWin()->SetMsgHandled(handled);
255 } 359 }
256 360
257 } // namespace views 361 } // namespace views
258 362
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