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

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

Issue 10255020: Get the default device scale factor from monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | Annotate | Revision Log
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/monitor_change_observer_x11.h" 5 #include "ui/aura/monitor_change_observer_x11.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool MonitorChangeObserverX11::Dispatch(const base::NativeEvent& event) { 57 bool MonitorChangeObserverX11::Dispatch(const base::NativeEvent& event) {
58 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { 58 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) {
59 NotifyMonitorChange(); 59 NotifyMonitorChange();
60 } 60 }
61 return true; 61 return true;
62 } 62 }
63 63
64 void MonitorChangeObserverX11::NotifyMonitorChange() { 64 void MonitorChangeObserverX11::NotifyMonitorChange() {
65 if (!MonitorManager::use_fullscreen_host_window()) 65 if (!MonitorManager::use_fullscreen_host_window())
66 return; // Use the default monitor that monitor manager determined. 66 return; // Use the default monitor that monitor manager determined.
67 float default_device_scale_factor =
68 Env::GetInstance()->monitor_manager()->default_device_scale_factor();
67 69
68 XRRScreenResources* screen_resources = 70 XRRScreenResources* screen_resources =
69 XRRGetScreenResources(xdisplay_, x_root_window_); 71 XRRGetScreenResources(xdisplay_, x_root_window_);
70 std::map<XID, XRRCrtcInfo*> crtc_info_map; 72 std::map<XID, XRRCrtcInfo*> crtc_info_map;
71 73
72 for (int c = 0; c < screen_resources->ncrtc; c++) { 74 for (int c = 0; c < screen_resources->ncrtc; c++) {
73 XID crtc_id = screen_resources->crtcs[c]; 75 XID crtc_id = screen_resources->crtcs[c];
74 XRRCrtcInfo *crtc_info = 76 XRRCrtcInfo *crtc_info =
75 XRRGetCrtcInfo(xdisplay_, screen_resources, crtc_id); 77 XRRGetCrtcInfo(xdisplay_, screen_resources, crtc_id);
76 crtc_info_map[crtc_id] = crtc_info; 78 crtc_info_map[crtc_id] = crtc_info;
(...skipping 17 matching lines...) Expand all
94 } 96 }
95 XRRModeInfo* mode = FindMode(screen_resources, crtc_info->mode); 97 XRRModeInfo* mode = FindMode(screen_resources, crtc_info->mode);
96 CHECK(mode); 98 CHECK(mode);
97 // Mirrored monitors have the same y coordinates. 99 // Mirrored monitors have the same y coordinates.
98 if (y_coords.find(crtc_info->y) != y_coords.end()) 100 if (y_coords.find(crtc_info->y) != y_coords.end())
99 continue; 101 continue;
100 // TODO(oshima): Create unique ID for the monitor. 102 // TODO(oshima): Create unique ID for the monitor.
101 monitors.push_back(gfx::Monitor( 103 monitors.push_back(gfx::Monitor(
102 0, 104 0,
103 gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height))); 105 gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height)));
106 monitors.back().set_device_scale_factor(default_device_scale_factor);
104 y_coords.insert(crtc_info->y); 107 y_coords.insert(crtc_info->y);
105 XRRFreeOutputInfo(output_info); 108 XRRFreeOutputInfo(output_info);
106 } 109 }
107 110
108 // Free all allocated resources. 111 // Free all allocated resources.
109 for (std::map<XID, XRRCrtcInfo*>::const_iterator iter = crtc_info_map.begin(); 112 for (std::map<XID, XRRCrtcInfo*>::const_iterator iter = crtc_info_map.begin();
110 iter != crtc_info_map.end(); ++iter) { 113 iter != crtc_info_map.end(); ++iter) {
111 XRRFreeCrtcInfo(iter->second); 114 XRRFreeCrtcInfo(iter->second);
112 } 115 }
113 XRRFreeScreenResources(screen_resources); 116 XRRFreeScreenResources(screen_resources);
114 117
115 // PowerManager lays out the outputs vertically. Sort them by Y 118 // PowerManager lays out the outputs vertically. Sort them by Y
116 // coordinates. 119 // coordinates.
117 std::sort(monitors.begin(), monitors.end(), CompareMonitorY); 120 std::sort(monitors.begin(), monitors.end(), CompareMonitorY);
118 // TODO(oshima): Assisgn index as ID for now. Use unique ID. 121 // TODO(oshima): Assisgn index as ID for now. Use unique ID.
119 int id = 0; 122 int id = 0;
120 for (std::vector<gfx::Monitor>::iterator iter = monitors.begin(); 123 for (std::vector<gfx::Monitor>::iterator iter = monitors.begin();
121 iter != monitors.end(); ++iter, ++id) 124 iter != monitors.end(); ++iter, ++id)
122 (*iter).set_id(id); 125 (*iter).set_id(id);
123 126
124 Env::GetInstance()->monitor_manager() 127 Env::GetInstance()->monitor_manager()
125 ->OnNativeMonitorsChanged(monitors); 128 ->OnNativeMonitorsChanged(monitors);
126 } 129 }
127 130
128 } // namespace internal 131 } // namespace internal
129 } // namespace aura 132 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698