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

Side by Side Diff: views/widget/widget_win.cc

Issue 6823055: Consolidate OnKeyEvent and InputMethod code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reduce the scope of this change. Created 9 years, 8 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
« views/widget/widget_gtk.cc ('K') | « views/widget/widget_win.h ('k') | no next file » | 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) 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"
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 786
787 void WidgetWin::OnInputLangChange(DWORD character_set, HKL input_language_id) { 787 void WidgetWin::OnInputLangChange(DWORD character_set, HKL input_language_id) {
788 if (is_input_method_win_) { 788 if (is_input_method_win_) {
789 static_cast<InputMethodWin*>(input_method_.get())->OnInputLangChange( 789 static_cast<InputMethodWin*>(input_method_.get())->OnInputLangChange(
790 character_set, input_language_id); 790 character_set, input_language_id);
791 } 791 }
792 } 792 }
793 793
794 LRESULT WidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { 794 LRESULT WidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) {
795 MSG msg = { hwnd(), message, w_param, l_param }; 795 MSG msg = { hwnd(), message, w_param, l_param };
796 KeyEvent key(msg); 796 delegate_->OnKeyEvent(KeyEvent(msg));
797 if (input_method_.get())
798 input_method_->DispatchKeyEvent(key);
799 else
800 DispatchKeyEventPostIME(key);
801 return 0; 797 return 0;
802 } 798 }
803 799
804 void WidgetWin::OnKillFocus(HWND focused_window) { 800 void WidgetWin::OnKillFocus(HWND focused_window) {
805 delegate_->OnNativeBlur(focused_window); 801 delegate_->OnNativeBlur(focused_window);
806 if (input_method_.get()) 802 if (input_method_.get())
807 input_method_->OnBlur(); 803 input_method_->OnBlur();
808 SetMsgHandled(FALSE); 804 SetMsgHandled(FALSE);
809 } 805 }
810 806
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 while (parent) { 1014 while (parent) {
1019 WidgetWin* widget = 1015 WidgetWin* widget =
1020 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); 1016 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent));
1021 if (widget && widget->is_window_) 1017 if (widget && widget->is_window_)
1022 return static_cast<WindowWin*>(widget); 1018 return static_cast<WindowWin*>(widget);
1023 parent = ::GetParent(parent); 1019 parent = ::GetParent(parent);
1024 } 1020 }
1025 return NULL; 1021 return NULL;
1026 } 1022 }
1027 1023
1028 RootView* WidgetWin::GetFocusedViewRootView() {
1029 // TODO(beng): get rid of this
1030 FocusManager* focus_manager = GetFocusManager();
1031 if (!focus_manager) {
1032 NOTREACHED();
1033 return NULL;
1034 }
1035 View* focused_view = focus_manager->GetFocusedView();
1036 if (!focused_view)
1037 return NULL;
1038 return focused_view->GetRootView();
1039 }
1040
1041 // static 1024 // static
1042 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, 1025 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget,
1043 int activation_state) { 1026 int activation_state) {
1044 if (!widget->delegate_->HasFocusManager()) { 1027 if (!widget->delegate_->HasFocusManager()) {
1045 NOTREACHED(); 1028 NOTREACHED();
1046 return; 1029 return;
1047 } 1030 }
1048 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); 1031 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager();
1049 if (WA_INACTIVE == activation_state) { 1032 if (WA_INACTIVE == activation_state) {
1050 // We might get activated/inactivated without being enabled, so we need to 1033 // We might get activated/inactivated without being enabled, so we need to
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 layered_window_contents_.reset( 1098 layered_window_contents_.reset(
1116 new gfx::CanvasSkia(s.width(), s.height(), false)); 1099 new gfx::CanvasSkia(s.width(), s.height(), false));
1117 } 1100 }
1118 } 1101 }
1119 1102
1120 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { 1103 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() {
1121 // TODO(beng): 1104 // TODO(beng):
1122 return gfx::kNullAcceleratedWidget; 1105 return gfx::kNullAcceleratedWidget;
1123 } 1106 }
1124 1107
1125 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { 1108 bool WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) {
1126 RootView* root_view = GetFocusedViewRootView(); 1109 bool handled = Widget::DispatchKeyEventPostIME(key);
1127 if (!root_view) 1110 SetMsgHandled(handled);
Ben Goodger (Google) 2011/04/12 21:11:15 I prefer these SetMsgHandled things to only be cal
msw 2011/04/14 21:47:39 Done.
1128 root_view = GetRootView(); 1111 return handled;
1129
1130 SetMsgHandled(root_view->ProcessKeyEvent(key));
1131 } 1112 }
1132 1113
1133 //////////////////////////////////////////////////////////////////////////////// 1114 ////////////////////////////////////////////////////////////////////////////////
1134 // Widget, public: 1115 // Widget, public:
1135 1116
1136 // static 1117 // static
1137 Widget* Widget::CreateWidget(const CreateParams& params) { 1118 Widget* Widget::CreateWidget(const CreateParams& params) {
1138 WidgetWin* widget = new WidgetWin; 1119 WidgetWin* widget = new WidgetWin;
1139 widget->SetCreateParams(params); 1120 widget->SetCreateParams(params);
1140 return widget; 1121 return widget;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 1271
1291 // And now, notify them that they have a brand new parent. 1272 // And now, notify them that they have a brand new parent.
1292 for (NativeWidgets::iterator it = widgets.begin(); 1273 for (NativeWidgets::iterator it = widgets.begin();
1293 it != widgets.end(); ++it) { 1274 it != widgets.end(); ++it) {
1294 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, 1275 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true,
1295 new_parent); 1276 new_parent);
1296 } 1277 }
1297 } 1278 }
1298 1279
1299 } // namespace views 1280 } // namespace views
OLDNEW
« views/widget/widget_gtk.cc ('K') | « views/widget/widget_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698