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 * Enumeration of display layout. These values must match the C++ values in | 8 * Enumeration of display layout. These values must match the C++ values in |
9 * ash::DisplayController. | 9 * ash::DisplayController. |
10 * @enum {number} | 10 * @enum {number} |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 * }} | 82 * }} |
83 */ | 83 */ |
84 options.DisplayInfo; | 84 options.DisplayInfo; |
85 | 85 |
86 /** | 86 /** |
87 * @typedef {{ | 87 * @typedef {{ |
88 * bounds: !options.DisplayBounds, | 88 * bounds: !options.DisplayBounds, |
89 * div: ?HTMLElement, | 89 * div: ?HTMLElement, |
90 * id: string, | 90 * id: string, |
91 * isPrimary: boolean, | 91 * isPrimary: boolean, |
92 * layoutType: options.DisplayLayoutType, | |
92 * name: string, | 93 * name: string, |
93 * originalPosition: !options.DisplayPosition | 94 * originalPosition: !options.DisplayPosition |
94 * }} | 95 * }} |
95 */ | 96 */ |
96 options.DisplayLayout; | 97 options.DisplayLayout; |
97 | 98 |
98 cr.define('options', function() { | 99 cr.define('options', function() { |
99 var Page = cr.ui.pageManager.Page; | 100 var Page = cr.ui.pageManager.Page; |
100 var PageManager = cr.ui.pageManager.PageManager; | 101 var PageManager = cr.ui.pageManager.PageManager; |
101 | 102 |
102 // The scale ratio of the display rectangle to its original size. | 103 // The scale ratio of the display rectangle to its original size. |
103 /** @const */ var VISUAL_SCALE = 1 / 10; | 104 /** @const */ var VISUAL_SCALE = 1 / 10; |
104 | 105 |
105 // The number of pixels to share the edges between displays. | 106 // The number of pixels to share the edges between displays. |
106 /** @const */ var MIN_OFFSET_OVERLAP = 5; | 107 /** @const */ var MIN_OFFSET_OVERLAP = 5; |
107 | 108 |
108 /** | 109 /** |
109 * Gets the position of |point| to |rect|, left, right, top, or bottom. | 110 * Gets the layout type of |point| relative to |rect|. |
110 * @param {!options.DisplayBounds} rect The base rectangle. | 111 * @param {!options.DisplayBounds} rect The base rectangle. |
111 * @param {!options.DisplayPosition} point The point to check the position. | 112 * @param {!options.DisplayPosition} point The point to check the position. |
112 * @return {options.DisplayLayoutType} The position of the calculated point. | 113 * @return {options.DisplayLayoutType} The position of the calculated point. |
xiyuan
2016/01/26 17:35:33
nit: update the comment here as well.
stevenjb
2016/01/26 18:18:10
Done in the next CL
| |
113 */ | 114 */ |
114 function getPositionToRectangle(rect, point) { | 115 function getPositionToRectangle(rect, point) { |
115 // Separates the area into four (LEFT/RIGHT/TOP/BOTTOM) by the diagonals of | 116 // Separates the area into four (LEFT/RIGHT/TOP/BOTTOM) by the diagonals of |
116 // the rect, and decides which area the display should reside. | 117 // the rect, and decides which area the display should reside. |
117 var diagonalSlope = rect.height / rect.width; | 118 var diagonalSlope = rect.height / rect.width; |
118 var topDownIntercept = rect.top - rect.left * diagonalSlope; | 119 var topDownIntercept = rect.top - rect.left * diagonalSlope; |
119 var bottomUpIntercept = rect.top + rect.height + rect.left * diagonalSlope; | 120 var bottomUpIntercept = rect.top + rect.height + rect.left * diagonalSlope; |
120 | 121 |
121 if (point.y > topDownIntercept + point.x * diagonalSlope) { | 122 if (point.y > topDownIntercept + point.x * diagonalSlope) { |
122 if (point.y > bottomUpIntercept - point.x * diagonalSlope) | 123 if (point.y > bottomUpIntercept - point.x * diagonalSlope) |
123 return options.DisplayLayoutType.BOTTOM; | 124 return options.DisplayLayoutType.BOTTOM; |
124 else | 125 else |
125 return options.DisplayLayoutType.LEFT; | 126 return options.DisplayLayoutType.LEFT; |
126 } else { | 127 } else { |
127 if (point.y > bottomUpIntercept - point.x * diagonalSlope) | 128 if (point.y > bottomUpIntercept - point.x * diagonalSlope) |
128 return options.DisplayLayoutType.RIGHT; | 129 return options.DisplayLayoutType.RIGHT; |
129 else | 130 else |
130 return options.DisplayLayoutType.TOP; | 131 return options.DisplayLayoutType.TOP; |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 /** | 135 /** |
136 * Snaps the region [point, width] to [basePoint, baseWidth] if | |
137 * the [point, width] is close enough to the base's edge. | |
138 * @param {number} point The starting point of the region. | |
139 * @param {number} width The width of the region. | |
140 * @param {number} basePoint The starting point of the base region. | |
141 * @param {number} baseWidth The width of the base region. | |
142 * @return {number} The moved point. Returns the point itself if it doesn't | |
143 * need to snap to the edge. | |
144 * @private | |
145 */ | |
146 function snapToEdge(point, width, basePoint, baseWidth) { | |
147 // If the edge of the region is smaller than this, it will snap to the | |
148 // base's edge. | |
149 /** @const */ var SNAP_DISTANCE_PX = 16; | |
150 | |
151 var startDiff = Math.abs(point - basePoint); | |
152 var endDiff = Math.abs(point + width - (basePoint + baseWidth)); | |
153 // Prefer the closer one if both edges are close enough. | |
154 if (startDiff < SNAP_DISTANCE_PX && startDiff < endDiff) | |
155 return basePoint; | |
156 else if (endDiff < SNAP_DISTANCE_PX) | |
157 return basePoint + baseWidth - width; | |
158 | |
159 return point; | |
160 } | |
161 | |
162 /** | |
135 * Encapsulated handling of the 'Display' page. | 163 * Encapsulated handling of the 'Display' page. |
136 * @constructor | 164 * @constructor |
137 * @extends {cr.ui.pageManager.Page} | 165 * @extends {cr.ui.pageManager.Page} |
138 */ | 166 */ |
139 function DisplayOptions() { | 167 function DisplayOptions() { |
140 Page.call(this, 'display', | 168 Page.call(this, 'display', |
141 loadTimeData.getString('displayOptionsPageTabTitle'), | 169 loadTimeData.getString('displayOptionsPageTabTitle'), |
142 'display-options-page'); | 170 'display-options-page'); |
143 } | 171 } |
144 | 172 |
(...skipping 17 matching lines...) Expand all Loading... | |
162 unifiedDesktopEnabled_: false, | 190 unifiedDesktopEnabled_: false, |
163 | 191 |
164 /** | 192 /** |
165 * Whether the unified desktop option should be present. | 193 * Whether the unified desktop option should be present. |
166 * @type {boolean} | 194 * @type {boolean} |
167 * @private | 195 * @private |
168 */ | 196 */ |
169 showUnifiedDesktopOption_: false, | 197 showUnifiedDesktopOption_: false, |
170 | 198 |
171 /** | 199 /** |
172 * The current secondary display layout. | |
173 * @type {options.DisplayLayoutType} | |
174 * @private | |
175 */ | |
176 layoutType_: options.DisplayLayoutType.RIGHT, | |
177 | |
178 /** | |
179 * The array of current output displays. It also contains the display | 200 * The array of current output displays. It also contains the display |
180 * rectangles currently rendered on screen. | 201 * rectangles currently rendered on screen. |
181 * @type {!Array<!options.DisplayInfo>} | 202 * @type {!Array<!options.DisplayInfo>} |
182 * @private | 203 * @private |
183 */ | 204 */ |
184 displays_: [], | 205 displays_: [], |
185 | 206 |
186 /** | 207 /** |
187 * An object containing DisplayLayout objects for each entry in |displays_|. | 208 * An object containing DisplayLayout objects for each entry in |displays_|. |
188 * @type {!Object<!options.DisplayLayout>} | 209 * @type {!Object<!options.DisplayLayout>} |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 }, | 439 }, |
419 | 440 |
420 /** | 441 /** |
421 * Collects the current data and sends it to Chrome. | 442 * Collects the current data and sends it to Chrome. |
422 * @private | 443 * @private |
423 */ | 444 */ |
424 sendDragResult_: function() { | 445 sendDragResult_: function() { |
425 // Offset is calculated from top or left edge. | 446 // Offset is calculated from top or left edge. |
426 var primary = this.displayLayoutMap_[this.primaryDisplayId_]; | 447 var primary = this.displayLayoutMap_[this.primaryDisplayId_]; |
427 var secondary = this.displayLayoutMap_[this.secondaryDisplayId_]; | 448 var secondary = this.displayLayoutMap_[this.secondaryDisplayId_]; |
449 var layoutType = secondary.layoutType; | |
428 var offset; | 450 var offset; |
429 if (this.layoutType_ == options.DisplayLayoutType.LEFT || | 451 if (layoutType == options.DisplayLayoutType.LEFT || |
430 this.layoutType_ == options.DisplayLayoutType.RIGHT) { | 452 layoutType == options.DisplayLayoutType.RIGHT) { |
431 offset = secondary.div.offsetTop - primary.div.offsetTop; | 453 offset = secondary.div.offsetTop - primary.div.offsetTop; |
432 } else { | 454 } else { |
433 offset = secondary.div.offsetLeft - primary.div.offsetLeft; | 455 offset = secondary.div.offsetLeft - primary.div.offsetLeft; |
434 } | 456 } |
435 offset = Math.floor(offset / this.visualScale_); | 457 offset = Math.floor(offset / this.visualScale_); |
436 chrome.send( | 458 chrome.send('setDisplayLayout', [secondary.id, layoutType, offset]); |
437 'setDisplayLayout', [secondary.id, this.layoutType_, offset]); | |
438 }, | 459 }, |
439 | 460 |
440 /** | 461 /** |
441 * Snaps the region [point, width] to [basePoint, baseWidth] if | |
442 * the [point, width] is close enough to the base's edge. | |
443 * @param {number} point The starting point of the region. | |
444 * @param {number} width The width of the region. | |
445 * @param {number} basePoint The starting point of the base region. | |
446 * @param {number} baseWidth The width of the base region. | |
447 * @return {number} The moved point. Returns point itself if it doesn't | |
448 * need to snap to the edge. | |
449 * @private | |
450 */ | |
451 snapToEdge_: function(point, width, basePoint, baseWidth) { | |
452 // If the edge of the regions is smaller than this, it will snap to the | |
453 // base's edge. | |
454 /** @const */ var SNAP_DISTANCE_PX = 16; | |
455 | |
456 var startDiff = Math.abs(point - basePoint); | |
457 var endDiff = Math.abs(point + width - (basePoint + baseWidth)); | |
458 // Prefer the closer one if both edges are close enough. | |
459 if (startDiff < SNAP_DISTANCE_PX && startDiff < endDiff) | |
460 return basePoint; | |
461 else if (endDiff < SNAP_DISTANCE_PX) | |
462 return basePoint + baseWidth - width; | |
463 | |
464 return point; | |
465 }, | |
466 | |
467 /** | |
468 * Processes the actual dragging of display rectangle. | 462 * Processes the actual dragging of display rectangle. |
469 * @param {Event} e The event which triggers this drag. | 463 * @param {Event} e The event which triggers this drag. |
470 * @param {options.DisplayPosition} eventLocation The location where the | 464 * @param {options.DisplayPosition} eventLocation The location where the |
471 * event happens. | 465 * event happens. |
472 * @private | 466 * @private |
473 */ | 467 */ |
474 processDragging_: function(e, eventLocation) { | 468 processDragging_: function(e, eventLocation) { |
475 if (!this.dragInfo_) | 469 if (!this.dragInfo_) |
476 return true; | 470 return true; |
477 | 471 |
478 e.preventDefault(); | 472 e.preventDefault(); |
479 | 473 |
480 // Note that current code of moving display-rectangles doesn't work | 474 // Note that current code of moving display-rectangles doesn't work |
481 // if there are >=3 displays. This is our assumption for M21. | 475 // if there are >=3 displays. This is our assumption for M21. |
482 // TODO(mukai): Fix the code to allow >=3 displays. | 476 // TODO(mukai): Fix the code to allow >=3 displays. |
483 var dragInfo = this.dragInfo_; | 477 var dragInfo = this.dragInfo_; |
484 var dragLayout = this.displayLayoutMap_[dragInfo.displayId]; | |
485 /** @type {options.DisplayPosition} */ var newPosition = { | 478 /** @type {options.DisplayPosition} */ var newPosition = { |
486 x: dragInfo.originalLocation.x + | 479 x: dragInfo.originalLocation.x + |
487 (eventLocation.x - dragInfo.eventLocation.x), | 480 (eventLocation.x - dragInfo.eventLocation.x), |
488 y: dragInfo.originalLocation.y + | 481 y: dragInfo.originalLocation.y + |
489 (eventLocation.y - dragInfo.eventLocation.y) | 482 (eventLocation.y - dragInfo.eventLocation.y) |
490 }; | 483 }; |
491 | 484 |
485 var dragLayout = this.displayLayoutMap_[dragInfo.displayId]; | |
486 var draggingDiv = dragLayout.div; | |
487 | |
492 var baseDisplayId = dragLayout.isPrimary ? this.secondaryDisplayId_ : | 488 var baseDisplayId = dragLayout.isPrimary ? this.secondaryDisplayId_ : |
493 this.primaryDisplayId_; | 489 this.primaryDisplayId_; |
494 var baseDiv = this.displayLayoutMap_[baseDisplayId].div; | 490 var baseLayout = this.displayLayoutMap_[baseDisplayId]; |
495 var draggingDiv = dragLayout.div; | 491 var baseDiv = baseLayout.div; |
496 | 492 |
497 newPosition.x = this.snapToEdge_(newPosition.x, draggingDiv.offsetWidth, | 493 newPosition.x = snapToEdge( |
498 baseDiv.offsetLeft, baseDiv.offsetWidth); | 494 newPosition.x, draggingDiv.offsetWidth, baseDiv.offsetLeft, |
499 newPosition.y = this.snapToEdge_(newPosition.y, draggingDiv.offsetHeight, | 495 baseDiv.offsetWidth); |
500 baseDiv.offsetTop, baseDiv.offsetHeight); | 496 newPosition.y = snapToEdge( |
497 newPosition.y, draggingDiv.offsetHeight, baseDiv.offsetTop, | |
498 baseDiv.offsetHeight); | |
501 | 499 |
502 /** @type {!options.DisplayPosition} */ var newCenter = { | 500 /** @type {!options.DisplayPosition} */ var newCenter = { |
503 x: newPosition.x + draggingDiv.offsetWidth / 2, | 501 x: newPosition.x + draggingDiv.offsetWidth / 2, |
504 y: newPosition.y + draggingDiv.offsetHeight / 2 | 502 y: newPosition.y + draggingDiv.offsetHeight / 2 |
505 }; | 503 }; |
506 | 504 |
507 /** @type {!options.DisplayBounds} */ var baseBounds = { | 505 /** @type {!options.DisplayBounds} */ var baseBounds = { |
508 left: baseDiv.offsetLeft, | 506 left: baseDiv.offsetLeft, |
509 top: baseDiv.offsetTop, | 507 top: baseDiv.offsetTop, |
510 width: baseDiv.offsetWidth, | 508 width: baseDiv.offsetWidth, |
511 height: baseDiv.offsetHeight | 509 height: baseDiv.offsetHeight |
512 }; | 510 }; |
513 | 511 |
514 var isPrimary = dragLayout.isPrimary; | 512 var isPrimary = dragLayout.isPrimary; |
515 var layoutType = this.layoutType_; | 513 // layoutType is always stored in the secondary layout. |
514 var layoutType = | |
515 isPrimary ? baseLayout.layoutType : dragLayout.layoutType; | |
516 | 516 |
517 switch (getPositionToRectangle(baseBounds, newCenter)) { | 517 switch (getPositionToRectangle(baseBounds, newCenter)) { |
518 case options.DisplayLayoutType.RIGHT: | 518 case options.DisplayLayoutType.RIGHT: |
519 layoutType = isPrimary ? options.DisplayLayoutType.LEFT : | 519 layoutType = isPrimary ? options.DisplayLayoutType.LEFT : |
520 options.DisplayLayoutType.RIGHT; | 520 options.DisplayLayoutType.RIGHT; |
521 break; | 521 break; |
522 case options.DisplayLayoutType.LEFT: | 522 case options.DisplayLayoutType.LEFT: |
523 layoutType = isPrimary ? options.DisplayLayoutType.RIGHT : | 523 layoutType = isPrimary ? options.DisplayLayoutType.RIGHT : |
524 options.DisplayLayoutType.LEFT; | 524 options.DisplayLayoutType.LEFT; |
525 break; | 525 break; |
(...skipping 17 matching lines...) Expand all Loading... | |
543 options.DisplayLayoutType.TOP; | 543 options.DisplayLayoutType.TOP; |
544 } else { | 544 } else { |
545 if (newPosition.x > baseDiv.offsetLeft + baseDiv.offsetWidth) | 545 if (newPosition.x > baseDiv.offsetLeft + baseDiv.offsetWidth) |
546 layoutType = isPrimary ? options.DisplayLayoutType.LEFT : | 546 layoutType = isPrimary ? options.DisplayLayoutType.LEFT : |
547 options.DisplayLayoutType.RIGHT; | 547 options.DisplayLayoutType.RIGHT; |
548 else if (newPosition.x + draggingDiv.offsetWidth < baseDiv.offsetLeft) | 548 else if (newPosition.x + draggingDiv.offsetWidth < baseDiv.offsetLeft) |
549 layoutType = isPrimary ? options.DisplayLayoutType.RIGHT : | 549 layoutType = isPrimary ? options.DisplayLayoutType.RIGHT : |
550 options.DisplayLayoutType.LEFT; | 550 options.DisplayLayoutType.LEFT; |
551 } | 551 } |
552 | 552 |
553 this.layoutType_ = layoutType; | |
554 | |
555 var layoutToBase; | 553 var layoutToBase; |
556 if (!isPrimary) { | 554 if (!isPrimary) { |
555 dragLayout.layoutType = layoutType; | |
557 layoutToBase = layoutType; | 556 layoutToBase = layoutType; |
558 } else { | 557 } else { |
558 baseLayout.layoutType = layoutType; | |
559 switch (layoutType) { | 559 switch (layoutType) { |
560 case options.DisplayLayoutType.RIGHT: | 560 case options.DisplayLayoutType.RIGHT: |
561 layoutToBase = options.DisplayLayoutType.LEFT; | 561 layoutToBase = options.DisplayLayoutType.LEFT; |
562 break; | 562 break; |
563 case options.DisplayLayoutType.LEFT: | 563 case options.DisplayLayoutType.LEFT: |
564 layoutToBase = options.DisplayLayoutType.RIGHT; | 564 layoutToBase = options.DisplayLayoutType.RIGHT; |
565 break; | 565 break; |
566 case options.DisplayLayoutType.TOP: | 566 case options.DisplayLayoutType.TOP: |
567 layoutToBase = options.DisplayLayoutType.BOTTOM; | 567 layoutToBase = options.DisplayLayoutType.BOTTOM; |
568 break; | 568 break; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 */ | 653 */ |
654 endDragging_: function(e) { | 654 endDragging_: function(e) { |
655 this.lastTouchLocation_ = null; | 655 this.lastTouchLocation_ = null; |
656 if (!this.dragInfo_) | 656 if (!this.dragInfo_) |
657 return false; | 657 return false; |
658 | 658 |
659 // Make sure the dragging location is connected. | 659 // Make sure the dragging location is connected. |
660 var dragLayout = this.displayLayoutMap_[this.dragInfo_.displayId]; | 660 var dragLayout = this.displayLayoutMap_[this.dragInfo_.displayId]; |
661 var baseDisplayId = dragLayout.isPrimary ? this.secondaryDisplayId_ : | 661 var baseDisplayId = dragLayout.isPrimary ? this.secondaryDisplayId_ : |
662 this.primaryDisplayId_; | 662 this.primaryDisplayId_; |
663 var baseDiv = this.displayLayoutMap_[baseDisplayId].div; | 663 |
664 var baseLayout = this.displayLayoutMap_[baseDisplayId]; | |
665 var baseDiv = baseLayout.div; | |
664 var draggingDiv = dragLayout.div; | 666 var draggingDiv = dragLayout.div; |
665 if (this.layoutType_ == options.DisplayLayoutType.LEFT || | 667 |
666 this.layoutType_ == options.DisplayLayoutType.RIGHT) { | 668 // layoutType is always stored in the secondary layout. |
669 var layoutType = | |
670 dragLayout.isPrimary ? baseLayout.layoutType : dragLayout.layoutType; | |
671 | |
672 if (layoutType == options.DisplayLayoutType.LEFT || | |
673 layoutType == options.DisplayLayoutType.RIGHT) { | |
667 var top = Math.max( | 674 var top = Math.max( |
668 draggingDiv.offsetTop, | 675 draggingDiv.offsetTop, |
669 baseDiv.offsetTop - draggingDiv.offsetHeight + MIN_OFFSET_OVERLAP); | 676 baseDiv.offsetTop - draggingDiv.offsetHeight + MIN_OFFSET_OVERLAP); |
670 top = Math.min( | 677 top = Math.min( |
671 top, baseDiv.offsetTop + baseDiv.offsetHeight - MIN_OFFSET_OVERLAP); | 678 top, baseDiv.offsetTop + baseDiv.offsetHeight - MIN_OFFSET_OVERLAP); |
672 draggingDiv.style.top = top + 'px'; | 679 draggingDiv.style.top = top + 'px'; |
673 } else { | 680 } else { |
674 var left = Math.max( | 681 var left = Math.max( |
675 draggingDiv.offsetLeft, | 682 draggingDiv.offsetLeft, |
676 baseDiv.offsetLeft - draggingDiv.offsetWidth + MIN_OFFSET_OVERLAP); | 683 baseDiv.offsetLeft - draggingDiv.offsetWidth + MIN_OFFSET_OVERLAP); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 div.className = 'displays-display'; | 890 div.className = 'displays-display'; |
884 div.style.top = i * MIRRORING_OFFSET_PIXELS + 'px'; | 891 div.style.top = i * MIRRORING_OFFSET_PIXELS + 'px'; |
885 div.style.left = i * MIRRORING_OFFSET_PIXELS + offsetX + 'px'; | 892 div.style.left = i * MIRRORING_OFFSET_PIXELS + offsetX + 'px'; |
886 div.style.width = width + 'px'; | 893 div.style.width = width + 'px'; |
887 div.style.height = height + 'px'; | 894 div.style.height = height + 'px'; |
888 div.style.zIndex = i; | 895 div.style.zIndex = i; |
889 // set 'display-mirrored' class for the background display rectangles. | 896 // set 'display-mirrored' class for the background display rectangles. |
890 if (i != numDisplays - 1) | 897 if (i != numDisplays - 1) |
891 div.classList.add('display-mirrored'); | 898 div.classList.add('display-mirrored'); |
892 this.displaysView_.appendChild(div); | 899 this.displaysView_.appendChild(div); |
893 | |
894 // Not currently used but set for consistency / debugging. | |
895 this.displayLayoutMap_[this.displays_[i].id].div = div; | |
896 } | 900 } |
897 }, | 901 }, |
898 | 902 |
899 /** | 903 /** |
900 * Creates a DisplayLayout object representing the display. | 904 * Creates a DisplayLayout object representing the display. |
901 * @param {!options.DisplayInfo} display | 905 * @param {!options.DisplayInfo} display |
906 * @param {!options.DisplayLayoutType} layoutType | |
902 * @return {!options.DisplayLayout} | 907 * @return {!options.DisplayLayout} |
903 * @private | 908 * @private |
904 */ | 909 */ |
905 createDisplayLayout_: function(display) { | 910 createDisplayLayout_: function(display, layoutType) { |
906 /** @type {options.DisplayLayout} */ var displayLayout = { | 911 return { |
907 bounds: display.bounds, | 912 bounds: display.bounds, |
908 div: null, | 913 div: null, |
909 id: display.id, | 914 id: display.id, |
910 isPrimary: display.isPrimary, | 915 isPrimary: display.isPrimary, |
916 layoutType: layoutType, | |
911 name: display.name, | 917 name: display.name, |
912 originalPosition: {x: 0, y: 0} | 918 originalPosition: {x: 0, y: 0} |
913 }; | 919 }; |
914 return displayLayout; | |
915 }, | 920 }, |
916 | 921 |
917 /** | 922 /** |
918 * Creates a div element representing the specified display. | 923 * Creates a div element representing the specified display. |
919 * @param {!options.DisplayLayout} displayLayout | 924 * @param {!options.DisplayLayout} displayLayout |
920 * @param {options.DisplayLayoutType} layoutType The layout type for the | 925 * @param {options.DisplayLayoutType} layoutType The layout type for the |
921 * secondary display. | 926 * secondary display. |
922 * @param {!options.DisplayPosition} offset The offset to the center of the | 927 * @param {!options.DisplayPosition} offset The offset to the center of the |
923 * display area. | 928 * display area. |
924 * @private | 929 * @private |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 * @private | 1069 * @private |
1065 */ | 1070 */ |
1066 onDisplayChanged_: function(mode, displays, layoutType, offset) { | 1071 onDisplayChanged_: function(mode, displays, layoutType, offset) { |
1067 if (!this.visible) | 1072 if (!this.visible) |
1068 return; | 1073 return; |
1069 | 1074 |
1070 this.displays_ = displays; | 1075 this.displays_ = displays; |
1071 this.displayLayoutMap_ = {}; | 1076 this.displayLayoutMap_ = {}; |
1072 for (var i = 0; i < displays.length; i++) { | 1077 for (var i = 0; i < displays.length; i++) { |
1073 var display = displays[i]; | 1078 var display = displays[i]; |
1074 this.displayLayoutMap_[display.id] = this.createDisplayLayout_(display); | 1079 this.displayLayoutMap_[display.id] = |
1080 this.createDisplayLayout_(display, layoutType); | |
1075 } | 1081 } |
1076 | 1082 |
1077 var mirroring = mode == options.MultiDisplayMode.MIRRORING; | 1083 var mirroring = mode == options.MultiDisplayMode.MIRRORING; |
1078 var unifiedDesktopEnabled = mode == options.MultiDisplayMode.UNIFIED; | 1084 var unifiedDesktopEnabled = mode == options.MultiDisplayMode.UNIFIED; |
1079 | 1085 |
1080 // Focus to the first display next to the primary one when |displays_| | 1086 // Focus to the first display next to the primary one when |displays_| |
1081 // is updated. | 1087 // is updated. |
1082 if (mirroring) { | 1088 if (mirroring) { |
1083 this.focusedId_ = ''; | 1089 this.focusedId_ = ''; |
1084 } else if ( | 1090 } else if ( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 mode, displays, layoutType, offset) { | 1128 mode, displays, layoutType, offset) { |
1123 DisplayOptions.getInstance().onDisplayChanged_( | 1129 DisplayOptions.getInstance().onDisplayChanged_( |
1124 mode, displays, layoutType, offset); | 1130 mode, displays, layoutType, offset); |
1125 }; | 1131 }; |
1126 | 1132 |
1127 // Export | 1133 // Export |
1128 return { | 1134 return { |
1129 DisplayOptions: DisplayOptions | 1135 DisplayOptions: DisplayOptions |
1130 }; | 1136 }; |
1131 }); | 1137 }); |
OLD | NEW |