| OLD | NEW |
| 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 "ui/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/drag_drop_client.h" | 10 #include "ui/aura/client/drag_drop_client.h" |
| 11 #include "ui/aura/client/shadow_types.h" | 11 #include "ui/aura/client/shadow_types.h" |
| 12 #include "ui/aura/desktop.h" | 12 #include "ui/aura/desktop.h" |
| 13 #include "ui/aura/desktop_observer.h" | 13 #include "ui/aura/desktop_observer.h" |
| 14 #include "ui/aura/event.h" | 14 #include "ui/aura/event.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_types.h" | 16 #include "ui/aura/window_types.h" |
| 17 #include "ui/base/dragdrop/os_exchange_data.h" | 17 #include "ui/base/dragdrop/os_exchange_data.h" |
| 18 #include "ui/base/ui_base_types.h" | 18 #include "ui/base/ui_base_types.h" |
| 19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/compositor/layer.h" | 20 #include "ui/gfx/compositor/layer.h" |
| 21 #include "ui/gfx/font.h" | 21 #include "ui/gfx/font.h" |
| 22 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
| 23 #include "ui/views/widget/drop_helper.h" | 23 #include "ui/views/widget/drop_helper.h" |
| 24 #include "ui/views/widget/native_widget_delegate.h" | 24 #include "ui/views/widget/native_widget_delegate.h" |
| 25 #include "ui/views/widget/tooltip_manager_views.h" | 25 #include "ui/views/widget/tooltip_manager_aura.h" |
| 26 #include "ui/views/widget/widget_delegate.h" |
| 26 | 27 |
| 27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 28 #include "base/win/scoped_gdi_object.h" | 29 #include "base/win/scoped_gdi_object.h" |
| 29 #include "base/win/win_util.h" | 30 #include "base/win/win_util.h" |
| 30 #include "ui/base/l10n/l10n_util_win.h" | 31 #include "ui/base/l10n/l10n_util_win.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 #if defined(HAVE_IBUS) | 34 #if defined(HAVE_IBUS) |
| 34 #include "ui/views/ime/input_method_ibus.h" | 35 #include "ui/views/ime/input_method_ibus.h" |
| 35 #else | 36 #else |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 parent->AddTransientChild(window_); | 150 parent->AddTransientChild(window_); |
| 150 // SetAlwaysOnTop before SetParent so that always-on-top container is used. | 151 // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
| 151 SetAlwaysOnTop(params.keep_on_top); | 152 SetAlwaysOnTop(params.keep_on_top); |
| 152 window_->SetParent(NULL); | 153 window_->SetParent(NULL); |
| 153 } | 154 } |
| 154 window_->set_ignore_events(!params.accept_events); | 155 window_->set_ignore_events(!params.accept_events); |
| 155 // TODO(beng): do this some other way. | 156 // TODO(beng): do this some other way. |
| 156 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); | 157 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); |
| 157 can_activate_ = params.can_activate; | 158 can_activate_ = params.can_activate; |
| 158 DCHECK(GetWidget()->GetRootView()); | 159 DCHECK(GetWidget()->GetRootView()); |
| 159 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { | 160 if (params.type != Widget::InitParams::TYPE_TOOLTIP) { |
| 160 views::TooltipManagerViews* manager = new views::TooltipManagerViews( | 161 tooltip_manager_.reset(new views::TooltipManagerAura(this)); |
| 161 GetWidget()->GetRootView()); | |
| 162 tooltip_manager_.reset(manager); | |
| 163 } | 162 } |
| 164 | 163 |
| 165 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); | 164 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); |
| 166 if (params.type != Widget::InitParams::TYPE_TOOLTIP && | 165 if (params.type != Widget::InitParams::TYPE_TOOLTIP && |
| 167 params.type != Widget::InitParams::TYPE_POPUP) { | 166 params.type != Widget::InitParams::TYPE_POPUP) { |
| 168 window_->SetProperty(aura::kDragDropDelegateKey, | 167 window_->SetProperty(aura::kDragDropDelegateKey, |
| 169 static_cast<aura::WindowDragDropDelegate*>(this)); | 168 static_cast<aura::WindowDragDropDelegate*>(this)); |
| 170 } | 169 } |
| 171 | 170 |
| 172 if (window_type == Widget::InitParams::TYPE_MENU) | 171 if (window_type == Widget::InitParams::TYPE_MENU) |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } | 590 } |
| 592 | 591 |
| 593 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 592 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
| 594 return delegate_->GetNonClientComponent(point); | 593 return delegate_->GetNonClientComponent(point); |
| 595 } | 594 } |
| 596 | 595 |
| 597 bool NativeWidgetAura::OnMouseEvent(aura::MouseEvent* event) { | 596 bool NativeWidgetAura::OnMouseEvent(aura::MouseEvent* event) { |
| 598 DCHECK(window_->IsVisible()); | 597 DCHECK(window_->IsVisible()); |
| 599 if (event->type() == ui::ET_MOUSEWHEEL) { | 598 if (event->type() == ui::ET_MOUSEWHEEL) { |
| 600 MouseWheelEvent wheel_event(event); | 599 MouseWheelEvent wheel_event(event); |
| 601 if (tooltip_manager_.get()) | |
| 602 tooltip_manager_->UpdateForMouseEvent(wheel_event); | |
| 603 return delegate_->OnMouseEvent(wheel_event); | 600 return delegate_->OnMouseEvent(wheel_event); |
| 604 } | 601 } |
| 605 MouseEvent mouse_event(event); | 602 MouseEvent mouse_event(event); |
| 606 if (tooltip_manager_.get()) | 603 if (tooltip_manager_.get()) |
| 607 tooltip_manager_->UpdateForMouseEvent(mouse_event); | 604 tooltip_manager_->UpdateTooltip(); |
| 608 return delegate_->OnMouseEvent(mouse_event); | 605 return delegate_->OnMouseEvent(mouse_event); |
| 609 } | 606 } |
| 610 | 607 |
| 611 ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) { | 608 ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) { |
| 612 DCHECK(window_->IsVisible()); | 609 DCHECK(window_->IsVisible()); |
| 613 TouchEvent touch_event(event); | 610 TouchEvent touch_event(event); |
| 614 return delegate_->OnTouchEvent(touch_event); | 611 return delegate_->OnTouchEvent(touch_event); |
| 615 } | 612 } |
| 616 | 613 |
| 617 bool NativeWidgetAura::ShouldActivate(aura::Event* event) { | 614 bool NativeWidgetAura::ShouldActivate(aura::Event* event) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 NOTIMPLEMENTED(); | 764 NOTIMPLEMENTED(); |
| 768 } | 765 } |
| 769 | 766 |
| 770 // static | 767 // static |
| 771 bool NativeWidgetPrivate::IsMouseButtonDown() { | 768 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 772 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 769 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
| 773 } | 770 } |
| 774 | 771 |
| 775 } // namespace internal | 772 } // namespace internal |
| 776 } // namespace views | 773 } // namespace views |
| OLD | NEW |