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

Side by Side Diff: ui/views/mus/desktop_window_tree_host_mus.cc

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mus/desktop_window_tree_host_mus.h" 5 #include "ui/views/mus/desktop_window_tree_host_mus.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ui/aura/client/aura_constants.h" 8 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/drag_drop_client.h" 9 #include "ui/aura/client/drag_drop_client.h"
10 #include "ui/aura/client/focus_client.h" 10 #include "ui/aura/client/focus_client.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 bool DesktopWindowTreeHostMus::IsDocked() const { 45 bool DesktopWindowTreeHostMus::IsDocked() const {
46 return window()->GetProperty(aura::client::kShowStateKey) == 46 return window()->GetProperty(aura::client::kShowStateKey) ==
47 ui::SHOW_STATE_DOCKED; 47 ui::SHOW_STATE_DOCKED;
48 } 48 }
49 49
50 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 50 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
51 const Widget::InitParams& params) { 51 const Widget::InitParams& params) {
52 // TODO: handle device scale, http://crbug.com/663524. 52 // TODO: handle device scale, http://crbug.com/663524.
53 if (!params.bounds.IsEmpty()) 53 if (!params.bounds.IsEmpty())
54 SetBounds(params.bounds); 54 SetBoundsInPixel(params.bounds);
55 } 55 }
56 56
57 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( 57 void DesktopWindowTreeHostMus::OnNativeWidgetCreated(
58 const Widget::InitParams& params) { 58 const Widget::InitParams& params) {
59 if (params.parent && params.parent->GetHost()) { 59 if (params.parent && params.parent->GetHost()) {
60 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); 60 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost());
61 parent_->children_.insert(this); 61 parent_->children_.insert(this);
62 } 62 }
63 native_widget_delegate_->OnNativeWidgetCreated(true); 63 native_widget_delegate_->OnNativeWidgetCreated(true);
64 } 64 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // aura::Window. 145 // aura::Window.
146 return window()->IsVisible() && 146 return window()->IsVisible() &&
147 (!parent_ || 147 (!parent_ ||
148 static_cast<const internal::NativeWidgetPrivate*>( 148 static_cast<const internal::NativeWidgetPrivate*>(
149 parent_->desktop_native_widget_aura_) 149 parent_->desktop_native_widget_aura_)
150 ->IsVisible()); 150 ->IsVisible());
151 } 151 }
152 152
153 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) { 153 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) {
154 // Use GetBounds() as the origin of window() is always at 0, 0. 154 // Use GetBounds() as the origin of window() is always at 0, 0.
155 gfx::Rect screen_bounds = GetBounds(); 155 gfx::Rect screen_bounds = GetBoundsInPixel();
156 // TODO: handle device scale, http://crbug.com/663524. Also, |screen_bounds| 156 // TODO: handle device scale, http://crbug.com/663524. Also, |screen_bounds|
157 // is in pixels and should be dip. 157 // is in pixels and should be dip.
158 screen_bounds.set_size(size); 158 screen_bounds.set_size(size);
159 SetBounds(screen_bounds); 159 SetBoundsInPixel(screen_bounds);
160 } 160 }
161 161
162 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) { 162 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) {
163 // TODO: implement window stacking, http://crbug.com/663617. 163 // TODO: implement window stacking, http://crbug.com/663617.
164 NOTIMPLEMENTED(); 164 NOTIMPLEMENTED();
165 } 165 }
166 166
167 void DesktopWindowTreeHostMus::StackAtTop() { 167 void DesktopWindowTreeHostMus::StackAtTop() {
168 // TODO: implement window stacking, http://crbug.com/663617. 168 // TODO: implement window stacking, http://crbug.com/663617.
169 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
170 } 170 }
171 171
172 void DesktopWindowTreeHostMus::CenterWindow(const gfx::Size& size) { 172 void DesktopWindowTreeHostMus::CenterWindow(const gfx::Size& size) {
173 gfx::Rect bounds_to_center_in = GetWorkAreaBoundsInScreen(); 173 gfx::Rect bounds_to_center_in = GetWorkAreaBoundsInScreen();
174 174
175 // If there is a transient parent and it fits |size|, then center over it. 175 // If there is a transient parent and it fits |size|, then center over it.
176 aura::Window* content_window = desktop_native_widget_aura_->content_window(); 176 aura::Window* content_window = desktop_native_widget_aura_->content_window();
177 if (wm::GetTransientParent(content_window)) { 177 if (wm::GetTransientParent(content_window)) {
178 gfx::Rect transient_parent_bounds = 178 gfx::Rect transient_parent_bounds =
179 wm::GetTransientParent(content_window)->GetBoundsInScreen(); 179 wm::GetTransientParent(content_window)->GetBoundsInScreen();
180 if (transient_parent_bounds.height() >= size.height() && 180 if (transient_parent_bounds.height() >= size.height() &&
181 transient_parent_bounds.width() >= size.width()) { 181 transient_parent_bounds.width() >= size.width()) {
182 bounds_to_center_in = transient_parent_bounds; 182 bounds_to_center_in = transient_parent_bounds;
183 } 183 }
184 } 184 }
185 185
186 gfx::Rect resulting_bounds(bounds_to_center_in); 186 gfx::Rect resulting_bounds(bounds_to_center_in);
187 resulting_bounds.ClampToCenteredSize(size); 187 resulting_bounds.ClampToCenteredSize(size);
188 188
189 // TODO: handle device scale, http://crbug.com/663524. SetBounds() expects 189 // TODO: handle device scale, http://crbug.com/663524. SetBoundsInPixel()
190 // pixels. 190 // expects pixels.
191 SetBounds(resulting_bounds); 191 SetBoundsInPixel(resulting_bounds);
192 } 192 }
193 193
194 void DesktopWindowTreeHostMus::GetWindowPlacement( 194 void DesktopWindowTreeHostMus::GetWindowPlacement(
195 gfx::Rect* bounds, 195 gfx::Rect* bounds,
196 ui::WindowShowState* show_state) const { 196 ui::WindowShowState* show_state) const {
197 // Implementation matches that of NativeWidgetAura. 197 // Implementation matches that of NativeWidgetAura.
198 *bounds = GetRestoredBounds(); 198 *bounds = GetRestoredBounds();
199 *show_state = window()->GetProperty(aura::client::kShowStateKey); 199 *show_state = window()->GetProperty(aura::client::kShowStateKey);
200 } 200 }
201 201
202 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const { 202 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const {
203 // TODO: convert to dips, http://crbug.com/663524. 203 // TODO: convert to dips, http://crbug.com/663524.
204 return GetBounds(); 204 return GetBoundsInPixel();
205 } 205 }
206 206
207 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { 207 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const {
208 // View-to-screen coordinate system transformations depend on this returning 208 // View-to-screen coordinate system transformations depend on this returning
209 // the full window bounds, for example View::ConvertPointToScreen(). 209 // the full window bounds, for example View::ConvertPointToScreen().
210 return GetWindowBoundsInScreen(); 210 return GetWindowBoundsInScreen();
211 } 211 }
212 212
213 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const { 213 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const {
214 // Restored bounds should only be relevant if the window is minimized, 214 // Restored bounds should only be relevant if the window is minimized,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 WindowTreeHostMus::ShowImpl(); 423 WindowTreeHostMus::ShowImpl();
424 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); 424 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true);
425 } 425 }
426 426
427 void DesktopWindowTreeHostMus::HideImpl() { 427 void DesktopWindowTreeHostMus::HideImpl() {
428 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); 428 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false);
429 WindowTreeHostMus::HideImpl(); 429 WindowTreeHostMus::HideImpl();
430 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); 430 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false);
431 } 431 }
432 432
433 void DesktopWindowTreeHostMus::SetBounds(const gfx::Rect& bounds_in_pixels) { 433 void DesktopWindowTreeHostMus::SetBoundsInPixel(
434 const gfx::Rect& bounds_in_pixels) {
434 // TODO: handle conversion to dips, http://crbug.com/663524. 435 // TODO: handle conversion to dips, http://crbug.com/663524.
435 gfx::Rect final_bounds_in_pixels = bounds_in_pixels; 436 gfx::Rect final_bounds_in_pixels = bounds_in_pixels;
436 if (GetBounds().size() != bounds_in_pixels.size()) { 437 if (GetBoundsInPixel().size() != bounds_in_pixels.size()) {
437 gfx::Size size = bounds_in_pixels.size(); 438 gfx::Size size = bounds_in_pixels.size();
438 size.SetToMax(native_widget_delegate_->GetMinimumSize()); 439 size.SetToMax(native_widget_delegate_->GetMinimumSize());
439 const gfx::Size max_size = native_widget_delegate_->GetMaximumSize(); 440 const gfx::Size max_size = native_widget_delegate_->GetMaximumSize();
440 if (!max_size.IsEmpty()) 441 if (!max_size.IsEmpty())
441 size.SetToMin(max_size); 442 size.SetToMin(max_size);
442 final_bounds_in_pixels.set_size(size); 443 final_bounds_in_pixels.set_size(size);
443 } 444 }
444 WindowTreeHostMus::SetBounds(final_bounds_in_pixels); 445 WindowTreeHostMus::SetBoundsInPixel(final_bounds_in_pixels);
445 } 446 }
446 447
447 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} 448 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {}
448 449
449 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( 450 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged(
450 aura::client::FocusClient* focus_client, 451 aura::client::FocusClient* focus_client,
451 aura::Window* window) { 452 aura::Window* window) {
452 if (window == this->window()) { 453 if (window == this->window()) {
453 is_active_ = true; 454 is_active_ = true;
454 desktop_native_widget_aura_->HandleActivationChanged(true); 455 desktop_native_widget_aura_->HandleActivationChanged(true);
455 } else if (is_active_) { 456 } else if (is_active_) {
456 is_active_ = false; 457 is_active_ = false;
457 desktop_native_widget_aura_->HandleActivationChanged(false); 458 desktop_native_widget_aura_->HandleActivationChanged(false);
458 } 459 }
459 } 460 }
460 461
461 } // namespace views 462 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698