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

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

Issue 6823055: Consolidate OnKeyEvent and InputMethod code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor X2Event handling, nix Windows InputMethodDelegate, etc. 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
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.h" 5 #include "views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "ui/gfx/compositor/compositor.h" 9 #include "ui/gfx/compositor/compositor.h"
10 #include "views/focus/view_storage.h" 10 #include "views/focus/view_storage.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 323
324 bool Widget::HasFocusManager() const { 324 bool Widget::HasFocusManager() const {
325 return !!focus_manager_.get(); 325 return !!focus_manager_.get();
326 } 326 }
327 327
328 void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) { 328 void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) {
329 GetRootView()->Paint(canvas); 329 GetRootView()->Paint(canvas);
330 RefreshCompositeTree(); 330 RefreshCompositeTree();
331 } 331 }
332 332
333 bool Widget::OnKeyEvent(const KeyEvent& event) {
334 InputMethod* input_method = GetInputMethod();
335 return (input_method && input_method->OnKeyEvent(event)) ||
336 DispatchKeyEventPostIME(event);
Ben Goodger (Google) 2011/04/15 18:23:19 If you get rid of the delegate interface this whol
msw 2011/04/15 19:19:57 See James' response regarding delegate / DispatchK
337 }
338
333 bool Widget::OnMouseEvent(const MouseEvent& event) { 339 bool Widget::OnMouseEvent(const MouseEvent& event) {
334 switch (event.type()) { 340 switch (event.type()) {
335 case ui::ET_MOUSE_PRESSED: 341 case ui::ET_MOUSE_PRESSED:
336 last_mouse_event_was_move_ = false; 342 last_mouse_event_was_move_ = false;
337 if (GetRootView()->OnMousePressed(event)) { 343 if (GetRootView()->OnMousePressed(event)) {
338 is_mouse_button_pressed_ = true; 344 is_mouse_button_pressed_ = true;
339 if (!native_widget_->HasMouseCapture()) 345 if (!native_widget_->HasMouseCapture())
340 native_widget_->SetMouseCapture(); 346 native_widget_->SetMouseCapture();
341 return true; 347 return true;
342 } 348 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 403 }
398 404
399 View* Widget::GetFocusTraversableParentView() { 405 View* Widget::GetFocusTraversableParentView() {
400 // We are a proxy to the root view, so we should be bypassed when traversing 406 // We are a proxy to the root view, so we should be bypassed when traversing
401 // up and as a result this should not be called. 407 // up and as a result this should not be called.
402 NOTREACHED(); 408 NOTREACHED();
403 return NULL; 409 return NULL;
404 } 410 }
405 411
406 //////////////////////////////////////////////////////////////////////////////// 412 ////////////////////////////////////////////////////////////////////////////////
413 // Widget, internal::InputMethodDelegate implementation:
414
415 bool Widget::DispatchKeyEventPostIME(const KeyEvent& event) {
416 return GetRootView()->OnKeyEvent(event);
417 }
418
419 ////////////////////////////////////////////////////////////////////////////////
407 // Widget, protected: 420 // Widget, protected:
408 421
409 RootView* Widget::CreateRootView() { 422 RootView* Widget::CreateRootView() {
410 return new RootView(this); 423 return new RootView(this);
411 } 424 }
412 425
413 void Widget::DestroyRootView() { 426 void Widget::DestroyRootView() {
414 root_view_.reset(); 427 root_view_.reset();
415 428
416 // Defer focus manager's destruction. This is for the case when the 429 // Defer focus manager's destruction. This is for the case when the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 compositor_ = ui::Compositor::Create(widget); 465 compositor_ = ui::Compositor::Create(widget);
453 466
454 return compositor_.get() != NULL; 467 return compositor_.get() != NULL;
455 } 468 }
456 469
457 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { 470 bool Widget::ShouldReleaseCaptureOnMouseReleased() const {
458 return true; 471 return true;
459 } 472 }
460 473
461 } // namespace views 474 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698