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

Side by Side Diff: ui/views/widget/native_widget_aura.cc

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded parens Created 6 years, 11 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) 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/window_move_client.h" 16 #include "ui/aura/client/window_move_client.h"
17 #include "ui/aura/client/window_tree_client.h" 17 #include "ui/aura/client/window_tree_client.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/root_window.h" 19 #include "ui/aura/root_window.h"
20 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/aura/window_observer.h" 21 #include "ui/aura/window_observer.h"
22 #include "ui/base/dragdrop/os_exchange_data.h" 22 #include "ui/base/dragdrop/os_exchange_data.h"
23 #include "ui/base/ui_base_types.h" 23 #include "ui/base/ui_base_types.h"
24 #include "ui/compositor/layer.h" 24 #include "ui/compositor/layer.h"
25 #include "ui/events/event.h" 25 #include "ui/events/event.h"
26 #include "ui/gfx/canvas.h" 26 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/font.h" 27 #include "ui/gfx/font.h"
28 #include "ui/gfx/screen.h" 28 #include "ui/gfx/screen.h"
29 #include "ui/native_theme/native_theme_aura.h" 29 #include "ui/native_theme/native_theme_aura.h"
30 #include "ui/views/corewm/window_util.h"
30 #include "ui/views/drag_utils.h" 31 #include "ui/views/drag_utils.h"
31 #include "ui/views/ime/input_method_bridge.h" 32 #include "ui/views/ime/input_method_bridge.h"
32 #include "ui/views/views_delegate.h" 33 #include "ui/views/views_delegate.h"
33 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
34 #include "ui/views/widget/drop_helper.h" 35 #include "ui/views/widget/drop_helper.h"
35 #include "ui/views/widget/native_widget_delegate.h" 36 #include "ui/views/widget/native_widget_delegate.h"
36 #include "ui/views/widget/root_view.h" 37 #include "ui/views/widget/root_view.h"
37 #include "ui/views/widget/tooltip_manager_aura.h" 38 #include "ui/views/widget/tooltip_manager_aura.h"
38 #include "ui/views/widget/widget_aura_utils.h" 39 #include "ui/views/widget/widget_aura_utils.h"
39 #include "ui/views/widget/widget_delegate.h" 40 #include "ui/views/widget/widget_delegate.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
131 // Set up the transient child before the window is added. This way the 132 // Set up the transient child before the window is added. This way the
132 // LayoutManager knows the window has a transient parent. 133 // LayoutManager knows the window has a transient parent.
133 if (parent && parent->type() != ui::wm::WINDOW_TYPE_UNKNOWN) { 134 if (parent && parent->type() != ui::wm::WINDOW_TYPE_UNKNOWN) {
134 parent->AddTransientChild(window_); 135 corewm::AddTransientChild(parent, window_);
135 if (!context) 136 if (!context)
136 context = parent; 137 context = parent;
137 parent = NULL; 138 parent = NULL;
138 } 139 }
139 // SetAlwaysOnTop before SetParent so that always-on-top container is used. 140 // SetAlwaysOnTop before SetParent so that always-on-top container is used.
140 SetAlwaysOnTop(params.keep_on_top); 141 SetAlwaysOnTop(params.keep_on_top);
141 // Make sure we have a real |window_bounds|. 142 // Make sure we have a real |window_bounds|.
142 if (parent && window_bounds == gfx::Rect()) { 143 if (parent && window_bounds == gfx::Rect()) {
143 // If a parent is specified but no bounds are given, 144 // If a parent is specified but no bounds are given,
144 // use the origin of the parent's display so that the widget 145 // use the origin of the parent's display so that the widget
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 gfx::Point origin = work_area.origin(); 304 gfx::Point origin = work_area.origin();
304 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(), 305 screen_position_client->ConvertPointFromScreen(window_->GetRootWindow(),
305 &origin); 306 &origin);
306 work_area.set_origin(origin); 307 work_area.set_origin(origin);
307 } 308 }
308 309
309 parent_bounds.Intersect(work_area); 310 parent_bounds.Intersect(work_area);
310 311
311 // If |window_|'s transient parent's bounds are big enough to fit it, then we 312 // If |window_|'s transient parent's bounds are big enough to fit it, then we
312 // center it with respect to the transient parent. 313 // center it with respect to the transient parent.
313 if (window_->transient_parent()) { 314 if (views::corewm::GetTransientParent(window_)) {
314 gfx::Rect transient_parent_rect = window_->transient_parent()-> 315 gfx::Rect transient_parent_rect =
315 GetBoundsInRootWindow(); 316 views::corewm::GetTransientParent(window_)->GetBoundsInRootWindow();
316 transient_parent_rect.Intersect(work_area); 317 transient_parent_rect.Intersect(work_area);
317 if (transient_parent_rect.height() >= size.height() && 318 if (transient_parent_rect.height() >= size.height() &&
318 transient_parent_rect.width() >= size.width()) 319 transient_parent_rect.width() >= size.width())
319 parent_bounds = transient_parent_rect; 320 parent_bounds = transient_parent_rect;
320 } 321 }
321 322
322 gfx::Rect window_bounds( 323 gfx::Rect window_bounds(
323 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2, 324 parent_bounds.x() + (parent_bounds.width() - size.width()) / 2,
324 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2, 325 parent_bounds.y() + (parent_bounds.height() - size.height()) / 2,
325 size.width(), 326 size.width(),
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 for (aura::Window::Windows::const_iterator i = child_windows.begin(); 1076 for (aura::Window::Windows::const_iterator i = child_windows.begin();
1076 i != child_windows.end(); ++i) { 1077 i != child_windows.end(); ++i) {
1077 GetAllChildWidgets((*i), children); 1078 GetAllChildWidgets((*i), children);
1078 } 1079 }
1079 } 1080 }
1080 1081
1081 // static 1082 // static
1082 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, 1083 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view,
1083 Widget::Widgets* owned) { 1084 Widget::Widgets* owned) {
1084 const aura::Window::Windows& transient_children = 1085 const aura::Window::Windows& transient_children =
1085 native_view->transient_children(); 1086 views::corewm::GetTransientChildren(native_view);
1086 for (aura::Window::Windows::const_iterator i = transient_children.begin(); 1087 for (aura::Window::Windows::const_iterator i = transient_children.begin();
1087 i != transient_children.end(); ++i) { 1088 i != transient_children.end(); ++i) {
1088 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( 1089 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>(
1089 GetNativeWidgetForNativeView(*i)); 1090 GetNativeWidgetForNativeView(*i));
1090 if (native_widget && native_widget->GetWidget()) 1091 if (native_widget && native_widget->GetWidget())
1091 owned->insert(native_widget->GetWidget()); 1092 owned->insert(native_widget->GetWidget());
1092 GetAllOwnedWidgets((*i), owned); 1093 GetAllOwnedWidgets((*i), owned);
1093 } 1094 }
1094 } 1095 }
1095 1096
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 return aura::Env::GetInstance()->IsMouseButtonDown(); 1144 return aura::Env::GetInstance()->IsMouseButtonDown();
1144 } 1145 }
1145 1146
1146 // static 1147 // static
1147 bool NativeWidgetPrivate::IsTouchDown() { 1148 bool NativeWidgetPrivate::IsTouchDown() {
1148 return aura::Env::GetInstance()->is_touch_down(); 1149 return aura::Env::GetInstance()->is_touch_down();
1149 } 1150 }
1150 1151
1151 } // namespace internal 1152 } // namespace internal
1152 } // namespace views 1153 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc ('k') | ui/wm/core/easy_resize_window_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698