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

Side by Side Diff: ui/aura/window_tree_host_x11.cc

Issue 2739113002: Simplify calls for scale factor (Closed)
Patch Set: nit Created 3 years, 9 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
« no previous file with comments | « ui/aura/window_tree_host_platform.cc ('k') | ui/base/layout.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/aura/window_tree_host_x11.h" 5 #include "ui/aura/window_tree_host_x11.h"
6 6
7 #include <strings.h> 7 #include <strings.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/extensions/Xrandr.h> 10 #include <X11/extensions/Xrandr.h>
(...skipping 13 matching lines...) Expand all
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
26 #include "base/sys_info.h" 26 #include "base/sys_info.h"
27 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
28 #include "build/build_config.h" 28 #include "build/build_config.h"
29 #include "ui/aura/client/cursor_client.h" 29 #include "ui/aura/client/cursor_client.h"
30 #include "ui/aura/env.h" 30 #include "ui/aura/env.h"
31 #include "ui/aura/window.h" 31 #include "ui/aura/window.h"
32 #include "ui/aura/window_event_dispatcher.h" 32 #include "ui/aura/window_event_dispatcher.h"
33 #include "ui/base/cursor/cursor.h" 33 #include "ui/base/cursor/cursor.h"
34 #include "ui/base/layout.h"
34 #include "ui/base/platform_window_defaults.h" 35 #include "ui/base/platform_window_defaults.h"
35 #include "ui/base/ui_base_switches.h" 36 #include "ui/base/ui_base_switches.h"
36 #include "ui/base/view_prop.h" 37 #include "ui/base/view_prop.h"
37 #include "ui/base/x/x11_util.h" 38 #include "ui/base/x/x11_util.h"
38 #include "ui/base/x/x11_window_event_manager.h" 39 #include "ui/base/x/x11_window_event_manager.h"
39 #include "ui/compositor/compositor.h" 40 #include "ui/compositor/compositor.h"
40 #include "ui/compositor/dip_util.h" 41 #include "ui/compositor/dip_util.h"
41 #include "ui/compositor/layer.h" 42 #include "ui/compositor/layer.h"
42 #include "ui/display/screen.h" 43 #include "ui/display/screen.h"
43 #include "ui/events/devices/x11/device_data_manager_x11.h" 44 #include "ui/events/devices/x11/device_data_manager_x11.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 397 }
397 398
398 gfx::Rect WindowTreeHostX11::GetBoundsInPixels() const { 399 gfx::Rect WindowTreeHostX11::GetBoundsInPixels() const {
399 return bounds_; 400 return bounds_;
400 } 401 }
401 402
402 void WindowTreeHostX11::SetBoundsInPixels(const gfx::Rect& bounds) { 403 void WindowTreeHostX11::SetBoundsInPixels(const gfx::Rect& bounds) {
403 // Even if the host window's size doesn't change, aura's root window 404 // Even if the host window's size doesn't change, aura's root window
404 // size, which is in DIP, changes when the scale changes. 405 // size, which is in DIP, changes when the scale changes.
405 float current_scale = compositor()->device_scale_factor(); 406 float current_scale = compositor()->device_scale_factor();
406 float new_scale = display::Screen::GetScreen() 407 float new_scale = ui::GetScaleFactorForNativeView(window());
407 ->GetDisplayNearestWindow(window())
408 .device_scale_factor();
409 bool origin_changed = bounds_.origin() != bounds.origin(); 408 bool origin_changed = bounds_.origin() != bounds.origin();
410 bool size_changed = bounds_.size() != bounds.size(); 409 bool size_changed = bounds_.size() != bounds.size();
411 XWindowChanges changes = {0}; 410 XWindowChanges changes = {0};
412 unsigned value_mask = 0; 411 unsigned value_mask = 0;
413 412
414 if (size_changed) { 413 if (size_changed) {
415 changes.width = bounds.width(); 414 changes.width = bounds.width();
416 changes.height = bounds.height(); 415 changes.height = bounds.height();
417 value_mask = CWHeight | CWWidth; 416 value_mask = CWHeight | CWWidth;
418 } 417 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 ui::LocatedEvent* event) { 567 ui::LocatedEvent* event) {
569 SendEventToProcessor(event); 568 SendEventToProcessor(event);
570 } 569 }
571 570
572 // static 571 // static
573 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds_in_pixels) { 572 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds_in_pixels) {
574 return new WindowTreeHostX11(bounds_in_pixels); 573 return new WindowTreeHostX11(bounds_in_pixels);
575 } 574 }
576 575
577 } // namespace aura 576 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_platform.cc ('k') | ui/base/layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698