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 cr.exportPath('options'); | 5 cr.exportPath('options'); |
6 | 6 |
7 /** | 7 /** |
8 * @typedef {{ | 8 * @typedef {{ |
9 * availableColorProfiles: Array<{profileId: number, name: string}>, | 9 * availableColorProfiles: Array<{profileId: number, name: string}>, |
10 * colorProfile: number, | 10 * colorProfile: number, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 | 109 |
110 DisplayOptions.prototype = { | 110 DisplayOptions.prototype = { |
111 __proto__: Page.prototype, | 111 __proto__: Page.prototype, |
112 | 112 |
113 /** | 113 /** |
114 * Whether the current output status is mirroring displays or not. | 114 * Whether the current output status is mirroring displays or not. |
115 * @private | 115 * @private |
116 */ | 116 */ |
117 mirroring_: false, | 117 mirroring_: false, |
118 | 118 |
119 /* | |
120 * Whether the unified desktop is enable or not. | |
121 * @private | |
122 */ | |
123 unified_desktop_enabled_: false, | |
124 | |
125 /* | |
126 * Whether the unified desktop option should be present. | |
127 * @private | |
128 */ | |
129 show_unified_desktop_option_: false, | |
130 | |
119 /** | 131 /** |
120 * The current secondary display layout. | 132 * The current secondary display layout. |
121 * @private | 133 * @private |
122 */ | 134 */ |
123 layout_: options.SecondaryDisplayLayout.RIGHT, | 135 layout_: options.SecondaryDisplayLayout.RIGHT, |
124 | 136 |
125 /** | 137 /** |
126 * The array of current output displays. It also contains the display | 138 * The array of current output displays. It also contains the display |
127 * rectangles currently rendered on screen. | 139 * rectangles currently rendered on screen. |
128 * @type {Array<options.DisplayInfo>} | 140 * @type {Array<options.DisplayInfo>} |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 var displayOverscan = options.DisplayOverscan.getInstance(); | 225 var displayOverscan = options.DisplayOverscan.getInstance(); |
214 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); | 226 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); |
215 PageManager.showPageByName('displayOverscan'); | 227 PageManager.showPageByName('displayOverscan'); |
216 chrome.send('coreOptionsUserMetricsAction', | 228 chrome.send('coreOptionsUserMetricsAction', |
217 ['Options_DisplaySetOverscan']); | 229 ['Options_DisplaySetOverscan']); |
218 }).bind(this); | 230 }).bind(this); |
219 | 231 |
220 $('display-options-done').onclick = function() { | 232 $('display-options-done').onclick = function() { |
221 PageManager.closeOverlay(); | 233 PageManager.closeOverlay(); |
222 }; | 234 }; |
235 | |
236 $('display-options-toggle-unified-desktop').onclick = (function() { | |
237 this.unified_desktop_enabled_ = !this.unified_desktop_enabled_; | |
238 chrome.send('setUnifiedDesktopEnabled', | |
239 [this.unified_desktop_enabled_]); | |
240 }).bind(this); | |
223 }, | 241 }, |
224 | 242 |
225 /** @override */ | 243 /** @override */ |
226 didShowPage: function() { | 244 didShowPage: function() { |
227 var optionTitles = document.getElementsByClassName( | 245 var optionTitles = document.getElementsByClassName( |
228 'selected-display-option-title'); | 246 'selected-display-option-title'); |
229 var maxSize = 0; | 247 var maxSize = 0; |
230 for (var i = 0; i < optionTitles.length; i++) | 248 for (var i = 0; i < optionTitles.length; i++) |
231 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); | 249 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); |
232 for (var i = 0; i < optionTitles.length; i++) | 250 for (var i = 0; i < optionTitles.length; i++) |
233 optionTitles[i].style.width = maxSize + 'px'; | 251 optionTitles[i].style.width = maxSize + 'px'; |
234 chrome.send('getDisplayInfo'); | 252 chrome.send('getDisplayInfo'); |
235 }, | 253 }, |
236 | 254 |
237 /** @override */ | 255 /** @override */ |
238 canShowPage: function() { | 256 canShowPage: function() { |
239 return this.enabled_; | 257 return this.enabled_; |
240 }, | 258 }, |
241 | 259 |
242 /** | 260 /** |
243 * Enables or disables the page. When disabled, the page will not be able to | 261 * Enables or disables the page. When disabled, the page will not be able to |
244 * open, and will close if currently opened. | 262 * open, and will close if currently opened. |
245 * @param {boolean} enabled Whether the page should be enabled. | 263 * @param {boolean} enabled Whether the page should be enabled. |
264 * @param {boolean} showUnifiedDesktop Whether the unified desktop option | |
265 * should be present. | |
246 */ | 266 */ |
247 setEnabled: function(enabled) { | 267 setEnabled: function(enabled, showUnifiedDesktop) { |
248 if (this.enabled_ == enabled) | 268 if (this.enabled_ == enabled && |
269 this.show_unified_desktop_option_ == showUnifiedDesktop) { | |
Jun Mukai
2015/05/20 02:47:49
name should be camelcased. showUnifiedDesktopOptio
oshima
2015/05/20 06:40:01
Done.
| |
249 return; | 270 return; |
271 } | |
250 this.enabled_ = enabled; | 272 this.enabled_ = enabled; |
273 this.show_unified_desktop_option_ = showUnifiedDesktop; | |
251 if (!enabled && this.visible) | 274 if (!enabled && this.visible) |
252 PageManager.closeOverlay(); | 275 PageManager.closeOverlay(); |
253 }, | 276 }, |
254 | 277 |
255 /** | 278 /** |
256 * Mouse move handler for dragging display rectangle. | 279 * Mouse move handler for dragging display rectangle. |
257 * @param {Event} e The mouse move event. | 280 * @param {Event} e The mouse move event. |
258 * @private | 281 * @private |
259 */ | 282 */ |
260 onMouseMove_: function(e) { | 283 onMouseMove_: function(e) { |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 offset.y + 'px'; | 947 offset.y + 'px'; |
925 break; | 948 break; |
926 } | 949 } |
927 this.secondaryDisplay_.originalPosition = { | 950 this.secondaryDisplay_.originalPosition = { |
928 x: secondaryDiv.offsetLeft, y: secondaryDiv.offsetTop}; | 951 x: secondaryDiv.offsetLeft, y: secondaryDiv.offsetTop}; |
929 } | 952 } |
930 }, | 953 }, |
931 | 954 |
932 /** | 955 /** |
933 * Called when the display arrangement has changed. | 956 * Called when the display arrangement has changed. |
934 * @param {boolean} mirroring Whether current mode is mirroring or not. | 957 * @param {string} multi display mode: one of 'mirror', 'unified', |
Jun Mukai
2015/05/20 02:47:49
It's better to be an enum rather than a string. S
oshima
2015/05/20 06:40:01
Done.
| |
958 * 'extended'. | |
935 * @param {Array<options.DisplayInfo>} displays The list of the display | 959 * @param {Array<options.DisplayInfo>} displays The list of the display |
936 * information. | 960 * information. |
937 * @param {options.SecondaryDisplayLayout} layout The layout strategy. | 961 * @param {options.SecondaryDisplayLayout} layout The layout strategy. |
938 * @param {number} offset The offset of the secondary display. | 962 * @param {number} offset The offset of the secondary display. |
939 * @private | 963 * @private |
940 */ | 964 */ |
941 onDisplayChanged_: function(mirroring, displays, layout, offset) { | 965 onDisplayChanged_: function(mode, displays, layout, offset) { |
942 if (!this.visible) | 966 if (!this.visible) |
943 return; | 967 return; |
944 | 968 |
945 var hasExternal = false; | 969 var hasExternal = false; |
946 for (var i = 0; i < displays.length; i++) { | 970 for (var i = 0; i < displays.length; i++) { |
947 if (!displays[i].isInternal) { | 971 if (!displays[i].isInternal) { |
948 hasExternal = true; | 972 hasExternal = true; |
949 break; | 973 break; |
950 } | 974 } |
951 } | 975 } |
952 | 976 |
953 this.layout_ = layout; | 977 this.layout_ = layout; |
954 | 978 |
979 var mirroring = mode == 'mirror'; | |
980 var unifiedDesktopEnabled = mode == 'unified'; | |
981 | |
955 $('display-options-toggle-mirroring').textContent = | 982 $('display-options-toggle-mirroring').textContent = |
956 loadTimeData.getString( | 983 loadTimeData.getString( |
957 mirroring ? 'stopMirroring' : 'startMirroring'); | 984 mirroring ? 'stopMirroring' : 'startMirroring'); |
958 | 985 |
959 // Focus to the first display next to the primary one when |displays| list | 986 // Focus to the first display next to the primary one when |displays| list |
960 // is updated. | 987 // is updated. |
961 if (mirroring) { | 988 if (mirroring || unifiedDesktopEnabled) { |
962 this.focusedIndex_ = null; | 989 this.focusedIndex_ = null; |
963 } else if (this.mirroring_ != mirroring || | 990 } else if (this.mirroring_ != mirroring || |
991 this.unified_desktop_enabled_ != unifiedDesktopEnabled || | |
964 this.displays_.length != displays.length) { | 992 this.displays_.length != displays.length) { |
965 this.focusedIndex_ = 0; | 993 this.focusedIndex_ = 0; |
966 } | 994 } |
967 | 995 |
968 this.mirroring_ = mirroring; | 996 this.mirroring_ = mirroring; |
997 this.unified_desktop_enabled_ = unifiedDesktopEnabled; | |
969 this.displays_ = displays; | 998 this.displays_ = displays; |
970 | 999 |
971 this.resetDisplaysView_(); | 1000 this.resetDisplaysView_(); |
972 if (this.mirroring_) | 1001 if (this.mirroring_) |
973 this.layoutMirroringDisplays_(); | 1002 this.layoutMirroringDisplays_(); |
974 else | 1003 else |
975 this.layoutDisplays_(); | 1004 this.layoutDisplays_(); |
976 | 1005 |
1006 $('display-options-unified-desktop').hidden = | |
1007 !this.show_unified_desktop_option_; | |
1008 | |
1009 $('display-options-toggle-unified-desktop').checked = | |
1010 this.unified_desktop_enabled_; | |
1011 | |
1012 var disableUnifiedDesktopOption = | |
1013 (this.mirroring_ || | |
1014 (!this.unified_desktop_enabled_ && | |
1015 this.displays_.length == 1)); | |
1016 | |
1017 $('display-options-toggle-unified-desktop').disabled = | |
1018 disableUnifiedDesktopOption; | |
1019 | |
977 this.updateSelectedDisplayDescription_(); | 1020 this.updateSelectedDisplayDescription_(); |
978 } | 1021 } |
979 }; | 1022 }; |
980 | 1023 |
981 DisplayOptions.setDisplayInfo = function( | 1024 DisplayOptions.setDisplayInfo = function( |
982 mirroring, displays, layout, offset) { | 1025 mode, displays, layout, offset) { |
983 DisplayOptions.getInstance().onDisplayChanged_( | 1026 DisplayOptions.getInstance().onDisplayChanged_( |
984 mirroring, displays, layout, offset); | 1027 mode, displays, layout, offset); |
985 }; | 1028 }; |
986 | 1029 |
987 // Export | 1030 // Export |
988 return { | 1031 return { |
989 DisplayOptions: DisplayOptions | 1032 DisplayOptions: DisplayOptions |
990 }; | 1033 }; |
991 }); | 1034 }); |
OLD | NEW |