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

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

Issue 2583873002: Correctly update the popup window position (Closed)
Patch Set: use content_window_ Created 4 years 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | no next file » | 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/views/widget/desktop_aura/desktop_native_widget_aura.h" 7 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
8 8
9 namespace views { 9 namespace views {
10 10
(...skipping 20 matching lines...) Expand all
31 DesktopScreenPositionClient::~DesktopScreenPositionClient() { 31 DesktopScreenPositionClient::~DesktopScreenPositionClient() {
32 aura::client::SetScreenPositionClient(root_window_, NULL); 32 aura::client::SetScreenPositionClient(root_window_, NULL);
33 } 33 }
34 34
35 void DesktopScreenPositionClient::SetBounds(aura::Window* window, 35 void DesktopScreenPositionClient::SetBounds(aura::Window* window,
36 const gfx::Rect& bounds, 36 const gfx::Rect& bounds,
37 const display::Display& display) { 37 const display::Display& display) {
38 // TODO(jam): Use the 3rd parameter, |display|. 38 // TODO(jam): Use the 3rd parameter, |display|.
39 aura::Window* root = window->GetRootWindow(); 39 aura::Window* root = window->GetRootWindow();
40 40
41 // This method assumes that |window| does not have an associated
42 // DesktopNativeWidgetAura.
43 internal::NativeWidgetPrivate* desktop_native_widget = 41 internal::NativeWidgetPrivate* desktop_native_widget =
44 DesktopNativeWidgetAura::ForWindow(root); 42 DesktopNativeWidgetAura::ForWindow(root);
43 // The screen bounds request to the content_window_ should be interpreted as
44 // a widget bounds change.
45 if (desktop_native_widget &&
46 desktop_native_widget->GetNativeView() == window) {
47 desktop_native_widget->GetWidget()->SetBounds(bounds);
48 return;
sadrul 2016/12/19 18:08:56 It looks like DesktopNativeWidgetAura::OnBoundsCha
oshima 2016/12/20 23:55:32 Did you mean DesktopNativeWidgetTopLevelHandler::O
49 }
50 // The following logic assumes that |window| does not have an associated
51 // DesktopNativeWidgetAura.
Bret 2016/12/21 00:04:25 nit: since you're explicitly handling the dchecked
45 DCHECK(!desktop_native_widget || 52 DCHECK(!desktop_native_widget ||
46 desktop_native_widget->GetNativeView() != window); 53 desktop_native_widget->GetNativeView() != window);
47 54
48 if (PositionWindowInScreenCoordinates(window)) { 55 if (PositionWindowInScreenCoordinates(window)) {
49 // The caller expects windows we consider "embedded" to be placed in the 56 // The caller expects windows we consider "embedded" to be placed in the
50 // screen coordinate system. So we need to offset the root window's 57 // screen coordinate system. So we need to offset the root window's
51 // position (which is in screen coordinates) from these bounds. 58 // position (which is in screen coordinates) from these bounds.
52 59
53 gfx::Point origin = bounds.origin(); 60 gfx::Point origin = bounds.origin();
54 aura::Window::ConvertPointToTarget(window->parent(), root, &origin); 61 aura::Window::ConvertPointToTarget(window->parent(), root, &origin);
55 62
56 gfx::Point host_origin = GetOriginInScreen(root); 63 gfx::Point host_origin = GetOriginInScreen(root);
57 origin.Offset(-host_origin.x(), -host_origin.y()); 64 origin.Offset(-host_origin.x(), -host_origin.y());
58 window->SetBounds(gfx::Rect(origin, bounds.size())); 65 window->SetBounds(gfx::Rect(origin, bounds.size()));
59 return; 66 return;
60 } 67 }
61 68
62 window->SetBounds(bounds); 69 window->SetBounds(bounds);
63 } 70 }
64 71
65 } // namespace views 72 } // namespace views
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698