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

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

Issue 10918015: Make HWNDMessageHandler build with use_aura==1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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/win/hwnd_message_handler.h ('k') | ui/views/win/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/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/system_monitor/system_monitor.h" 11 #include "base/system_monitor/system_monitor.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "ui/base/event.h" 13 #include "ui/base/event.h"
14 #include "ui/base/keycodes/keyboard_code_conversion_win.h" 14 #include "ui/base/keycodes/keyboard_code_conversion_win.h"
15 #include "ui/base/native_theme/native_theme_win.h" 15 #include "ui/base/native_theme/native_theme_win.h"
16 #include "ui/base/win/hwnd_util.h" 16 #include "ui/base/win/hwnd_util.h"
17 #include "ui/base/win/mouse_wheel_util.h" 17 #include "ui/base/win/mouse_wheel_util.h"
18 #include "ui/base/win/shell.h" 18 #include "ui/base/win/shell.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/canvas_paint.h" 20 #include "ui/gfx/canvas_paint.h"
21 #include "ui/gfx/canvas_skia_paint.h" 21 #include "ui/gfx/canvas_skia_paint.h"
22 #include "ui/gfx/icon_util.h" 22 #include "ui/gfx/icon_util.h"
23 #include "ui/gfx/insets.h" 23 #include "ui/gfx/insets.h"
24 #include "ui/gfx/path.h" 24 #include "ui/gfx/path.h"
25 #include "ui/gfx/screen.h" 25 #include "ui/gfx/screen.h"
26 #include "ui/views/accessibility/native_view_accessibility_win.h"
27 #include "ui/views/ime/input_method_win.h"
28 #include "ui/views/views_delegate.h" 26 #include "ui/views/views_delegate.h"
29 #include "ui/views/widget/child_window_message_processor.h"
30 #include "ui/views/widget/monitor_win.h" 27 #include "ui/views/widget/monitor_win.h"
31 #include "ui/views/widget/native_widget_win.h" 28 #include "ui/views/widget/native_widget_win.h"
32 #include "ui/views/widget/widget_hwnd_utils.h" 29 #include "ui/views/widget/widget_hwnd_utils.h"
33 #include "ui/views/win/fullscreen_handler.h" 30 #include "ui/views/win/fullscreen_handler.h"
34 #include "ui/views/win/hwnd_message_handler_delegate.h" 31 #include "ui/views/win/hwnd_message_handler_delegate.h"
35 #include "ui/views/win/scoped_fullscreen_visibility.h" 32 #include "ui/views/win/scoped_fullscreen_visibility.h"
36 33
37 #if !defined(USE_AURA) 34 #if !defined(USE_AURA)
38 #include "base/command_line.h" 35 #include "ui/views/accessibility/native_view_accessibility_win.h"
39 #include "ui/base/ui_base_switches.h" 36 #include "ui/views/widget/child_window_message_processor.h"
40 #endif 37 #endif
41 38
42 namespace views { 39 namespace views {
43 namespace { 40 namespace {
44 41
45 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a 42 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a
46 // move. win32 doesn't appear to offer a way to determine the result of a move, 43 // move. win32 doesn't appear to offer a way to determine the result of a move,
47 // so we install hooks to determine if we got a mouse up and assume the move 44 // so we install hooks to determine if we got a mouse up and assume the move
48 // completed. 45 // completed.
49 class MoveLoopMouseWatcher { 46 class MoveLoopMouseWatcher {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 *work_area = monitor_info.rcWork; 179 *work_area = monitor_info.rcWork;
183 return true; 180 return true;
184 } 181 }
185 182
186 struct FindOwnedWindowsData { 183 struct FindOwnedWindowsData {
187 HWND window; 184 HWND window;
188 std::vector<Widget*> owned_widgets; 185 std::vector<Widget*> owned_widgets;
189 }; 186 };
190 187
191 BOOL CALLBACK FindOwnedWindowsCallback(HWND hwnd, LPARAM param) { 188 BOOL CALLBACK FindOwnedWindowsCallback(HWND hwnd, LPARAM param) {
189 // TODO(beng): resolve wrt aura.
190 #if !defined(USE_AURA)
192 FindOwnedWindowsData* data = reinterpret_cast<FindOwnedWindowsData*>(param); 191 FindOwnedWindowsData* data = reinterpret_cast<FindOwnedWindowsData*>(param);
193 if (GetWindow(hwnd, GW_OWNER) == data->window) { 192 if (GetWindow(hwnd, GW_OWNER) == data->window) {
194 Widget* widget = Widget::GetWidgetForNativeView(hwnd); 193 Widget* widget = Widget::GetWidgetForNativeView(hwnd);
195 if (widget) 194 if (widget)
196 data->owned_widgets.push_back(widget); 195 data->owned_widgets.push_back(widget);
197 } 196 }
197 #endif
198 return TRUE; 198 return TRUE;
199 } 199 }
200 200
201 // Enables or disables the menu item for the specified command and menu. 201 // Enables or disables the menu item for the specified command and menu.
202 void EnableMenuItemByCommand(HMENU menu, UINT command, bool enabled) { 202 void EnableMenuItemByCommand(HMENU menu, UINT command, bool enabled) {
203 UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED); 203 UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
204 EnableMenuItem(menu, command, flags); 204 EnableMenuItem(menu, command, flags);
205 } 205 }
206 206
207 // Callback used to notify child windows that the top level window received a 207 // Callback used to notify child windows that the top level window received a
(...skipping 24 matching lines...) Expand all
232 GetWindowRect(window, &bounds); 232 GetWindowRect(window, &bounds);
233 ExcludeClipRect(clip_state->dc, 233 ExcludeClipRect(clip_state->dc,
234 bounds.left - clip_state->x, 234 bounds.left - clip_state->x,
235 bounds.top - clip_state->y, 235 bounds.top - clip_state->y,
236 bounds.right - clip_state->x, 236 bounds.right - clip_state->x,
237 bounds.bottom - clip_state->y); 237 bounds.bottom - clip_state->y);
238 } 238 }
239 return TRUE; 239 return TRUE;
240 } 240 }
241 241
242 #if !defined(USE_AURA)
243
242 // Get the source HWND of the specified message. Depending on the message, the 244 // Get the source HWND of the specified message. Depending on the message, the
243 // source HWND is encoded in either the WPARAM or the LPARAM value. 245 // source HWND is encoded in either the WPARAM or the LPARAM value.
244 HWND GetControlHWNDForMessage(UINT message, WPARAM w_param, LPARAM l_param) { 246 HWND GetControlHWNDForMessage(UINT message, WPARAM w_param, LPARAM l_param) {
245 // Each of the following messages can be sent by a child HWND and must be 247 // Each of the following messages can be sent by a child HWND and must be
246 // forwarded to its associated NativeControlWin for handling. 248 // forwarded to its associated NativeControlWin for handling.
247 switch (message) { 249 switch (message) {
248 case WM_NOTIFY: 250 case WM_NOTIFY:
249 return reinterpret_cast<NMHDR*>(l_param)->hwndFrom; 251 return reinterpret_cast<NMHDR*>(l_param)->hwndFrom;
250 case WM_COMMAND: 252 case WM_COMMAND:
251 return reinterpret_cast<HWND>(l_param); 253 return reinterpret_cast<HWND>(l_param);
(...skipping 24 matching lines...) Expand all
276 if (IsWindow(control_hwnd)) { 278 if (IsWindow(control_hwnd)) {
277 ChildWindowMessageProcessor* processor = 279 ChildWindowMessageProcessor* processor =
278 ChildWindowMessageProcessor::Get(control_hwnd); 280 ChildWindowMessageProcessor::Get(control_hwnd);
279 if (processor) 281 if (processor)
280 return processor->ProcessMessage(message, w_param, l_param, l_result); 282 return processor->ProcessMessage(message, w_param, l_param, l_result);
281 } 283 }
282 284
283 return false; 285 return false;
284 } 286 }
285 287
288 #endif
289
286 // A custom MSAA object id used to determine if a screen reader is actively 290 // A custom MSAA object id used to determine if a screen reader is actively
287 // listening for MSAA events. 291 // listening for MSAA events.
288 const int kCustomObjectID = 1; 292 const int kCustomObjectID = 1;
289 293
290 // The thickness of an auto-hide taskbar in pixels. 294 // The thickness of an auto-hide taskbar in pixels.
291 const int kAutoHideTaskbarThicknessPx = 2; 295 const int kAutoHideTaskbarThicknessPx = 2;
292 296
293 } // namespace 297 } // namespace
294 298
295 // A scoping class that prevents a window from being able to redraw in response 299 // A scoping class that prevents a window from being able to redraw in response
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 if (show_state) { 504 if (show_state) {
501 if (wp.showCmd == SW_SHOWMAXIMIZED) 505 if (wp.showCmd == SW_SHOWMAXIMIZED)
502 *show_state = ui::SHOW_STATE_MAXIMIZED; 506 *show_state = ui::SHOW_STATE_MAXIMIZED;
503 else if (wp.showCmd == SW_SHOWMINIMIZED) 507 else if (wp.showCmd == SW_SHOWMINIMIZED)
504 *show_state = ui::SHOW_STATE_MINIMIZED; 508 *show_state = ui::SHOW_STATE_MINIMIZED;
505 else 509 else
506 *show_state = ui::SHOW_STATE_NORMAL; 510 *show_state = ui::SHOW_STATE_NORMAL;
507 } 511 }
508 } 512 }
509 513
510 gfx::Rect HWNDMessageHandler::GetWorkAreaBoundsInScreen() const {
511 return gfx::Screen::GetDisplayNearestWindow(hwnd()).work_area();
512 }
513
514 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds) { 514 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds) {
515 LONG style = GetWindowLong(hwnd(), GWL_STYLE); 515 LONG style = GetWindowLong(hwnd(), GWL_STYLE);
516 if (style & WS_MAXIMIZE) 516 if (style & WS_MAXIMIZE)
517 SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE); 517 SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE);
518 SetWindowPos(hwnd(), NULL, bounds.x(), bounds.y(), bounds.width(), 518 SetWindowPos(hwnd(), NULL, bounds.x(), bounds.y(), bounds.width(),
519 bounds.height(), SWP_NOACTIVATE | SWP_NOZORDER); 519 bounds.height(), SWP_NOACTIVATE | SWP_NOZORDER);
520 } 520 }
521 521
522 void HWNDMessageHandler::SetSize(const gfx::Size& size) { 522 void HWNDMessageHandler::SetSize(const gfx::Size& size) {
523 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), 523 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 } 727 }
728 728
729 void HWNDMessageHandler::SetVisibilityChangedAnimationsEnabled(bool enabled) { 729 void HWNDMessageHandler::SetVisibilityChangedAnimationsEnabled(bool enabled) {
730 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 730 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
731 int dwm_value = enabled ? FALSE : TRUE; 731 int dwm_value = enabled ? FALSE : TRUE;
732 DwmSetWindowAttribute( 732 DwmSetWindowAttribute(
733 hwnd(), DWMWA_TRANSITIONS_FORCEDISABLED, &dwm_value, sizeof(dwm_value)); 733 hwnd(), DWMWA_TRANSITIONS_FORCEDISABLED, &dwm_value, sizeof(dwm_value));
734 } 734 }
735 } 735 }
736 736
737 InputMethod* HWNDMessageHandler::CreateInputMethod() {
738 #if !defined(USE_AURA)
739 CommandLine* command_line = CommandLine::ForCurrentProcess();
740 if (!command_line->HasSwitch(switches::kEnableViewsTextfield))
741 return NULL;
742 #endif
743 return new InputMethodWin(this);
744 }
745
746 void HWNDMessageHandler::SetTitle(const string16& title) { 737 void HWNDMessageHandler::SetTitle(const string16& title) {
747 SetWindowText(hwnd(), title.c_str()); 738 SetWindowText(hwnd(), title.c_str());
748 SetAccessibleName(title); 739 SetAccessibleName(title);
749 } 740 }
750 741
751 void HWNDMessageHandler::SetAccessibleName(const string16& name) { 742 void HWNDMessageHandler::SetAccessibleName(const string16& name) {
743 // TODO(beng): figure out vis-a-vis aura.
744 #if !defined(USE_AURA)
752 base::win::ScopedComPtr<IAccPropServices> pAccPropServices; 745 base::win::ScopedComPtr<IAccPropServices> pAccPropServices;
753 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, 746 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER,
754 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); 747 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
755 if (SUCCEEDED(hr)) 748 if (SUCCEEDED(hr))
756 hr = pAccPropServices->SetHwndPropStr(hwnd(), OBJID_CLIENT, CHILDID_SELF, 749 hr = pAccPropServices->SetHwndPropStr(hwnd(), OBJID_CLIENT, CHILDID_SELF,
757 PROPID_ACC_NAME, name.c_str()); 750 PROPID_ACC_NAME, name.c_str());
751 #endif
758 } 752 }
759 753
760 void HWNDMessageHandler::SetAccessibleRole(ui::AccessibilityTypes::Role role) { 754 void HWNDMessageHandler::SetAccessibleRole(ui::AccessibilityTypes::Role role) {
755 // TODO(beng): figure out vis-a-vis aura.
756 #if !defined(USE_AURA)
761 base::win::ScopedComPtr<IAccPropServices> pAccPropServices; 757 base::win::ScopedComPtr<IAccPropServices> pAccPropServices;
762 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, 758 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER,
763 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); 759 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
764 if (SUCCEEDED(hr)) { 760 if (SUCCEEDED(hr)) {
765 VARIANT var; 761 VARIANT var;
766 if (role) { 762 if (role) {
767 var.vt = VT_I4; 763 var.vt = VT_I4;
768 var.lVal = NativeViewAccessibilityWin::MSAARole(role); 764 var.lVal = NativeViewAccessibilityWin::MSAARole(role);
769 hr = pAccPropServices->SetHwndProp(hwnd(), OBJID_CLIENT, CHILDID_SELF, 765 hr = pAccPropServices->SetHwndProp(hwnd(), OBJID_CLIENT, CHILDID_SELF,
770 PROPID_ACC_ROLE, var); 766 PROPID_ACC_ROLE, var);
771 } 767 }
772 } 768 }
769 #endif
773 } 770 }
774 771
775 void HWNDMessageHandler::SetAccessibleState( 772 void HWNDMessageHandler::SetAccessibleState(
776 ui::AccessibilityTypes::State state) { 773 ui::AccessibilityTypes::State state) {
774 // TODO(beng): figure out vis-a-vis aura.
775 #if !defined(USE_AURA)
777 base::win::ScopedComPtr<IAccPropServices> pAccPropServices; 776 base::win::ScopedComPtr<IAccPropServices> pAccPropServices;
778 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, 777 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER,
779 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); 778 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
780 if (SUCCEEDED(hr)) { 779 if (SUCCEEDED(hr)) {
781 VARIANT var; 780 VARIANT var;
782 if (state) { 781 if (state) {
783 var.vt = VT_I4; 782 var.vt = VT_I4;
784 var.lVal = NativeViewAccessibilityWin::MSAAState(state); 783 var.lVal = NativeViewAccessibilityWin::MSAAState(state);
785 hr = pAccPropServices->SetHwndProp(hwnd(), OBJID_CLIENT, CHILDID_SELF, 784 hr = pAccPropServices->SetHwndProp(hwnd(), OBJID_CLIENT, CHILDID_SELF,
786 PROPID_ACC_STATE, var); 785 PROPID_ACC_STATE, var);
787 } 786 }
788 } 787 }
788 #endif
789 } 789 }
790 790
791 void HWNDMessageHandler::SendNativeAccessibilityEvent( 791 void HWNDMessageHandler::SendNativeAccessibilityEvent(
792 int id, 792 int id,
793 ui::AccessibilityTypes::Event event_type) { 793 ui::AccessibilityTypes::Event event_type) {
794 // TODO(beng): figure out vis-a-vis aura.
795 #if !defined(USE_AURA)
794 // Now call the Windows-specific method to notify MSAA clients of this 796 // Now call the Windows-specific method to notify MSAA clients of this
795 // event. The widget gives us a temporary unique child ID to associate 797 // event. The widget gives us a temporary unique child ID to associate
796 // with this view so that clients can call get_accChild in 798 // with this view so that clients can call get_accChild in
797 // NativeViewAccessibilityWin to retrieve the IAccessible associated 799 // NativeViewAccessibilityWin to retrieve the IAccessible associated
798 // with this view. 800 // with this view.
799 ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type), hwnd(), 801 ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type), hwnd(),
800 OBJID_CLIENT, id); 802 OBJID_CLIENT, id);
803 #endif
801 } 804 }
802 805
803 void HWNDMessageHandler::SetCursor(HCURSOR cursor) { 806 void HWNDMessageHandler::SetCursor(HCURSOR cursor) {
804 if (cursor) { 807 if (cursor) {
805 previous_cursor_ = ::SetCursor(cursor); 808 previous_cursor_ = ::SetCursor(cursor);
806 } else if (previous_cursor_) { 809 } else if (previous_cursor_) {
807 ::SetCursor(previous_cursor_); 810 ::SetCursor(previous_cursor_);
808 previous_cursor_ = NULL; 811 previous_cursor_ = NULL;
809 } 812 }
810 } 813 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 905
903 LRESULT HWNDMessageHandler::OnWndProc(UINT message, 906 LRESULT HWNDMessageHandler::OnWndProc(UINT message,
904 WPARAM w_param, 907 WPARAM w_param,
905 LPARAM l_param) { 908 LPARAM l_param) {
906 HWND window = hwnd(); 909 HWND window = hwnd();
907 LRESULT result = 0; 910 LRESULT result = 0;
908 911
909 if (delegate_->PreHandleMSG(message, w_param, l_param, &result)) 912 if (delegate_->PreHandleMSG(message, w_param, l_param, &result))
910 return result; 913 return result;
911 914
915 #if !defined(USE_AURA)
912 // First allow messages sent by child controls to be processed directly by 916 // First allow messages sent by child controls to be processed directly by
913 // their associated views. If such a view is present, it will handle the 917 // their associated views. If such a view is present, it will handle the
914 // message *instead of* this NativeWidgetWin. 918 // message *instead of* this NativeWidgetWin.
915 if (ProcessChildWindowMessage(message, w_param, l_param, &result)) 919 if (ProcessChildWindowMessage(message, w_param, l_param, &result))
916 return result; 920 return result;
921 #endif
917 922
918 // Otherwise we handle everything else. 923 // Otherwise we handle everything else.
919 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) 924 if (!ProcessWindowMessage(window, message, w_param, l_param, result))
920 result = DefWindowProc(window, message, w_param, l_param); 925 result = DefWindowProc(window, message, w_param, l_param);
921 delegate_->PostHandleMSG(message, w_param, l_param); 926 delegate_->PostHandleMSG(message, w_param, l_param);
922 if (message == WM_NCDESTROY) { 927 if (message == WM_NCDESTROY) {
923 MessageLoopForUI::current()->RemoveObserver(this); 928 MessageLoopForUI::current()->RemoveObserver(this);
924 delegate_->HandleDestroyed(); 929 delegate_->HandleDestroyed();
925 } 930 }
926 931
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 MONITORINFO mi; 1112 MONITORINFO mi;
1108 mi.cbSize = sizeof mi; 1113 mi.cbSize = sizeof mi;
1109 GetMonitorInfo(monitor, &mi); 1114 GetMonitorInfo(monitor, &mi);
1110 CRect work_rect = mi.rcWork; 1115 CRect work_rect = mi.rcWork;
1111 work_rect.OffsetRect(-window_rect.left, -window_rect.top); 1116 work_rect.OffsetRect(-window_rect.left, -window_rect.top);
1112 new_region = CreateRectRgnIndirect(&work_rect); 1117 new_region = CreateRectRgnIndirect(&work_rect);
1113 } else { 1118 } else {
1114 gfx::Path window_mask; 1119 gfx::Path window_mask;
1115 delegate_->GetWindowMask( 1120 delegate_->GetWindowMask(
1116 gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask); 1121 gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask);
1122 // TODO(beng): resolve wrt aura.
1123 #if !defined(USE_AURA)
1117 new_region = window_mask.CreateNativeRegion(); 1124 new_region = window_mask.CreateNativeRegion();
1125 #endif
1118 } 1126 }
1119 1127
1120 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { 1128 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) {
1121 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion. 1129 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion.
1122 SetWindowRgn(hwnd(), new_region, TRUE); 1130 SetWindowRgn(hwnd(), new_region, TRUE);
1123 } else { 1131 } else {
1124 DeleteObject(new_region); 1132 DeleteObject(new_region);
1125 } 1133 }
1126 1134
1127 DeleteObject(current_rgn); 1135 DeleteObject(current_rgn);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 // Return with failure. 1397 // Return with failure.
1390 return static_cast<LRESULT>(0L); 1398 return static_cast<LRESULT>(0L);
1391 } 1399 }
1392 1400
1393 return reference_result; 1401 return reference_result;
1394 } 1402 }
1395 1403
1396 LRESULT HWNDMessageHandler::OnImeMessages(UINT message, 1404 LRESULT HWNDMessageHandler::OnImeMessages(UINT message,
1397 WPARAM w_param, 1405 WPARAM w_param,
1398 LPARAM l_param) { 1406 LPARAM l_param) {
1399 InputMethod* input_method = delegate_->GetInputMethod(); 1407 LRESULT result = 0;
1400 if (!input_method || input_method->IsMock()) { 1408 SetMsgHandled(delegate_->HandleIMEMessage(
1401 SetMsgHandled(FALSE); 1409 message, w_param, l_param, &result));
1402 return 0;
1403 }
1404
1405 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method);
1406 BOOL handled = FALSE;
1407 LRESULT result = ime_win->OnImeMessages(message, w_param, l_param, &handled);
1408 SetMsgHandled(handled);
1409 return result; 1410 return result;
1410 } 1411 }
1411 1412
1412 void HWNDMessageHandler::OnInitMenu(HMENU menu) { 1413 void HWNDMessageHandler::OnInitMenu(HMENU menu) {
1413 bool is_fullscreen = fullscreen_handler_->fullscreen(); 1414 bool is_fullscreen = fullscreen_handler_->fullscreen();
1414 bool is_minimized = IsMinimized(); 1415 bool is_minimized = IsMinimized();
1415 bool is_maximized = IsMaximized(); 1416 bool is_maximized = IsMaximized();
1416 bool is_restored = !is_fullscreen && !is_minimized && !is_maximized; 1417 bool is_restored = !is_fullscreen && !is_minimized && !is_maximized;
1417 1418
1418 ScopedRedrawLock lock(this); 1419 ScopedRedrawLock lock(this);
1419 EnableMenuItemByCommand(menu, SC_RESTORE, is_minimized || is_maximized); 1420 EnableMenuItemByCommand(menu, SC_RESTORE, is_minimized || is_maximized);
1420 EnableMenuItemByCommand(menu, SC_MOVE, is_restored); 1421 EnableMenuItemByCommand(menu, SC_MOVE, is_restored);
1421 EnableMenuItemByCommand(menu, SC_SIZE, delegate_->CanResize() && is_restored); 1422 EnableMenuItemByCommand(menu, SC_SIZE, delegate_->CanResize() && is_restored);
1422 EnableMenuItemByCommand(menu, SC_MAXIMIZE, delegate_->CanMaximize() && 1423 EnableMenuItemByCommand(menu, SC_MAXIMIZE, delegate_->CanMaximize() &&
1423 !is_fullscreen && !is_maximized); 1424 !is_fullscreen && !is_maximized);
1424 EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMaximize() && 1425 EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMaximize() &&
1425 !is_minimized); 1426 !is_minimized);
1426 } 1427 }
1427 1428
1428 void HWNDMessageHandler::OnInputLangChange(DWORD character_set, 1429 void HWNDMessageHandler::OnInputLangChange(DWORD character_set,
1429 HKL input_language_id) { 1430 HKL input_language_id) {
1430 InputMethod* input_method = delegate_->GetInputMethod(); 1431 delegate_->HandleInputLanguageChange(character_set, input_language_id);
1431 if (input_method && !input_method->IsMock()) {
1432 static_cast<InputMethodWin*>(input_method)->OnInputLangChange(
1433 character_set, input_language_id);
1434 }
1435 } 1432 }
1436 1433
1437 LRESULT HWNDMessageHandler::OnKeyEvent(UINT message, 1434 LRESULT HWNDMessageHandler::OnKeyEvent(UINT message,
1438 WPARAM w_param, 1435 WPARAM w_param,
1439 LPARAM l_param) { 1436 LPARAM l_param) {
1437
1440 MSG msg = { hwnd(), message, w_param, l_param }; 1438 MSG msg = { hwnd(), message, w_param, l_param };
1441 ui::KeyEvent key(msg, message == WM_CHAR); 1439 ui::KeyEvent key(msg, message == WM_CHAR);
1442 InputMethod* input_method = delegate_->GetInputMethod(); 1440 if (!delegate_->HandleUntranslatedKeyEvent(key))
1443 if (input_method)
1444 input_method->DispatchKeyEvent(key);
1445 else
1446 DispatchKeyEventPostIME(key); 1441 DispatchKeyEventPostIME(key);
1447 return 0; 1442 return 0;
1448 } 1443 }
1449 1444
1450 void HWNDMessageHandler::OnKillFocus(HWND focused_window) { 1445 void HWNDMessageHandler::OnKillFocus(HWND focused_window) {
1451 delegate_->HandleNativeBlur(focused_window); 1446 delegate_->HandleNativeBlur(focused_window);
1452
1453 InputMethod* input_method = delegate_->GetInputMethod();
1454 if (input_method)
1455 input_method->OnBlur();
1456 SetMsgHandled(FALSE); 1447 SetMsgHandled(FALSE);
1457 } 1448 }
1458 1449
1459 LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, 1450 LRESULT HWNDMessageHandler::OnMouseActivate(UINT message,
1460 WPARAM w_param, 1451 WPARAM w_param,
1461 LPARAM l_param) { 1452 LPARAM l_param) {
1462 // TODO(beng): resolve this with the GetWindowLong() check on the subsequent 1453 // TODO(beng): resolve this with the GetWindowLong() check on the subsequent
1463 // line. 1454 // line.
1464 if (delegate_->IsWidgetWindow()) 1455 if (delegate_->IsWidgetWindow())
1465 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT; 1456 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 } 1823 }
1833 1824
1834 void HWNDMessageHandler::OnPaint(HDC dc) { 1825 void HWNDMessageHandler::OnPaint(HDC dc) {
1835 RECT dirty_rect; 1826 RECT dirty_rect;
1836 // Try to paint accelerated first. 1827 // Try to paint accelerated first.
1837 if (GetUpdateRect(hwnd(), &dirty_rect, FALSE) && 1828 if (GetUpdateRect(hwnd(), &dirty_rect, FALSE) &&
1838 !IsRectEmpty(&dirty_rect)) { 1829 !IsRectEmpty(&dirty_rect)) {
1839 if (delegate_->HandlePaintAccelerated(gfx::Rect(dirty_rect))) { 1830 if (delegate_->HandlePaintAccelerated(gfx::Rect(dirty_rect))) {
1840 ValidateRect(hwnd(), NULL); 1831 ValidateRect(hwnd(), NULL);
1841 } else { 1832 } else {
1833 // TODO(beng): resolve vis-a-vis aura
1834 #if !defined(USE_AURA)
1842 scoped_ptr<gfx::CanvasPaint> canvas( 1835 scoped_ptr<gfx::CanvasPaint> canvas(
1843 gfx::CanvasPaint::CreateCanvasPaint(hwnd())); 1836 gfx::CanvasPaint::CreateCanvasPaint(hwnd()));
1844 delegate_->HandlePaint(canvas->AsCanvas()); 1837 delegate_->HandlePaint(canvas->AsCanvas());
1838 #endif
1845 } 1839 }
1846 } else { 1840 } else {
1847 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. 1841 // TODO(msw): Find a better solution for this crbug.com/93530 workaround.
1848 // Some scenarios otherwise fail to validate minimized app/popup windows. 1842 // Some scenarios otherwise fail to validate minimized app/popup windows.
1849 ValidateRect(hwnd(), NULL); 1843 ValidateRect(hwnd(), NULL);
1850 } 1844 }
1851 } 1845 }
1852 1846
1853 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { 1847 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) {
1854 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 1848 base::SystemMonitor* monitor = base::SystemMonitor::Get();
(...skipping 16 matching lines...) Expand all
1871 // Using ScopedRedrawLock here frequently allows content behind this window to 1865 // Using ScopedRedrawLock here frequently allows content behind this window to
1872 // paint in front of this window, causing glaring rendering artifacts. 1866 // paint in front of this window, causing glaring rendering artifacts.
1873 // If omitting ScopedRedrawLock here triggers caption rendering artifacts via 1867 // If omitting ScopedRedrawLock here triggers caption rendering artifacts via
1874 // DefWindowProc message handling, we'll need to find a better solution. 1868 // DefWindowProc message handling, we'll need to find a better solution.
1875 SetMsgHandled(FALSE); 1869 SetMsgHandled(FALSE);
1876 return 0; 1870 return 0;
1877 } 1871 }
1878 1872
1879 void HWNDMessageHandler::OnSetFocus(HWND last_focused_window) { 1873 void HWNDMessageHandler::OnSetFocus(HWND last_focused_window) {
1880 delegate_->HandleNativeFocus(last_focused_window); 1874 delegate_->HandleNativeFocus(last_focused_window);
1881 InputMethod* input_method = delegate_->GetInputMethod();
1882 if (input_method)
1883 input_method->OnFocus();
1884 SetMsgHandled(FALSE); 1875 SetMsgHandled(FALSE);
1885 } 1876 }
1886 1877
1887 LRESULT HWNDMessageHandler::OnSetIcon(UINT size_type, HICON new_icon) { 1878 LRESULT HWNDMessageHandler::OnSetIcon(UINT size_type, HICON new_icon) {
1888 // Use a ScopedRedrawLock to avoid weird non-client painting. 1879 // Use a ScopedRedrawLock to avoid weird non-client painting.
1889 return DefWindowProcWithRedrawLock(WM_SETICON, size_type, 1880 return DefWindowProcWithRedrawLock(WM_SETICON, size_type,
1890 reinterpret_cast<LPARAM>(new_icon)); 1881 reinterpret_cast<LPARAM>(new_icon));
1891 } 1882 }
1892 1883
1893 LRESULT HWNDMessageHandler::OnSetText(const wchar_t* text) { 1884 LRESULT HWNDMessageHandler::OnSetText(const wchar_t* text) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 } 1956 }
1966 1957
1967 // If the delegate can't handle it, the system implementation will be called. 1958 // If the delegate can't handle it, the system implementation will be called.
1968 if (!delegate_->HandleCommand(notification_code)) { 1959 if (!delegate_->HandleCommand(notification_code)) {
1969 DefWindowProc(hwnd(), WM_SYSCOMMAND, notification_code, 1960 DefWindowProc(hwnd(), WM_SYSCOMMAND, notification_code,
1970 MAKELPARAM(point.x, point.y)); 1961 MAKELPARAM(point.x, point.y));
1971 } 1962 }
1972 } 1963 }
1973 1964
1974 void HWNDMessageHandler::OnThemeChanged() { 1965 void HWNDMessageHandler::OnThemeChanged() {
1966 // TODO(beng): resolve vis-a-vis aura.
1967 #if !defined(USE_AURA)
1975 ui::NativeThemeWin::instance()->CloseHandles(); 1968 ui::NativeThemeWin::instance()->CloseHandles();
1969 #endif
1976 } 1970 }
1977 1971
1978 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, 1972 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
1979 WPARAM w_param, 1973 WPARAM w_param,
1980 LPARAM l_param) { 1974 LPARAM l_param) {
1981 int num_points = LOWORD(w_param); 1975 int num_points = LOWORD(w_param);
1982 scoped_array<TOUCHINPUT> input(new TOUCHINPUT[num_points]); 1976 scoped_array<TOUCHINPUT> input(new TOUCHINPUT[num_points]);
1983 if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(l_param), 1977 if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(l_param),
1984 num_points, input.get(), sizeof(TOUCHINPUT))) { 1978 num_points, input.get(), sizeof(TOUCHINPUT))) {
1985 for (int i = 0; i < num_points; ++i) { 1979 for (int i = 0; i < num_points; ++i) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 DwmExtendFrameIntoClientArea(hwnd(), &m); 2085 DwmExtendFrameIntoClientArea(hwnd(), &m);
2092 } 2086 }
2093 if (window_pos->flags & SWP_SHOWWINDOW) 2087 if (window_pos->flags & SWP_SHOWWINDOW)
2094 delegate_->HandleVisibilityChanged(true); 2088 delegate_->HandleVisibilityChanged(true);
2095 else if (window_pos->flags & SWP_HIDEWINDOW) 2089 else if (window_pos->flags & SWP_HIDEWINDOW)
2096 delegate_->HandleVisibilityChanged(false); 2090 delegate_->HandleVisibilityChanged(false);
2097 SetMsgHandled(FALSE); 2091 SetMsgHandled(FALSE);
2098 } 2092 }
2099 2093
2100 } // namespace views 2094 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698