| 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/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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "ui/aura/client/activation_client.h" | 10 #include "ui/aura/client/activation_client.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
| 23 #include "ui/base/dragdrop/os_exchange_data.h" | 23 #include "ui/base/dragdrop/os_exchange_data.h" |
| 24 #include "ui/base/ui_base_types.h" | 24 #include "ui/base/ui_base_types.h" |
| 25 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
| 26 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
| 27 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/font.h" | 28 #include "ui/gfx/font.h" |
| 29 #include "ui/gfx/screen.h" | 29 #include "ui/gfx/screen.h" |
| 30 #include "ui/native_theme/native_theme_aura.h" | 30 #include "ui/native_theme/native_theme_aura.h" |
| 31 #include "ui/views/corewm/transient_window_manager.h" |
| 31 #include "ui/views/drag_utils.h" | 32 #include "ui/views/drag_utils.h" |
| 32 #include "ui/views/ime/input_method_bridge.h" | 33 #include "ui/views/ime/input_method_bridge.h" |
| 33 #include "ui/views/views_delegate.h" | 34 #include "ui/views/views_delegate.h" |
| 34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 35 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 35 #include "ui/views/widget/drop_helper.h" | 36 #include "ui/views/widget/drop_helper.h" |
| 36 #include "ui/views/widget/native_widget_delegate.h" | 37 #include "ui/views/widget/native_widget_delegate.h" |
| 37 #include "ui/views/widget/root_view.h" | 38 #include "ui/views/widget/root_view.h" |
| 38 #include "ui/views/widget/tooltip_manager_aura.h" | 39 #include "ui/views/widget/tooltip_manager_aura.h" |
| 39 #include "ui/views/widget/widget_aura_utils.h" | 40 #include "ui/views/widget/widget_aura_utils.h" |
| 40 #include "ui/views/widget/widget_delegate.h" | 41 #include "ui/views/widget/widget_delegate.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 window_->Init(params.layer_type); | 122 window_->Init(params.layer_type); |
| 122 if (params.type == Widget::InitParams::TYPE_CONTROL) | 123 if (params.type == Widget::InitParams::TYPE_CONTROL) |
| 123 window_->Show(); | 124 window_->Show(); |
| 124 | 125 |
| 125 delegate_->OnNativeWidgetCreated(false); | 126 delegate_->OnNativeWidgetCreated(false); |
| 126 | 127 |
| 127 gfx::Rect window_bounds = params.bounds; | 128 gfx::Rect window_bounds = params.bounds; |
| 128 gfx::NativeView parent = params.parent; | 129 gfx::NativeView parent = params.parent; |
| 129 gfx::NativeView context = params.context; | 130 gfx::NativeView context = params.context; |
| 130 if (!params.child) { | 131 if (!params.child) { |
| 132 |
| 131 // Set up the transient child before the window is added. This way the | 133 // Set up the transient child before the window is added. This way the |
| 132 // LayoutManager knows the window has a transient parent. | 134 // LayoutManager knows the window has a transient parent. |
| 133 if (parent && parent->type() != aura::client::WINDOW_TYPE_UNKNOWN) { | 135 if (parent && parent->type() != aura::client::WINDOW_TYPE_UNKNOWN) { |
| 134 parent->AddTransientChild(window_); | 136 corewm::AddTransientChild(parent, window_); |
| 135 if (!context) | 137 if (!context) |
| 136 context = parent; | 138 context = parent; |
| 137 parent = NULL; | 139 parent = NULL; |
| 138 } | 140 } |
| 139 // SetAlwaysOnTop before SetParent so that always-on-top container is used. | 141 // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
| 140 SetAlwaysOnTop(params.keep_on_top); | 142 SetAlwaysOnTop(params.keep_on_top); |
| 141 // Make sure we have a real |window_bounds|. | 143 // Make sure we have a real |window_bounds|. |
| 142 if (parent && window_bounds == gfx::Rect()) { | 144 if (parent && window_bounds == gfx::Rect()) { |
| 143 // If a parent is specified but no bounds are given, | 145 // If a parent is specified but no bounds are given, |
| 144 // use the origin of the parent's display so that the widget | 146 // use the origin of the parent's display so that the widget |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 gfx::Point origin = work_area.origin(); | 305 gfx::Point origin = work_area.origin(); |
| 304 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), | 306 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), |
| 305 &origin); | 307 &origin); |
| 306 work_area.set_origin(origin); | 308 work_area.set_origin(origin); |
| 307 } | 309 } |
| 308 | 310 |
| 309 parent_bounds.Intersect(work_area); | 311 parent_bounds.Intersect(work_area); |
| 310 | 312 |
| 311 // If |window_|'s transient parent's bounds are big enough to fit it, then we | 313 // If |window_|'s transient parent's bounds are big enough to fit it, then we |
| 312 // center it with respect to the transient parent. | 314 // center it with respect to the transient parent. |
| 313 if (window_->transient_parent()) { | 315 if (views::corewm::GetTransientParent(window_)) { |
| 314 gfx::Rect transient_parent_rect = window_->transient_parent()-> | 316 gfx::Rect transient_parent_rect = |
| 315 GetBoundsInRootWindow(); | 317 views::corewm::GetTransientParent(window_)->GetBoundsInRootWindow(); |
| 316 transient_parent_rect.Intersect(work_area); | 318 transient_parent_rect.Intersect(work_area); |
| 317 if (transient_parent_rect.height() >= size.height() && | 319 if (transient_parent_rect.height() >= size.height() && |
| 318 transient_parent_rect.width() >= size.width()) | 320 transient_parent_rect.width() >= size.width()) |
| 319 parent_bounds = transient_parent_rect; | 321 parent_bounds = transient_parent_rect; |
| 320 } | 322 } |
| 321 | 323 |
| 322 gfx::Rect window_bounds( | 324 gfx::Rect window_bounds( |
| 323 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, | 325 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, |
| 324 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, | 326 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, |
| 325 size.width(), | 327 size.width(), |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 for (aura::Window::Windows::const_iterator i = child_windows.begin(); | 1077 for (aura::Window::Windows::const_iterator i = child_windows.begin(); |
| 1076 i != child_windows.end(); ++i) { | 1078 i != child_windows.end(); ++i) { |
| 1077 GetAllChildWidgets((*i), children); | 1079 GetAllChildWidgets((*i), children); |
| 1078 } | 1080 } |
| 1079 } | 1081 } |
| 1080 | 1082 |
| 1081 // static | 1083 // static |
| 1082 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, | 1084 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, |
| 1083 Widget::Widgets* owned) { | 1085 Widget::Widgets* owned) { |
| 1084 const aura::Window::Windows& transient_children = | 1086 const aura::Window::Windows& transient_children = |
| 1085 native_view->transient_children(); | 1087 views::corewm::GetTransientChildren(native_view); |
| 1086 for (aura::Window::Windows::const_iterator i = transient_children.begin(); | 1088 for (aura::Window::Windows::const_iterator i = transient_children.begin(); |
| 1087 i != transient_children.end(); ++i) { | 1089 i != transient_children.end(); ++i) { |
| 1088 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( | 1090 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( |
| 1089 GetNativeWidgetForNativeView(*i)); | 1091 GetNativeWidgetForNativeView(*i)); |
| 1090 if (native_widget && native_widget->GetWidget()) | 1092 if (native_widget && native_widget->GetWidget()) |
| 1091 owned->insert(native_widget->GetWidget()); | 1093 owned->insert(native_widget->GetWidget()); |
| 1092 GetAllOwnedWidgets((*i), owned); | 1094 GetAllOwnedWidgets((*i), owned); |
| 1093 } | 1095 } |
| 1094 } | 1096 } |
| 1095 | 1097 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 return aura::Env::GetInstance()->IsMouseButtonDown(); | 1145 return aura::Env::GetInstance()->IsMouseButtonDown(); |
| 1144 } | 1146 } |
| 1145 | 1147 |
| 1146 // static | 1148 // static |
| 1147 bool NativeWidgetPrivate::IsTouchDown() { | 1149 bool NativeWidgetPrivate::IsTouchDown() { |
| 1148 return aura::Env::GetInstance()->is_touch_down(); | 1150 return aura::Env::GetInstance()->is_touch_down(); |
| 1149 } | 1151 } |
| 1150 | 1152 |
| 1151 } // namespace internal | 1153 } // namespace internal |
| 1152 } // namespace views | 1154 } // namespace views |
| OLD | NEW |