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

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

Issue 10911317: KeyEvent work. (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/widget/desktop_root_window_host_win.h ('k') | ui/views/widget/native_widget_win.cc » ('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/desktop_root_window_host_win.h" 5 #include "ui/views/widget/desktop_root_window_host_win.h"
6 6
7 #include "ui/aura/desktop/desktop_activation_client.h" 7 #include "ui/aura/desktop/desktop_activation_client.h"
8 #include "ui/aura/desktop/desktop_dispatcher_client.h" 8 #include "ui/aura/desktop/desktop_dispatcher_client.h"
9 #include "ui/aura/focus_manager.h" 9 #include "ui/aura/focus_manager.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
11 #include "ui/aura/shared/compound_event_filter.h"
12 #include "ui/views/ime/input_method_win.h"
11 #include "ui/views/widget/desktop_capture_client.h" 13 #include "ui/views/widget/desktop_capture_client.h"
12 #include "ui/views/win/hwnd_message_handler.h" 14 #include "ui/views/win/hwnd_message_handler.h"
13 15
14 namespace views { 16 namespace views {
15 17
16 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
17 // DesktopRootWindowHostWin, public: 19 // DesktopRootWindowHostWin, public:
18 20
19 DesktopRootWindowHostWin::DesktopRootWindowHostWin( 21 DesktopRootWindowHostWin::DesktopRootWindowHostWin(
20 internal::NativeWidgetDelegate* native_widget_delegate, 22 internal::NativeWidgetDelegate* native_widget_delegate,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 root_window_->set_focus_manager(focus_manager_.get()); 56 root_window_->set_focus_manager(focus_manager_.get());
55 57
56 activation_client_.reset( 58 activation_client_.reset(
57 new aura::DesktopActivationClient(root_window_->GetFocusManager())); 59 new aura::DesktopActivationClient(root_window_->GetFocusManager()));
58 aura::client::SetActivationClient(root_window_.get(), 60 aura::client::SetActivationClient(root_window_.get(),
59 activation_client_.get()); 61 activation_client_.get());
60 62
61 dispatcher_client_.reset(new aura::DesktopDispatcherClient); 63 dispatcher_client_.reset(new aura::DesktopDispatcherClient);
62 aura::client::SetDispatcherClient(root_window_.get(), 64 aura::client::SetDispatcherClient(root_window_.get(),
63 dispatcher_client_.get()); 65 dispatcher_client_.get());
66
67 // CEF sets focus to the window the user clicks down on.
68 // TODO(beng): see if we can't do this some other way. CEF seems a heavy-
69 // handed way of accomplishing focus.
70 root_window_->SetEventFilter(new aura::shared::CompoundEventFilter);
64 } 71 }
65 72
66 void DesktopRootWindowHostWin::Close() { 73 void DesktopRootWindowHostWin::Close() {
67 message_handler_->Close(); 74 message_handler_->Close();
68 } 75 }
69 76
70 void DesktopRootWindowHostWin::CloseNow() { 77 void DesktopRootWindowHostWin::CloseNow() {
71 message_handler_->CloseNow(); 78 message_handler_->CloseNow();
72 } 79 }
73 80
74 aura::RootWindowHost* DesktopRootWindowHostWin::AsRootWindowHost() { 81 aura::RootWindowHost* DesktopRootWindowHostWin::AsRootWindowHost() {
75 return this; 82 return this;
76 } 83 }
77 84
78 void DesktopRootWindowHostWin::ShowWindowWithState( 85 void DesktopRootWindowHostWin::ShowWindowWithState(
79 ui::WindowShowState show_state) { 86 ui::WindowShowState show_state) {
80 message_handler_->ShowWindowWithState(show_state); 87 message_handler_->ShowWindowWithState(show_state);
81 } 88 }
82 89
83 bool DesktopRootWindowHostWin::IsVisible() const { 90 bool DesktopRootWindowHostWin::IsVisible() const {
84 return message_handler_->IsVisible(); 91 return message_handler_->IsVisible();
85 } 92 }
86 93
87 gfx::Rect DesktopRootWindowHostWin::GetClientAreaBoundsInScreen() const { 94 gfx::Rect DesktopRootWindowHostWin::GetClientAreaBoundsInScreen() const {
88 return message_handler_->GetClientAreaBoundsInScreen(); 95 return message_handler_->GetClientAreaBoundsInScreen();
89 } 96 }
90 97
98 InputMethod* DesktopRootWindowHostWin::CreateInputMethod() {
99 return new InputMethodWin(message_handler_.get(), message_handler_->hwnd());
100 }
101
102 internal::InputMethodDelegate*
103 DesktopRootWindowHostWin::GetInputMethodDelegate() {
104 return message_handler_.get();
105 }
106
91 //////////////////////////////////////////////////////////////////////////////// 107 ////////////////////////////////////////////////////////////////////////////////
92 // DesktopRootWindowHostWin, RootWindowHost implementation: 108 // DesktopRootWindowHostWin, RootWindowHost implementation:
93 109
94 aura::RootWindow* DesktopRootWindowHostWin::GetRootWindow() { 110 aura::RootWindow* DesktopRootWindowHostWin::GetRootWindow() {
95 return root_window_.get(); 111 return root_window_.get();
96 } 112 }
97 113
98 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() { 114 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() {
99 return message_handler_->hwnd(); 115 return message_handler_->hwnd();
100 } 116 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 271 }
256 272
257 void DesktopRootWindowHostWin::PaintLayeredWindow(gfx::Canvas* canvas) { 273 void DesktopRootWindowHostWin::PaintLayeredWindow(gfx::Canvas* canvas) {
258 } 274 }
259 275
260 gfx::NativeViewAccessible DesktopRootWindowHostWin::GetNativeViewAccessible() { 276 gfx::NativeViewAccessible DesktopRootWindowHostWin::GetNativeViewAccessible() {
261 return NULL; 277 return NULL;
262 } 278 }
263 279
264 InputMethod* DesktopRootWindowHostWin::GetInputMethod() { 280 InputMethod* DesktopRootWindowHostWin::GetInputMethod() {
265 return NULL; 281 return native_widget_delegate_->AsWidget()->GetInputMethodDirect();
266 } 282 }
267 283
268 void DesktopRootWindowHostWin::HandleAppDeactivated() { 284 void DesktopRootWindowHostWin::HandleAppDeactivated() {
269 } 285 }
270 286
271 void DesktopRootWindowHostWin::HandleActivationChanged(bool active) { 287 void DesktopRootWindowHostWin::HandleActivationChanged(bool active) {
272 } 288 }
273 289
274 bool DesktopRootWindowHostWin::HandleAppCommand(short command) { 290 bool DesktopRootWindowHostWin::HandleAppCommand(short command) {
275 return false; 291 return false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (root_window_host_delegate_) 349 if (root_window_host_delegate_)
334 root_window_host_delegate_->OnHostResized(new_size); 350 root_window_host_delegate_->OnHostResized(new_size);
335 // TODO(beng): replace with a layout manager?? 351 // TODO(beng): replace with a layout manager??
336 content_window_->SetBounds(gfx::Rect(new_size)); 352 content_window_->SetBounds(gfx::Rect(new_size));
337 } 353 }
338 354
339 void DesktopRootWindowHostWin::HandleFrameChanged() { 355 void DesktopRootWindowHostWin::HandleFrameChanged() {
340 } 356 }
341 357
342 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { 358 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) {
359 InputMethod* input_method = GetInputMethod();
360 if (input_method)
361 input_method->OnFocus();
343 } 362 }
344 363
345 void DesktopRootWindowHostWin::HandleNativeBlur(HWND focused_window) { 364 void DesktopRootWindowHostWin::HandleNativeBlur(HWND focused_window) {
365 InputMethod* input_method = GetInputMethod();
366 if (input_method)
367 input_method->OnBlur();
346 } 368 }
347 369
348 bool DesktopRootWindowHostWin::HandleMouseEvent(const ui::MouseEvent& event) { 370 bool DesktopRootWindowHostWin::HandleMouseEvent(const ui::MouseEvent& event) {
349 return root_window_host_delegate_->OnHostMouseEvent( 371 return root_window_host_delegate_->OnHostMouseEvent(
350 const_cast<ui::MouseEvent*>(&event)); 372 const_cast<ui::MouseEvent*>(&event));
351 } 373 }
352 374
353 bool DesktopRootWindowHostWin::HandleKeyEvent(const ui::KeyEvent& event) { 375 bool DesktopRootWindowHostWin::HandleKeyEvent(const ui::KeyEvent& event) {
354 return false; 376 return root_window_host_delegate_->OnHostKeyEvent(
377 const_cast<ui::KeyEvent*>(&event));
355 } 378 }
356 379
357 bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent( 380 bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent(
358 const ui::KeyEvent& event) { 381 const ui::KeyEvent& event) {
359 return false; 382 InputMethod* input_method = GetInputMethod();
383 if (input_method)
384 input_method->DispatchKeyEvent(event);
385 return !!input_method;
360 } 386 }
361 387
362 bool DesktopRootWindowHostWin::HandleIMEMessage(UINT message, 388 bool DesktopRootWindowHostWin::HandleIMEMessage(UINT message,
363 WPARAM w_param, 389 WPARAM w_param,
364 LPARAM l_param, 390 LPARAM l_param,
365 LRESULT* result) { 391 LRESULT* result) {
366 return false; 392 InputMethod* input_method = GetInputMethod();
393 if (!input_method || input_method->IsMock()) {
394 *result = 0;
395 return false;
396 }
397
398 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method);
399 BOOL handled = FALSE;
400 *result = ime_win->OnImeMessages(message, w_param, l_param, &handled);
401 return !!handled;
367 } 402 }
368 403
369 void DesktopRootWindowHostWin::HandleInputLanguageChange( 404 void DesktopRootWindowHostWin::HandleInputLanguageChange(
370 DWORD character_set, 405 DWORD character_set,
371 HKL input_language_id) { 406 HKL input_language_id) {
407 InputMethod* input_method = GetInputMethod();
408 if (input_method && !input_method->IsMock()) {
409 static_cast<InputMethodWin*>(input_method)->OnInputLangChange(
410 character_set, input_language_id);
411 }
372 } 412 }
373 413
374 bool DesktopRootWindowHostWin::HandlePaintAccelerated( 414 bool DesktopRootWindowHostWin::HandlePaintAccelerated(
375 const gfx::Rect& invalid_rect) { 415 const gfx::Rect& invalid_rect) {
376 return native_widget_delegate_->OnNativeWidgetPaintAccelerated(invalid_rect); 416 return native_widget_delegate_->OnNativeWidgetPaintAccelerated(invalid_rect);
377 } 417 }
378 418
379 void DesktopRootWindowHostWin::HandlePaint(gfx::Canvas* canvas) { 419 void DesktopRootWindowHostWin::HandlePaint(gfx::Canvas* canvas) {
380 root_window_host_delegate_->OnHostPaint(); 420 root_window_host_delegate_->OnHostPaint();
381 } 421 }
(...skipping 28 matching lines...) Expand all
410 // DesktopRootWindowHost, public: 450 // DesktopRootWindowHost, public:
411 451
412 // static 452 // static
413 DesktopRootWindowHost* DesktopRootWindowHost::Create( 453 DesktopRootWindowHost* DesktopRootWindowHost::Create(
414 internal::NativeWidgetDelegate* native_widget_delegate, 454 internal::NativeWidgetDelegate* native_widget_delegate,
415 const gfx::Rect& initial_bounds) { 455 const gfx::Rect& initial_bounds) {
416 return new DesktopRootWindowHostWin(native_widget_delegate, initial_bounds); 456 return new DesktopRootWindowHostWin(native_widget_delegate, initial_bounds);
417 } 457 }
418 458
419 } // namespace views 459 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_root_window_host_win.h ('k') | ui/views/widget/native_widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698