| OLD | NEW |
| 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_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/Xrandr.h> | 7 #include <X11/extensions/Xrandr.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 // It clashes with out RootWindow. | 10 // It clashes with out RootWindow. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 double GetDeviceScaleFactor() { | 39 double GetDeviceScaleFactor() { |
| 40 float device_scale_factor = 1.0f; | 40 float device_scale_factor = 1.0f; |
| 41 if (views::LinuxUI::instance()) | 41 if (views::LinuxUI::instance()) |
| 42 device_scale_factor = | 42 device_scale_factor = |
| 43 views::LinuxUI::instance()->GetDeviceScaleFactor(); | 43 views::LinuxUI::instance()->GetDeviceScaleFactor(); |
| 44 return device_scale_factor; | 44 return device_scale_factor; |
| 45 } | 45 } |
| 46 | 46 |
| 47 gfx::Point PixelToDIPPoint(const gfx::Point& pixel_point) { | 47 gfx::Point PixelToDIPPoint(const gfx::Point& pixel_point) { |
| 48 return ToFlooredPoint(ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor())); | 48 return gfx::ScaleToFlooredPoint(pixel_point, 1.0f / GetDeviceScaleFactor()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) { | 51 gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) { |
| 52 return ToFlooredPoint(gfx::ScalePoint(dip_point, GetDeviceScaleFactor())); | 52 return gfx::ScaleToFlooredPoint(dip_point, GetDeviceScaleFactor()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 std::vector<gfx::Display> GetFallbackDisplayList() { | 55 std::vector<gfx::Display> GetFallbackDisplayList() { |
| 56 ::XDisplay* display = gfx::GetXDisplay(); | 56 ::XDisplay* display = gfx::GetXDisplay(); |
| 57 ::Screen* screen = DefaultScreenOfDisplay(display); | 57 ::Screen* screen = DefaultScreenOfDisplay(display); |
| 58 int width = WidthOfScreen(screen); | 58 int width = WidthOfScreen(screen); |
| 59 int height = HeightOfScreen(screen); | 59 int height = HeightOfScreen(screen); |
| 60 gfx::Size physical_size(WidthMMOfScreen(screen), HeightMMOfScreen(screen)); | 60 gfx::Size physical_size(WidthMMOfScreen(screen), HeightMMOfScreen(screen)); |
| 61 | 61 |
| 62 gfx::Rect bounds_in_pixels(0, 0, width, height); | 62 gfx::Rect bounds_in_pixels(0, 0, width, height); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (!gfx::Display::HasForceDeviceScaleFactor()) { | 315 if (!gfx::Display::HasForceDeviceScaleFactor()) { |
| 316 display.SetScaleAndBounds(device_scale_factor, crtc_bounds); | 316 display.SetScaleAndBounds(device_scale_factor, crtc_bounds); |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (has_work_area) { | 319 if (has_work_area) { |
| 320 gfx::Rect intersection_in_pixels = crtc_bounds; | 320 gfx::Rect intersection_in_pixels = crtc_bounds; |
| 321 intersection_in_pixels.Intersect(work_area_in_pixels); | 321 intersection_in_pixels.Intersect(work_area_in_pixels); |
| 322 // SetScaleAndBounds() above does the conversion from pixels to DIP for | 322 // SetScaleAndBounds() above does the conversion from pixels to DIP for |
| 323 // us, but set_work_area does not, so we need to do it here. | 323 // us, but set_work_area does not, so we need to do it here. |
| 324 display.set_work_area(gfx::Rect( | 324 display.set_work_area(gfx::Rect( |
| 325 gfx::ToFlooredPoint( | 325 gfx::ScaleToFlooredPoint(intersection_in_pixels.origin(), |
| 326 gfx::ScalePoint(intersection_in_pixels.origin(), | 326 1.0f / display.device_scale_factor()), |
| 327 1.0f / display.device_scale_factor())), | |
| 328 gfx::ScaleToFlooredSize(intersection_in_pixels.size(), | 327 gfx::ScaleToFlooredSize(intersection_in_pixels.size(), |
| 329 1.0f / display.device_scale_factor()))); | 328 1.0f / display.device_scale_factor()))); |
| 330 } | 329 } |
| 331 | 330 |
| 332 switch (crtc->rotation) { | 331 switch (crtc->rotation) { |
| 333 case RR_Rotate_0: | 332 case RR_Rotate_0: |
| 334 display.set_rotation(gfx::Display::ROTATE_0); | 333 display.set_rotation(gfx::Display::ROTATE_0); |
| 335 break; | 334 break; |
| 336 case RR_Rotate_90: | 335 case RR_Rotate_90: |
| 337 display.set_rotation(gfx::Display::ROTATE_90); | 336 display.set_rotation(gfx::Display::ROTATE_90); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 361 change_notifier_.NotifyDisplaysChanged(old_displays, displays_); | 360 change_notifier_.NotifyDisplaysChanged(old_displays, displays_); |
| 362 } | 361 } |
| 363 | 362 |
| 364 //////////////////////////////////////////////////////////////////////////////// | 363 //////////////////////////////////////////////////////////////////////////////// |
| 365 | 364 |
| 366 gfx::Screen* CreateDesktopScreen() { | 365 gfx::Screen* CreateDesktopScreen() { |
| 367 return new DesktopScreenX11; | 366 return new DesktopScreenX11; |
| 368 } | 367 } |
| 369 | 368 |
| 370 } // namespace views | 369 } // namespace views |
| OLD | NEW |