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

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

Issue 2525113002: Rename WindowTreeHost functions to indicate pixels/dips. (Closed)
Patch Set: win 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/drop_target_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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 SetHitTestMask(mask_rect); 164 SetHitTestMask(mask_rect);
165 } 165 }
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::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) {
175 const gfx::Rect& bounds_in_dips) { 175 SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip));
176 SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dips));
177 } 176 }
178 177
179 void DesktopWindowTreeHostMus::Init(aura::Window* content_window, 178 void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
180 const Widget::InitParams& params) { 179 const Widget::InitParams& params) {
181 if (!params.bounds.IsEmpty()) 180 if (!params.bounds.IsEmpty())
182 SetBoundsInDips(params.bounds); 181 SetBoundsInDIP(params.bounds);
183 } 182 }
184 183
185 void DesktopWindowTreeHostMus::OnNativeWidgetCreated( 184 void DesktopWindowTreeHostMus::OnNativeWidgetCreated(
186 const Widget::InitParams& params) { 185 const Widget::InitParams& params) {
187 if (params.parent && params.parent->GetHost()) { 186 if (params.parent && params.parent->GetHost()) {
188 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost()); 187 parent_ = static_cast<DesktopWindowTreeHostMus*>(params.parent->GetHost());
189 parent_->children_.insert(this); 188 parent_->children_.insert(this);
190 } 189 }
191 native_widget_delegate_->OnNativeWidgetCreated(true); 190 native_widget_delegate_->OnNativeWidgetCreated(true);
192 } 191 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 static_cast<const internal::NativeWidgetPrivate*>( 275 static_cast<const internal::NativeWidgetPrivate*>(
277 parent_->desktop_native_widget_aura_) 276 parent_->desktop_native_widget_aura_)
278 ->IsVisible()); 277 ->IsVisible());
279 } 278 }
280 279
281 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) { 280 void DesktopWindowTreeHostMus::SetSize(const gfx::Size& size) {
282 // Use GetBounds() as the origin of window() is always at 0, 0. 281 // Use GetBounds() as the origin of window() is always at 0, 0.
283 gfx::Rect screen_bounds = 282 gfx::Rect screen_bounds =
284 gfx::ConvertRectToDIP(GetScaleFactor(), GetBoundsInPixels()); 283 gfx::ConvertRectToDIP(GetScaleFactor(), GetBoundsInPixels());
285 screen_bounds.set_size(size); 284 screen_bounds.set_size(size);
286 SetBoundsInDips(screen_bounds); 285 SetBoundsInDIP(screen_bounds);
287 } 286 }
288 287
289 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) { 288 void DesktopWindowTreeHostMus::StackAbove(aura::Window* window) {
290 // TODO: implement window stacking, http://crbug.com/663617. 289 // TODO: implement window stacking, http://crbug.com/663617.
291 NOTIMPLEMENTED(); 290 NOTIMPLEMENTED();
292 } 291 }
293 292
294 void DesktopWindowTreeHostMus::StackAtTop() { 293 void DesktopWindowTreeHostMus::StackAtTop() {
295 // TODO: implement window stacking, http://crbug.com/663617. 294 // TODO: implement window stacking, http://crbug.com/663617.
296 NOTIMPLEMENTED(); 295 NOTIMPLEMENTED();
297 } 296 }
298 297
299 void DesktopWindowTreeHostMus::CenterWindow(const gfx::Size& size) { 298 void DesktopWindowTreeHostMus::CenterWindow(const gfx::Size& size) {
300 gfx::Rect bounds_to_center_in = GetWorkAreaBoundsInScreen(); 299 gfx::Rect bounds_to_center_in = GetWorkAreaBoundsInScreen();
301 300
302 // If there is a transient parent and it fits |size|, then center over it. 301 // If there is a transient parent and it fits |size|, then center over it.
303 aura::Window* content_window = desktop_native_widget_aura_->content_window(); 302 aura::Window* content_window = desktop_native_widget_aura_->content_window();
304 if (wm::GetTransientParent(content_window)) { 303 if (wm::GetTransientParent(content_window)) {
305 gfx::Rect transient_parent_bounds = 304 gfx::Rect transient_parent_bounds =
306 wm::GetTransientParent(content_window)->GetBoundsInScreen(); 305 wm::GetTransientParent(content_window)->GetBoundsInScreen();
307 if (transient_parent_bounds.height() >= size.height() && 306 if (transient_parent_bounds.height() >= size.height() &&
308 transient_parent_bounds.width() >= size.width()) { 307 transient_parent_bounds.width() >= size.width()) {
309 bounds_to_center_in = transient_parent_bounds; 308 bounds_to_center_in = transient_parent_bounds;
310 } 309 }
311 } 310 }
312 311
313 gfx::Rect resulting_bounds(bounds_to_center_in); 312 gfx::Rect resulting_bounds(bounds_to_center_in);
314 resulting_bounds.ClampToCenteredSize(size); 313 resulting_bounds.ClampToCenteredSize(size);
315 SetBoundsInDips(resulting_bounds); 314 SetBoundsInDIP(resulting_bounds);
316 } 315 }
317 316
318 void DesktopWindowTreeHostMus::GetWindowPlacement( 317 void DesktopWindowTreeHostMus::GetWindowPlacement(
319 gfx::Rect* bounds, 318 gfx::Rect* bounds,
320 ui::WindowShowState* show_state) const { 319 ui::WindowShowState* show_state) const {
321 // Implementation matches that of NativeWidgetAura. 320 // Implementation matches that of NativeWidgetAura.
322 *bounds = GetRestoredBounds(); 321 *bounds = GetRestoredBounds();
323 *show_state = window()->GetProperty(aura::client::kShowStateKey); 322 *show_state = window()->GetProperty(aura::client::kShowStateKey);
324 } 323 }
325 324
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 if (window == this->window()) { 592 if (window == this->window()) {
594 is_active_ = true; 593 is_active_ = true;
595 desktop_native_widget_aura_->HandleActivationChanged(true); 594 desktop_native_widget_aura_->HandleActivationChanged(true);
596 } else if (is_active_) { 595 } else if (is_active_) {
597 is_active_ = false; 596 is_active_ = false;
598 desktop_native_widget_aura_->HandleActivationChanged(false); 597 desktop_native_widget_aura_->HandleActivationChanged(false);
599 } 598 }
600 } 599 }
601 600
602 } // namespace views 601 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.h ('k') | ui/views/mus/drop_target_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698