| 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" |
| 11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
| 13 #include "ui/aura/client/drag_drop_client.h" | 13 #include "ui/aura/client/drag_drop_client.h" |
| 14 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
| 15 #include "ui/aura/client/screen_position_client.h" | 15 #include "ui/aura/client/screen_position_client.h" |
| 16 #include "ui/aura/client/stacking_client.h" | |
| 17 #include "ui/aura/client/window_move_client.h" | 16 #include "ui/aura/client/window_move_client.h" |
| 17 #include "ui/aura/client/window_tree_client.h" |
| 18 #include "ui/aura/client/window_types.h" | 18 #include "ui/aura/client/window_types.h" |
| 19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 20 #include "ui/aura/root_window.h" | 20 #include "ui/aura/root_window.h" |
| 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" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // will be added to the same display as the parent. | 146 // will be added to the same display as the parent. |
| 147 gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> | 147 gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> |
| 148 GetDisplayNearestWindow(parent).bounds(); | 148 GetDisplayNearestWindow(parent).bounds(); |
| 149 window_bounds.set_origin(bounds.origin()); | 149 window_bounds.set_origin(bounds.origin()); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 if (parent) { | 153 if (parent) { |
| 154 parent->AddChild(window_); | 154 parent->AddChild(window_); |
| 155 } else { | 155 } else { |
| 156 window_->SetDefaultParentByRootWindow(context->GetRootWindow(), | 156 aura::client::ParentWindowWithContext( |
| 157 window_bounds); | 157 window_, context->GetRootWindow(), window_bounds); |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Wait to set the bounds until we have a parent. That way we can know our | 160 // Wait to set the bounds until we have a parent. That way we can know our |
| 161 // true state/bounds (the LayoutManager may enforce a particular | 161 // true state/bounds (the LayoutManager may enforce a particular |
| 162 // state/bounds). | 162 // state/bounds). |
| 163 if (IsMaximized()) | 163 if (IsMaximized()) |
| 164 SetRestoreBounds(window_, window_bounds); | 164 SetRestoreBounds(window_, window_bounds); |
| 165 else | 165 else |
| 166 SetBounds(window_bounds); | 166 SetBounds(window_bounds); |
| 167 window_->set_ignore_events(!params.accept_events); | 167 window_->set_ignore_events(!params.accept_events); |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 for (Widget::Widgets::iterator it = widgets.begin(); | 1115 for (Widget::Widgets::iterator it = widgets.begin(); |
| 1116 it != widgets.end(); ++it) { | 1116 it != widgets.end(); ++it) { |
| 1117 (*it)->NotifyNativeViewHierarchyWillChange(); | 1117 (*it)->NotifyNativeViewHierarchyWillChange(); |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 if (new_parent) { | 1120 if (new_parent) { |
| 1121 new_parent->AddChild(native_view); | 1121 new_parent->AddChild(native_view); |
| 1122 } else { | 1122 } else { |
| 1123 // The following looks weird, but it's the equivalent of what aura has | 1123 // The following looks weird, but it's the equivalent of what aura has |
| 1124 // always done. (The previous behaviour of aura::Window::SetParent() used | 1124 // always done. (The previous behaviour of aura::Window::SetParent() used |
| 1125 // NULL as a special value that meant ask the StackingClient where things | 1125 // NULL as a special value that meant ask the WindowTreeClient where things |
| 1126 // should go.) | 1126 // should go.) |
| 1127 // | 1127 // |
| 1128 // This probably isn't strictly correct, but its an invariant that a Window | 1128 // This probably isn't strictly correct, but its an invariant that a Window |
| 1129 // in use will be attached to a RootWindow, so we can't just call | 1129 // in use will be attached to a RootWindow, so we can't just call |
| 1130 // RemoveChild here. The only possible thing that could assign a RootWindow | 1130 // RemoveChild here. The only possible thing that could assign a RootWindow |
| 1131 // in this case is the stacking client of the current RootWindow. This | 1131 // in this case is the stacking client of the current RootWindow. This |
| 1132 // matches our previous behaviour; the global stacking client would almost | 1132 // matches our previous behaviour; the global stacking client would almost |
| 1133 // always reattach the window to the same RootWindow. | 1133 // always reattach the window to the same RootWindow. |
| 1134 aura::RootWindow* root_window = native_view->GetRootWindow(); | 1134 aura::RootWindow* root_window = native_view->GetRootWindow(); |
| 1135 native_view->SetDefaultParentByRootWindow( | 1135 aura::client::ParentWindowWithContext( |
| 1136 root_window, root_window->GetBoundsInScreen()); | 1136 native_view, root_window, root_window->GetBoundsInScreen()); |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 // And now, notify them that they have a brand new parent. | 1139 // And now, notify them that they have a brand new parent. |
| 1140 for (Widget::Widgets::iterator it = widgets.begin(); | 1140 for (Widget::Widgets::iterator it = widgets.begin(); |
| 1141 it != widgets.end(); ++it) { | 1141 it != widgets.end(); ++it) { |
| 1142 (*it)->NotifyNativeViewHierarchyChanged(); | 1142 (*it)->NotifyNativeViewHierarchyChanged(); |
| 1143 } | 1143 } |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 // static | 1146 // static |
| 1147 bool NativeWidgetPrivate::IsMouseButtonDown() { | 1147 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 1148 return aura::Env::GetInstance()->IsMouseButtonDown(); | 1148 return aura::Env::GetInstance()->IsMouseButtonDown(); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 // static | 1151 // static |
| 1152 bool NativeWidgetPrivate::IsTouchDown() { | 1152 bool NativeWidgetPrivate::IsTouchDown() { |
| 1153 return aura::Env::GetInstance()->is_touch_down(); | 1153 return aura::Env::GetInstance()->is_touch_down(); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 } // namespace internal | 1156 } // namespace internal |
| 1157 } // namespace views | 1157 } // namespace views |
| OLD | NEW |