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

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: rebase 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 | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/mus/native_widget_mus.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 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 float DesktopWindowTreeHostMus::GetScaleFactor() const { 167 float DesktopWindowTreeHostMus::GetScaleFactor() const {
168 // TODO(sky): GetDisplayNearestWindow() should take a const aura::Window*. 168 // TODO(sky): GetDisplayNearestWindow() should take a const aura::Window*.
169 return display::Screen::GetScreen() 169 return display::Screen::GetScreen()
170 ->GetDisplayNearestWindow(const_cast<aura::Window*>(window())) 170 ->GetDisplayNearestWindow(const_cast<aura::Window*>(window()))
171 .device_scale_factor(); 171 .device_scale_factor();
172 } 172 }
173 173
174 void DesktopWindowTreeHostMus::SetBoundsInDips( 174 void DesktopWindowTreeHostMus::SetBoundsInDips(
175 const gfx::Rect& bounds_in_dips) { 175 const gfx::Rect& bounds_in_dips) {
176 SetBounds(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dips)); 176 SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dips));
177 } 177 }
178 178
179 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 179 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
180 const Widget::InitParams& params) { 180 const Widget::InitParams& params) {
181 if (!params.bounds.IsEmpty()) 181 if (!params.bounds.IsEmpty())
182 SetBoundsInDips(params.bounds); 182 SetBoundsInDips(params.bounds);
183 } 183 }
184 184
185 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( 185 void DesktopWindowTreeHostMus::OnNativeWidgetCreated(
186 const Widget::InitParams& params) { 186 const Widget::InitParams& params) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return window()->IsVisible() && 274 return window()->IsVisible() &&
275 (!parent_ || 275 (!parent_ ||
276 static_cast<const internal::NativeWidgetPrivate*>( 276 static_cast<const internal::NativeWidgetPrivate*>(
277 parent_->desktop_native_widget_aura_) 277 parent_->desktop_native_widget_aura_)
278 ->IsVisible()); 278 ->IsVisible());
279 } 279 }
280 280
281 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) { 281 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) {
282 // Use GetBounds() as the origin of window() is always at 0, 0. 282 // Use GetBounds() as the origin of window() is always at 0, 0.
283 gfx::Rect screen_bounds = 283 gfx::Rect screen_bounds =
284 gfx::ConvertRectToDIP(GetScaleFactor(), GetBounds()); 284 gfx::ConvertRectToDIP(GetScaleFactor(), GetBoundsInPixels());
285 screen_bounds.set_size(size); 285 screen_bounds.set_size(size);
286 SetBoundsInDips(screen_bounds); 286 SetBoundsInDips(screen_bounds);
287 } 287 }
288 288
289 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) { 289 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) {
290 // TODO: implement window stacking, http://crbug.com/663617. 290 // TODO: implement window stacking, http://crbug.com/663617.
291 NOTIMPLEMENTED(); 291 NOTIMPLEMENTED();
292 } 292 }
293 293
294 void DesktopWindowTreeHostMus::StackAtTop() { 294 void DesktopWindowTreeHostMus::StackAtTop() {
(...skipping 22 matching lines...) Expand all
317 317
318 void DesktopWindowTreeHostMus::GetWindowPlacement( 318 void DesktopWindowTreeHostMus::GetWindowPlacement(
319 gfx::Rect* bounds, 319 gfx::Rect* bounds,
320 ui::WindowShowState* show_state) const { 320 ui::WindowShowState* show_state) const {
321 // Implementation matches that of NativeWidgetAura. 321 // Implementation matches that of NativeWidgetAura.
322 *bounds = GetRestoredBounds(); 322 *bounds = GetRestoredBounds();
323 *show_state = window()->GetProperty(aura::client::kShowStateKey); 323 *show_state = window()->GetProperty(aura::client::kShowStateKey);
324 } 324 }
325 325
326 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const { 326 gfx::Rect DesktopWindowTreeHostMus::GetWindowBoundsInScreen() const {
327 return gfx::ConvertRectToDIP(GetScaleFactor(), GetBounds()); 327 return gfx::ConvertRectToDIP(GetScaleFactor(), GetBoundsInPixels());
328 } 328 }
329 329
330 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { 330 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const {
331 // View-to-screen coordinate system transformations depend on this returning 331 // View-to-screen coordinate system transformations depend on this returning
332 // the full window bounds, for example View::ConvertPointToScreen(). 332 // the full window bounds, for example View::ConvertPointToScreen().
333 return GetWindowBoundsInScreen(); 333 return GetWindowBoundsInScreen();
334 } 334 }
335 335
336 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const { 336 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const {
337 // Restored bounds should only be relevant if the window is minimized, 337 // Restored bounds should only be relevant if the window is minimized,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 WindowTreeHostMus::ShowImpl(); 562 WindowTreeHostMus::ShowImpl();
563 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); 563 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true);
564 } 564 }
565 565
566 void DesktopWindowTreeHostMus::HideImpl() { 566 void DesktopWindowTreeHostMus::HideImpl() {
567 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false); 567 native_widget_delegate_->OnNativeWidgetVisibilityChanging(false);
568 WindowTreeHostMus::HideImpl(); 568 WindowTreeHostMus::HideImpl();
569 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); 569 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false);
570 } 570 }
571 571
572 void DesktopWindowTreeHostMus::SetBounds(const gfx::Rect& bounds_in_pixels) { 572 void DesktopWindowTreeHostMus::SetBoundsInPixels(
573 const gfx::Rect& bounds_in_pixels) {
573 gfx::Rect final_bounds_in_pixels = bounds_in_pixels; 574 gfx::Rect final_bounds_in_pixels = bounds_in_pixels;
574 if (GetBounds().size() != bounds_in_pixels.size()) { 575 if (GetBoundsInPixels().size() != bounds_in_pixels.size()) {
575 gfx::Size size = bounds_in_pixels.size(); 576 gfx::Size size = bounds_in_pixels.size();
576 size.SetToMax(gfx::ConvertSizeToPixel( 577 size.SetToMax(gfx::ConvertSizeToPixel(
577 GetScaleFactor(), native_widget_delegate_->GetMinimumSize())); 578 GetScaleFactor(), native_widget_delegate_->GetMinimumSize()));
578 const gfx::Size max_size_in_pixels = gfx::ConvertSizeToPixel( 579 const gfx::Size max_size_in_pixels = gfx::ConvertSizeToPixel(
579 GetScaleFactor(), native_widget_delegate_->GetMaximumSize()); 580 GetScaleFactor(), native_widget_delegate_->GetMaximumSize());
580 if (!max_size_in_pixels.IsEmpty()) 581 if (!max_size_in_pixels.IsEmpty())
581 size.SetToMin(max_size_in_pixels); 582 size.SetToMin(max_size_in_pixels);
582 final_bounds_in_pixels.set_size(size); 583 final_bounds_in_pixels.set_size(size);
583 } 584 }
584 WindowTreeHostMus::SetBounds(final_bounds_in_pixels); 585 WindowTreeHostMus::SetBoundsInPixels(final_bounds_in_pixels);
585 } 586 }
586 587
587 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {} 588 void DesktopWindowTreeHostMus::OnWindowInitialized(aura::Window* window) {}
588 589
589 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged( 590 void DesktopWindowTreeHostMus::OnActiveFocusClientChanged(
590 aura::client::FocusClient* focus_client, 591 aura::client::FocusClient* focus_client,
591 aura::Window* window) { 592 aura::Window* window) {
592 if (window == this->window()) { 593 if (window == this->window()) {
593 is_active_ = true; 594 is_active_ = true;
594 desktop_native_widget_aura_->HandleActivationChanged(true); 595 desktop_native_widget_aura_->HandleActivationChanged(true);
595 } else if (is_active_) { 596 } else if (is_active_) {
596 is_active_ = false; 597 is_active_ = false;
597 desktop_native_widget_aura_->HandleActivationChanged(false); 598 desktop_native_widget_aura_->HandleActivationChanged(false);
598 } 599 }
599 } 600 }
600 601
601 } // namespace views 602 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698