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

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: 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
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 bool Widget::HasFocusManager() const { 320 bool Widget::HasFocusManager() const {
321 return !!focus_manager_.get(); 321 return !!focus_manager_.get();
322 } 322 }
323 323
324 void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) { 324 void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) {
325 GetRootView()->Paint(canvas); 325 GetRootView()->Paint(canvas);
326 RefreshCompositeTree(); 326 RefreshCompositeTree();
327 } 327 }
328 328
329 void Widget::OnKeyEvent(const KeyEvent& event) {
330 if (GetInputMethod())
331 GetInputMethod()->DispatchKeyEvent(event);
332 else
333 DispatchKeyEventPostIME(event);
Ben Goodger (Google) 2011/04/12 21:11:15 I looked at InputMethod's DispatchKeyEvent/calling
msw 2011/04/14 21:47:39 Done. My updated changes roughly follow this appro
334 }
335
329 bool Widget::OnMouseEvent(const MouseEvent& event) { 336 bool Widget::OnMouseEvent(const MouseEvent& event) {
330 switch (event.type()) { 337 switch (event.type()) {
331 case ui::ET_MOUSE_PRESSED: 338 case ui::ET_MOUSE_PRESSED:
332 last_mouse_event_was_move_ = false; 339 last_mouse_event_was_move_ = false;
333 if (GetRootView()->OnMousePressed(event)) { 340 if (GetRootView()->OnMousePressed(event)) {
334 is_mouse_button_pressed_ = true; 341 is_mouse_button_pressed_ = true;
335 if (!native_widget_->HasMouseCapture()) 342 if (!native_widget_->HasMouseCapture())
336 native_widget_->SetMouseCapture(); 343 native_widget_->SetMouseCapture();
337 return true; 344 return true;
338 } 345 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 400 }
394 401
395 View* Widget::GetFocusTraversableParentView() { 402 View* Widget::GetFocusTraversableParentView() {
396 // We are a proxy to the root view, so we should be bypassed when traversing 403 // We are a proxy to the root view, so we should be bypassed when traversing
397 // up and as a result this should not be called. 404 // up and as a result this should not be called.
398 NOTREACHED(); 405 NOTREACHED();
399 return NULL; 406 return NULL;
400 } 407 }
401 408
402 //////////////////////////////////////////////////////////////////////////////// 409 ////////////////////////////////////////////////////////////////////////////////
410 // Widget, internal::InputMethodDelegate implementation:
411
412 bool Widget::DispatchKeyEventPostIME(const KeyEvent& key) {
413 return GetRootView()->ProcessKeyEvent(key);
414 }
415
416 ////////////////////////////////////////////////////////////////////////////////
403 // Widget, protected: 417 // Widget, protected:
404 418
405 RootView* Widget::CreateRootView() { 419 RootView* Widget::CreateRootView() {
406 return new RootView(this); 420 return new RootView(this);
407 } 421 }
408 422
409 void Widget::DestroyRootView() { 423 void Widget::DestroyRootView() {
410 root_view_.reset(); 424 root_view_.reset();
411 425
412 // Defer focus manager's destruction. This is for the case when the 426 // Defer focus manager's destruction. This is for the case when the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 compositor_ = ui::Compositor::Create(widget); 462 compositor_ = ui::Compositor::Create(widget);
449 463
450 return compositor_.get() != NULL; 464 return compositor_.get() != NULL;
451 } 465 }
452 466
453 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { 467 bool Widget::ShouldReleaseCaptureOnMouseReleased() const {
454 return true; 468 return true;
455 } 469 }
456 470
457 } // namespace views 471 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/widget.h ('k') | views/widget/widget_gtk.h » ('j') | views/widget/widget_gtk.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698