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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_screen_x11.cc

Issue 1036263003: hi-dpi: convert _NET_WORKAREA from pixels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hi-dpi: convert _NET_WORKAREA from pixels. Created 5 years, 8 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 | « no previous file | no next file » | 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/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.
11 #undef RootWindow 11 #undef RootWindow
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/aura/window_event_dispatcher.h" 16 #include "ui/aura/window_event_dispatcher.h"
17 #include "ui/aura/window_tree_host.h" 17 #include "ui/aura/window_tree_host.h"
18 #include "ui/base/layout.h" 18 #include "ui/base/layout.h"
19 #include "ui/display/util/display_util.h" 19 #include "ui/display/util/display_util.h"
20 #include "ui/display/util/x11/edid_parser_x11.h" 20 #include "ui/display/util/x11/edid_parser_x11.h"
21 #include "ui/events/platform/platform_event_source.h" 21 #include "ui/events/platform/platform_event_source.h"
22 #include "ui/gfx/display.h" 22 #include "ui/gfx/display.h"
23 #include "ui/gfx/geometry/point_conversions.h"
24 #include "ui/gfx/geometry/size_conversions.h"
23 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
24 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
25 #include "ui/gfx/x/x11_types.h" 27 #include "ui/gfx/x/x11_types.h"
26 #include "ui/views/widget/desktop_aura/desktop_screen.h" 28 #include "ui/views/widget/desktop_aura/desktop_screen.h"
27 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 29 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
28 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" 30 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
29 31
30 namespace { 32 namespace {
31 33
32 // The delay to perform configuration after RRNotify. See the comment 34 // The delay to perform configuration after RRNotify. See the comment
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() { 262 std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
261 std::vector<gfx::Display> displays; 263 std::vector<gfx::Display> displays;
262 XRRScreenResources* resources = 264 XRRScreenResources* resources =
263 XRRGetScreenResourcesCurrent(xdisplay_, x_root_window_); 265 XRRGetScreenResourcesCurrent(xdisplay_, x_root_window_);
264 if (!resources) { 266 if (!resources) {
265 LOG(ERROR) << "XRandR returned no displays. Falling back to Root Window."; 267 LOG(ERROR) << "XRandR returned no displays. Falling back to Root Window.";
266 return GetFallbackDisplayList(); 268 return GetFallbackDisplayList();
267 } 269 }
268 270
269 bool has_work_area = false; 271 bool has_work_area = false;
270 gfx::Rect work_area; 272 gfx::Rect work_area_in_pixels;
271 std::vector<int> value; 273 std::vector<int> value;
272 if (ui::GetIntArrayProperty(x_root_window_, "_NET_WORKAREA", &value) && 274 if (ui::GetIntArrayProperty(x_root_window_, "_NET_WORKAREA", &value) &&
273 value.size() >= 4) { 275 value.size() >= 4) {
274 work_area = gfx::Rect(value[0], value[1], value[2], value[3]); 276 work_area_in_pixels = gfx::Rect(value[0], value[1], value[2], value[3]);
275 has_work_area = true; 277 has_work_area = true;
276 } 278 }
277 279
278 float device_scale_factor = 1.0f; 280 float device_scale_factor = 1.0f;
279 for (int i = 0; i < resources->noutput; ++i) { 281 for (int i = 0; i < resources->noutput; ++i) {
280 RROutput output_id = resources->outputs[i]; 282 RROutput output_id = resources->outputs[i];
281 XRROutputInfo* output_info = 283 XRROutputInfo* output_info =
282 XRRGetOutputInfo(xdisplay_, resources, output_id); 284 XRRGetOutputInfo(xdisplay_, resources, output_id);
283 285
284 bool is_connected = (output_info->connection == RR_Connected); 286 bool is_connected = (output_info->connection == RR_Connected);
(...skipping 23 matching lines...) Expand all
308 // As per display scale factor is not supported right now, 310 // As per display scale factor is not supported right now,
309 // the primary display's scale factor is always used. 311 // the primary display's scale factor is always used.
310 device_scale_factor = GetDeviceScaleFactor(crtc->width, 312 device_scale_factor = GetDeviceScaleFactor(crtc->width,
311 output_info->mm_width); 313 output_info->mm_width);
312 DCHECK_LE(1.0f, device_scale_factor); 314 DCHECK_LE(1.0f, device_scale_factor);
313 } 315 }
314 display.SetScaleAndBounds(device_scale_factor, crtc_bounds); 316 display.SetScaleAndBounds(device_scale_factor, crtc_bounds);
315 } 317 }
316 318
317 if (has_work_area) { 319 if (has_work_area) {
318 gfx::Rect intersection = crtc_bounds; 320 gfx::Rect intersection_in_pixels = crtc_bounds;
319 intersection.Intersect(work_area); 321 intersection_in_pixels.Intersect(work_area_in_pixels);
320 display.set_work_area(intersection); 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.
324 display.set_work_area(gfx::Rect(
325 gfx::ToFlooredPoint(
326 gfx::ScalePoint(intersection_in_pixels.origin(),
327 1.0f / display.device_scale_factor())),
328 gfx::ToFlooredSize(
329 gfx::ScaleSize(intersection_in_pixels.size(),
330 1.0f / display.device_scale_factor()))));
321 } 331 }
322 332
323 switch (crtc->rotation) { 333 switch (crtc->rotation) {
324 case RR_Rotate_0: 334 case RR_Rotate_0:
325 display.set_rotation(gfx::Display::ROTATE_0); 335 display.set_rotation(gfx::Display::ROTATE_0);
326 break; 336 break;
327 case RR_Rotate_90: 337 case RR_Rotate_90:
328 display.set_rotation(gfx::Display::ROTATE_90); 338 display.set_rotation(gfx::Display::ROTATE_90);
329 break; 339 break;
330 case RR_Rotate_180: 340 case RR_Rotate_180:
(...skipping 27 matching lines...) Expand all
358 change_notifier_.NotifyDisplaysChanged(old_displays, displays_); 368 change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
359 } 369 }
360 370
361 //////////////////////////////////////////////////////////////////////////////// 371 ////////////////////////////////////////////////////////////////////////////////
362 372
363 gfx::Screen* CreateDesktopScreen() { 373 gfx::Screen* CreateDesktopScreen() {
364 return new DesktopScreenX11; 374 return new DesktopScreenX11;
365 } 375 }
366 376
367 } // namespace views 377 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698