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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_screen_position_client.cc

Issue 21504003: Don't assume that widgets of TYPE_CONTROL are parented to the RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review issues. Created 7 years, 4 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
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/desktop_aura/desktop_screen_position_client.h" 5 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
6 6
7 #include "ui/aura/root_window.h" 7 #include "ui/aura/root_window.h"
8 #include "ui/gfx/display.h" 8 #include "ui/gfx/display.h"
9 #include "ui/gfx/point_conversions.h" 9 #include "ui/gfx/point_conversions.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void DesktopScreenPositionClient::ConvertHostPointToScreen( 61 void DesktopScreenPositionClient::ConvertHostPointToScreen(
62 aura::RootWindow* window, gfx::Point* point) { 62 aura::RootWindow* window, gfx::Point* point) {
63 ConvertPointToScreen(window, point); 63 ConvertPointToScreen(window, point);
64 } 64 }
65 65
66 void DesktopScreenPositionClient::SetBounds( 66 void DesktopScreenPositionClient::SetBounds(
67 aura::Window* window, 67 aura::Window* window,
68 const gfx::Rect& bounds, 68 const gfx::Rect& bounds,
69 const gfx::Display& display) { 69 const gfx::Display& display) {
70 // TODO: Use the 3rd parameter, |display|. 70 // TODO: Use the 3rd parameter, |display|.
71 gfx::Point origin = bounds.origin();
72 aura::RootWindow* root = window->GetRootWindow(); 71 aura::RootWindow* root = window->GetRootWindow();
73 aura::Window::ConvertPointToTarget(window->parent(), root, &origin);
74
75 if (window->type() == aura::client::WINDOW_TYPE_CONTROL) {
76 window->SetBounds(gfx::Rect(origin, bounds.size()));
77 return;
78 }
79 72
80 if (PositionWindowInScreenCoordinates(window)) { 73 if (PositionWindowInScreenCoordinates(window)) {
81 // The caller expects windows we consider "embedded" to be placed in the 74 // The caller expects windows we consider "embedded" to be placed in the
82 // screen coordinate system. So we need to offset the root window's 75 // screen coordinate system. So we need to offset the root window's
83 // position (which is in screen coordinates) from these bounds. 76 // position (which is in screen coordinates) from these bounds.
77
78 gfx::Point origin = bounds.origin();
79 aura::Window::ConvertPointToTarget(window->parent(), root, &origin);
80
84 gfx::Point host_origin = GetOrigin(root); 81 gfx::Point host_origin = GetOrigin(root);
85 origin.Offset(-host_origin.x(), -host_origin.y()); 82 origin.Offset(-host_origin.x(), -host_origin.y());
86 window->SetBounds(gfx::Rect(origin, bounds.size())); 83 window->SetBounds(gfx::Rect(origin, bounds.size()));
87 return; 84 return;
88 } 85 }
89 86
90 DesktopNativeWidgetAura* desktop_native_widget = 87 DesktopNativeWidgetAura* desktop_native_widget =
91 DesktopNativeWidgetAura::ForWindow(window); 88 DesktopNativeWidgetAura::ForWindow(window);
92 if (desktop_native_widget) { 89 if (desktop_native_widget) {
93 root->SetHostBounds(bounds); 90 root->SetHostBounds(bounds);
94 // Setting bounds of root resizes |window|. 91 // Setting bounds of root resizes |window|.
95 } else { 92 } else {
96 window->SetBounds(bounds); 93 window->SetBounds(bounds);
97 } 94 }
98 } 95 }
99 96
100 } // namespace views 97 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698