OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/widget_win.h" | 5 #include "views/widget/widget_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
11 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 11 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
12 #include "ui/base/l10n/l10n_util_win.h" | 12 #include "ui/base/l10n/l10n_util_win.h" |
13 #include "ui/base/system_monitor/system_monitor.h" | 13 #include "ui/base/system_monitor/system_monitor.h" |
14 #include "ui/base/theme_provider.h" | 14 #include "ui/base/theme_provider.h" |
15 #include "ui/base/view_prop.h" | 15 #include "ui/base/view_prop.h" |
16 #include "ui/base/win/hwnd_util.h" | 16 #include "ui/base/win/hwnd_util.h" |
17 #include "ui/gfx/canvas_skia.h" | 17 #include "ui/gfx/canvas_skia.h" |
18 #include "ui/gfx/native_theme_win.h" | 18 #include "ui/gfx/native_theme_win.h" |
19 #include "ui/gfx/path.h" | 19 #include "ui/gfx/path.h" |
20 #include "views/accessibility/view_accessibility.h" | 20 #include "views/accessibility/view_accessibility.h" |
21 #include "views/controls/native_control_win.h" | 21 #include "views/controls/native_control_win.h" |
| 22 #include "views/focus/accelerator_handler.h" |
22 #include "views/focus/focus_util_win.h" | 23 #include "views/focus/focus_util_win.h" |
23 #include "views/views_delegate.h" | 24 #include "views/views_delegate.h" |
24 #include "views/widget/aero_tooltip_manager.h" | 25 #include "views/widget/aero_tooltip_manager.h" |
25 #include "views/widget/child_window_message_processor.h" | 26 #include "views/widget/child_window_message_processor.h" |
26 #include "views/widget/default_theme_provider.h" | 27 #include "views/widget/default_theme_provider.h" |
27 #include "views/widget/drop_target_win.h" | 28 #include "views/widget/drop_target_win.h" |
28 #include "views/widget/root_view.h" | 29 #include "views/widget/root_view.h" |
29 #include "views/widget/widget_delegate.h" | 30 #include "views/widget/widget_delegate.h" |
30 #include "views/widget/widget_utils.h" | 31 #include "views/widget/widget_utils.h" |
31 #include "views/window/window_win.h" | 32 #include "views/window/window_win.h" |
(...skipping 14 matching lines...) Expand all Loading... |
46 } // namespace | 47 } // namespace |
47 | 48 |
48 namespace views { | 49 namespace views { |
49 | 50 |
50 // Property used to link the HWND to its RootView. | 51 // Property used to link the HWND to its RootView. |
51 static const char* const kRootViewWindowProperty = "__ROOT_VIEW__"; | 52 static const char* const kRootViewWindowProperty = "__ROOT_VIEW__"; |
52 | 53 |
53 // Links the HWND to it's Widget (as a Widget, not a WidgetWin). | 54 // Links the HWND to it's Widget (as a Widget, not a WidgetWin). |
54 static const char* const kWidgetKey = "__VIEWS_WIDGET__"; | 55 static const char* const kWidgetKey = "__VIEWS_WIDGET__"; |
55 | 56 |
| 57 // static |
56 bool WidgetWin::screen_reader_active_ = false; | 58 bool WidgetWin::screen_reader_active_ = false; |
57 | 59 |
| 60 // static |
| 61 std::vector<MSG>* WidgetWin::current_messages_ = NULL; |
| 62 |
58 // A custom MSAA object id used to determine if a screen reader is actively | 63 // A custom MSAA object id used to determine if a screen reader is actively |
59 // listening for MSAA events. | 64 // listening for MSAA events. |
60 #define OBJID_CUSTOM 1 | 65 #define OBJID_CUSTOM 1 |
61 | 66 |
62 RootView* GetRootViewForHWND(HWND hwnd) { | 67 RootView* GetRootViewForHWND(HWND hwnd) { |
63 return reinterpret_cast<RootView*>( | 68 return reinterpret_cast<RootView*>( |
64 ViewProp::GetValue(hwnd, kRootViewWindowProperty)); | 69 ViewProp::GetValue(hwnd, kRootViewWindowProperty)); |
65 } | 70 } |
66 | 71 |
67 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 // A views::NativeViewHost may contain the given native view, without it being | 519 // A views::NativeViewHost may contain the given native view, without it being |
515 // an ancestor of hwnd(), so traverse the views::View hierarchy looking for | 520 // an ancestor of hwnd(), so traverse the views::View hierarchy looking for |
516 // such views. | 521 // such views. |
517 return GetRootView()->ContainsNativeView(native_view); | 522 return GetRootView()->ContainsNativeView(native_view); |
518 } | 523 } |
519 | 524 |
520 //////////////////////////////////////////////////////////////////////////////// | 525 //////////////////////////////////////////////////////////////////////////////// |
521 // MessageLoop::Observer | 526 // MessageLoop::Observer |
522 | 527 |
523 void WidgetWin::WillProcessMessage(const MSG& msg) { | 528 void WidgetWin::WillProcessMessage(const MSG& msg) { |
| 529 if (!current_messages_) |
| 530 current_messages_ = new std::vector<MSG>; |
| 531 current_messages_->push_back(msg); |
524 } | 532 } |
525 | 533 |
526 void WidgetWin::DidProcessMessage(const MSG& msg) { | 534 void WidgetWin::DidProcessMessage(const MSG& msg) { |
527 if (root_view_->NeedsPainting(true)) { | 535 if (root_view_->NeedsPainting(true)) |
528 PaintNow(root_view_->GetScheduledPaintRect()); | 536 PaintNow(root_view_->GetScheduledPaintRect()); |
529 } | 537 current_messages_->pop_back(); |
530 } | 538 } |
531 | 539 |
532 //////////////////////////////////////////////////////////////////////////////// | 540 //////////////////////////////////////////////////////////////////////////////// |
533 // FocusTraversable | 541 // FocusTraversable |
534 | 542 |
535 FocusSearch* WidgetWin::GetFocusSearch() { | 543 FocusSearch* WidgetWin::GetFocusSearch() { |
536 return root_view_->GetFocusSearch(); | 544 return root_view_->GetFocusSearch(); |
537 } | 545 } |
538 | 546 |
539 FocusTraversable* WidgetWin::GetFocusTraversableParent() { | 547 FocusTraversable* WidgetWin::GetFocusTraversableParent() { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 SetMsgHandled(FALSE); | 690 SetMsgHandled(FALSE); |
683 } | 691 } |
684 | 692 |
685 void WidgetWin::OnInitMenuPopup(HMENU menu, | 693 void WidgetWin::OnInitMenuPopup(HMENU menu, |
686 UINT position, | 694 UINT position, |
687 BOOL is_system_menu) { | 695 BOOL is_system_menu) { |
688 SetMsgHandled(FALSE); | 696 SetMsgHandled(FALSE); |
689 } | 697 } |
690 | 698 |
691 void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { | 699 void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { |
692 KeyEvent event(ui::ET_KEY_PRESSED, ui::KeyboardCodeForWindowsKeyCode(c), | 700 KeyEvent event(current_messages_->back()); |
693 KeyEvent::GetKeyStateFlags(), rep_cnt, flags, | |
694 WM_KEYDOWN); | |
695 RootView* root_view = GetFocusedViewRootView(); | 701 RootView* root_view = GetFocusedViewRootView(); |
696 if (!root_view) | 702 if (!root_view) |
697 root_view = root_view_.get(); | 703 root_view = root_view_.get(); |
698 | 704 |
699 SetMsgHandled(root_view->ProcessKeyEvent(event)); | 705 SetMsgHandled(root_view->ProcessKeyEvent(event)); |
700 } | 706 } |
701 | 707 |
702 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { | 708 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { |
703 KeyEvent event(ui::ET_KEY_RELEASED, ui::KeyboardCodeForWindowsKeyCode(c), | 709 KeyEvent event(current_messages_->back()); |
704 KeyEvent::GetKeyStateFlags(), rep_cnt, flags, | |
705 WM_KEYUP); | |
706 RootView* root_view = GetFocusedViewRootView(); | 710 RootView* root_view = GetFocusedViewRootView(); |
707 if (!root_view) | 711 if (!root_view) |
708 root_view = root_view_.get(); | 712 root_view = root_view_.get(); |
709 | 713 |
710 SetMsgHandled(root_view->ProcessKeyEvent(event)); | 714 SetMsgHandled(root_view->ProcessKeyEvent(event)); |
711 } | 715 } |
712 | 716 |
713 void WidgetWin::OnKillFocus(HWND focused_window) { | 717 void WidgetWin::OnKillFocus(HWND focused_window) { |
714 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( | 718 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( |
715 this->GetNativeView(), | 719 this->GetNativeView(), |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) { | 1389 Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) { |
1386 return Widget::GetWidgetFromNativeView(native_window); | 1390 return Widget::GetWidgetFromNativeView(native_window); |
1387 } | 1391 } |
1388 | 1392 |
1389 // static | 1393 // static |
1390 void Widget::NotifyLocaleChanged() { | 1394 void Widget::NotifyLocaleChanged() { |
1391 NOTIMPLEMENTED(); | 1395 NOTIMPLEMENTED(); |
1392 } | 1396 } |
1393 | 1397 |
1394 } // namespace views | 1398 } // namespace views |
OLD | NEW |