| OLD | NEW |
| 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_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/stacking_client.h" | 8 #include "ui/aura/client/stacking_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" |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 scoped_refptr<ui::Texture> DesktopNativeWidgetAura::CopyTexture() { | 537 scoped_refptr<ui::Texture> DesktopNativeWidgetAura::CopyTexture() { |
| 538 // The layer we create doesn't have an external texture, so this should never | 538 // The layer we create doesn't have an external texture, so this should never |
| 539 // get invoked. | 539 // get invoked. |
| 540 NOTREACHED(); | 540 NOTREACHED(); |
| 541 return scoped_refptr<ui::Texture>(); | 541 return scoped_refptr<ui::Texture>(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 //////////////////////////////////////////////////////////////////////////////// | 544 //////////////////////////////////////////////////////////////////////////////// |
| 545 // DesktopNativeWidgetAura, ui::EventHandler implementation: | 545 // DesktopNativeWidgetAura, ui::EventHandler implementation: |
| 546 | 546 |
| 547 ui::EventResult DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { | 547 void DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
| 548 if (event->is_char()) { | 548 if (event->is_char()) { |
| 549 // If a ui::InputMethod object is attached to the root window, character | 549 // If a ui::InputMethod object is attached to the root window, character |
| 550 // events are handled inside the object and are not passed to this function. | 550 // events are handled inside the object and are not passed to this function. |
| 551 // If such object is not attached, character events might be sent (e.g. on | 551 // If such object is not attached, character events might be sent (e.g. on |
| 552 // Windows). In this case, we just skip these. | 552 // Windows). In this case, we just skip these. |
| 553 return ui::ER_UNHANDLED; | 553 return; |
| 554 } | 554 } |
| 555 // Renderer may send a key event back to us if the key event wasn't handled, | 555 // Renderer may send a key event back to us if the key event wasn't handled, |
| 556 // and the window may be invisible by that time. | 556 // and the window may be invisible by that time. |
| 557 if (!window_->IsVisible()) | 557 if (!window_->IsVisible()) |
| 558 return ui::ER_UNHANDLED; | 558 return; |
| 559 | 559 |
| 560 if (native_widget_delegate_->OnKeyEvent(*event)) | 560 native_widget_delegate_->OnKeyEvent(event); |
| 561 return ui::ER_HANDLED; | 561 if (event->handled()) |
| 562 return; |
| 562 | 563 |
| 563 if (GetWidget()->HasFocusManager() && | 564 if (GetWidget()->HasFocusManager() && |
| 564 !GetWidget()->GetFocusManager()->OnKeyEvent(*event)) | 565 !GetWidget()->GetFocusManager()->OnKeyEvent(*event)) |
| 565 return ui::ER_HANDLED; | 566 event->SetHandled(); |
| 566 | |
| 567 return ui::ER_UNHANDLED; | |
| 568 } | 567 } |
| 569 | 568 |
| 570 ui::EventResult DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { | 569 ui::EventResult DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
| 571 DCHECK(window_->IsVisible()); | 570 DCHECK(window_->IsVisible()); |
| 572 if (event->type() == ui::ET_MOUSEWHEEL) { | 571 if (event->type() == ui::ET_MOUSEWHEEL) { |
| 573 return native_widget_delegate_->OnMouseEvent(*event) ? | 572 return native_widget_delegate_->OnMouseEvent(*event) ? |
| 574 ui::ER_HANDLED : ui::ER_UNHANDLED; | 573 ui::ER_HANDLED : ui::ER_UNHANDLED; |
| 575 } | 574 } |
| 576 | 575 |
| 577 return native_widget_delegate_->OnMouseEvent(*event) ? | 576 return native_widget_delegate_->OnMouseEvent(*event) ? |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 aura::client::GetFocusClient(window_)->GetFocusedWindow()); | 663 aura::client::GetFocusClient(window_)->GetFocusedWindow()); |
| 665 } | 664 } |
| 666 } | 665 } |
| 667 | 666 |
| 668 //////////////////////////////////////////////////////////////////////////////// | 667 //////////////////////////////////////////////////////////////////////////////// |
| 669 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: | 668 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: |
| 670 | 669 |
| 671 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 670 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
| 672 FocusManager* focus_manager = | 671 FocusManager* focus_manager = |
| 673 native_widget_delegate_->AsWidget()->GetFocusManager(); | 672 native_widget_delegate_->AsWidget()->GetFocusManager(); |
| 674 if (native_widget_delegate_->OnKeyEvent(key) || !focus_manager) | 673 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
| 674 if (key.handled() || !focus_manager) |
| 675 return; | 675 return; |
| 676 focus_manager->OnKeyEvent(key); | 676 focus_manager->OnKeyEvent(key); |
| 677 } | 677 } |
| 678 | 678 |
| 679 //////////////////////////////////////////////////////////////////////////////// | 679 //////////////////////////////////////////////////////////////////////////////// |
| 680 // DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation: | 680 // DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation: |
| 681 | 681 |
| 682 void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { | 682 void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { |
| 683 DCHECK(drop_helper_.get() != NULL); | 683 DCHECK(drop_helper_.get() != NULL); |
| 684 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), | 684 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 697 drop_helper_->OnDragExit(); | 697 drop_helper_->OnDragExit(); |
| 698 } | 698 } |
| 699 | 699 |
| 700 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 700 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 701 DCHECK(drop_helper_.get() != NULL); | 701 DCHECK(drop_helper_.get() != NULL); |
| 702 return drop_helper_->OnDrop(event.data(), event.location(), | 702 return drop_helper_->OnDrop(event.data(), event.location(), |
| 703 last_drop_operation_); | 703 last_drop_operation_); |
| 704 } | 704 } |
| 705 | 705 |
| 706 } // namespace views | 706 } // namespace views |
| OLD | NEW |