Commit 26e3461a authored by stevenjb's avatar stevenjb Committed by Commit bot

Fix types in display_options.js

This adds and fixes some types in display_options.js, in preparation
for re-factoring it to support multiple displays.

BUG=576375

Review URL: https://codereview.chromium.org/1612873002

Cr-Commit-Position: refs/heads/master@{#370749}
parent 1be9999b
...@@ -4,6 +4,29 @@ ...@@ -4,6 +4,29 @@
cr.exportPath('options'); cr.exportPath('options');
/**
* Enumeration of display layout. These values must match the C++ values in
* ash::DisplayController.
* @enum {number}
*/
options.DisplayLayoutType = {
TOP: 0,
RIGHT: 1,
BOTTOM: 2,
LEFT: 3
};
/**
* Enumeration of multi display mode. These values must match the C++ values in
* ash::DisplayManager.
* @enum {number}
*/
options.MultiDisplayMode = {
EXTENDED: 0,
MIRRORING: 1,
UNIFIED: 2,
};
/** /**
* @typedef {{ * @typedef {{
* left: number, * left: number,
...@@ -14,6 +37,14 @@ cr.exportPath('options'); ...@@ -14,6 +37,14 @@ cr.exportPath('options');
*/ */
options.DisplayBounds; options.DisplayBounds;
/**
* @typedef {{
* x: number,
* y: number
* }}
*/
options.DisplayPosition;
/** /**
* @typedef {{ * @typedef {{
* width: number, * width: number,
...@@ -40,7 +71,7 @@ options.ColorProfile; ...@@ -40,7 +71,7 @@ options.ColorProfile;
/** /**
* @typedef {{ * @typedef {{
* availableColorProfiles: !Array<!options.ColorProfile>, * availableColorProfiles: !Array<!options.ColorProfile>,
* bounds: options.DisplayBounds, * bounds: !options.DisplayBounds,
* colorProfileId: number, * colorProfileId: number,
* div: ?Element, * div: ?Element,
* id: string, * id: string,
...@@ -49,34 +80,11 @@ options.ColorProfile; ...@@ -49,34 +80,11 @@ options.ColorProfile;
* resolutions: !Array<!options.DisplayMode>, * resolutions: !Array<!options.DisplayMode>,
* name: string, * name: string,
* rotation: number, * rotation: number,
* originalPosition: ?{x: number, y: number} * originalPosition: ?options.DisplayPosition
* }} * }}
*/ */
options.DisplayInfo; options.DisplayInfo;
/**
* Enumeration of secondary display layout. The value has to be same as the
* values in ash/display/display_controller.cc.
* @enum {number}
*/
options.SecondaryDisplayLayout = {
TOP: 0,
RIGHT: 1,
BOTTOM: 2,
LEFT: 3
};
/**
* Enumeration of multi display mode. The value has to be same as the
* values in ash/display/display_manager..
* @enum {number}
*/
options.MultiDisplayMode = {
EXTENDED: 0,
MIRRORING: 1,
UNIFIED: 2,
};
cr.define('options', function() { cr.define('options', function() {
var Page = cr.ui.pageManager.Page; var Page = cr.ui.pageManager.Page;
var PageManager = cr.ui.pageManager.PageManager; var PageManager = cr.ui.pageManager.PageManager;
...@@ -87,51 +95,29 @@ cr.define('options', function() { ...@@ -87,51 +95,29 @@ cr.define('options', function() {
// The number of pixels to share the edges between displays. // The number of pixels to share the edges between displays.
/** @const */ var MIN_OFFSET_OVERLAP = 5; /** @const */ var MIN_OFFSET_OVERLAP = 5;
/**
* Calculates the bounds of |element| relative to the page.
* @param {HTMLElement} element The element to be known.
* @return {Object} The object for the bounds, with x, y, width, and height.
*/
function getBoundsInPage(element) {
var bounds = {
x: element.offsetLeft,
y: element.offsetTop,
width: element.offsetWidth,
height: element.offsetHeight
};
var parent = element.offsetParent;
while (parent && parent != document.body) {
bounds.x += parent.offsetLeft;
bounds.y += parent.offsetTop;
parent = parent.offsetParent;
}
return bounds;
}
/** /**
* Gets the position of |point| to |rect|, left, right, top, or bottom. * Gets the position of |point| to |rect|, left, right, top, or bottom.
* @param {Object} rect The base rectangle with x, y, width, and height. * @param {!options.DisplayBounds} rect The base rectangle.
* @param {Object} point The point to check the position. * @param {!options.DisplayPosition} point The point to check the position.
* @return {options.SecondaryDisplayLayout} The position of the calculated * @return {options.DisplayLayoutType} The position of the calculated point.
* point.
*/ */
function getPositionToRectangle(rect, point) { function getPositionToRectangle(rect, point) {
// Separates the area into four (LEFT/RIGHT/TOP/BOTTOM) by the diagonals of // Separates the area into four (LEFT/RIGHT/TOP/BOTTOM) by the diagonals of
// the rect, and decides which area the display should reside. // the rect, and decides which area the display should reside.
var diagonalSlope = rect.height / rect.width; var diagonalSlope = rect.height / rect.width;
var topDownIntercept = rect.y - rect.x * diagonalSlope; var topDownIntercept = rect.top - rect.left * diagonalSlope;
var bottomUpIntercept = rect.y + rect.height + rect.x * diagonalSlope; var bottomUpIntercept = rect.top + rect.height + rect.left * diagonalSlope;
if (point.y > topDownIntercept + point.x * diagonalSlope) { if (point.y > topDownIntercept + point.x * diagonalSlope) {
if (point.y > bottomUpIntercept - point.x * diagonalSlope) if (point.y > bottomUpIntercept - point.x * diagonalSlope)
return options.SecondaryDisplayLayout.BOTTOM; return options.DisplayLayoutType.BOTTOM;
else else
return options.SecondaryDisplayLayout.LEFT; return options.DisplayLayoutType.LEFT;
} else { } else {
if (point.y > bottomUpIntercept - point.x * diagonalSlope) if (point.y > bottomUpIntercept - point.x * diagonalSlope)
return options.SecondaryDisplayLayout.RIGHT; return options.DisplayLayoutType.RIGHT;
else else
return options.SecondaryDisplayLayout.TOP; return options.DisplayLayoutType.TOP;
} }
} }
...@@ -153,27 +139,31 @@ cr.define('options', function() { ...@@ -153,27 +139,31 @@ cr.define('options', function() {
/** /**
* Whether the current output status is mirroring displays or not. * Whether the current output status is mirroring displays or not.
* @type {boolean}
* @private * @private
*/ */
mirroring_: false, mirroring_: false,
/** /**
* Whether the unified desktop is enable or not. * Whether the unified desktop is enable or not.
* @type {boolean}
* @private * @private
*/ */
unifiedDesktopEnabled_: false, unifiedDesktopEnabled_: false,
/** /**
* Whether the unified desktop option should be present. * Whether the unified desktop option should be present.
* @type {boolean}
* @private * @private
*/ */
showUnifiedDesktopOption_: false, showUnifiedDesktopOption_: false,
/** /**
* The current secondary display layout. * The current secondary display layout.
* @type {options.DisplayLayoutType}
* @private * @private
*/ */
layout_: options.SecondaryDisplayLayout.RIGHT, layout_: options.DisplayLayoutType.RIGHT,
/** /**
* The array of current output displays. It also contains the display * The array of current output displays. It also contains the display
...@@ -184,11 +174,11 @@ cr.define('options', function() { ...@@ -184,11 +174,11 @@ cr.define('options', function() {
displays_: [], displays_: [],
/** /**
* The index for the currently focused display in the options UI. null if * The index of the currently focused display, or -1 for none.
* no one has focus. * @type {number}
* @private * @private
*/ */
focusedIndex_: null, focusedIndex_: -1,
/** /**
* The primary display edit info. * The primary display edit info.
...@@ -204,8 +194,18 @@ cr.define('options', function() { ...@@ -204,8 +194,18 @@ cr.define('options', function() {
*/ */
secondaryDisplay_: null, secondaryDisplay_: null,
/**
* Drag info.
* @type {?{display: !options.DisplayInfo,
* originalLocation: !options.DisplayPosition,
* eventLocation: !options.DisplayPosition}}
* @private
*/
dragging_: null,
/** /**
* The container div element which contains all of the display rectangles. * The container div element which contains all of the display rectangles.
* @type {?Element}
* @private * @private
*/ */
displaysView_: null, displaysView_: null,
...@@ -213,6 +213,7 @@ cr.define('options', function() { ...@@ -213,6 +213,7 @@ cr.define('options', function() {
/** /**
* The scale factor of the actual display size to the drawn display * The scale factor of the actual display size to the drawn display
* rectangle size. * rectangle size.
* @type {number}
* @private * @private
*/ */
visualScale_: VISUAL_SCALE, visualScale_: VISUAL_SCALE,
...@@ -221,12 +222,14 @@ cr.define('options', function() { ...@@ -221,12 +222,14 @@ cr.define('options', function() {
* The location where the last touch event happened. This is used to * The location where the last touch event happened. This is used to
* prevent unnecessary dragging events happen. Set to null unless it's * prevent unnecessary dragging events happen. Set to null unless it's
* during touch events. * during touch events.
* @type {?options.DisplayPosition}
* @private * @private
*/ */
lastTouchLocation_: null, lastTouchLocation_: null,
/** /**
* Whether the display settings can be shown. * Whether the display settings can be shown.
* @type {boolean}
* @private * @private
*/ */
enabled_: true, enabled_: true,
...@@ -257,7 +260,7 @@ cr.define('options', function() { ...@@ -257,7 +260,7 @@ cr.define('options', function() {
}).bind(this); }).bind(this);
$('display-options-orientation-selection').onchange = (function(ev) { $('display-options-orientation-selection').onchange = (function(ev) {
var displayIndex = var displayIndex =
(this.focusedIndex_ === null) ? 0 : this.focusedIndex_; (this.focusedIndex_ == -1) ? 0 : this.focusedIndex_;
var rotation = parseInt(ev.target.value, 10); var rotation = parseInt(ev.target.value, 10);
chrome.send('setRotation', [this.displays_[displayIndex].id, rotation]); chrome.send('setRotation', [this.displays_[displayIndex].id, rotation]);
}).bind(this); }).bind(this);
...@@ -299,9 +302,7 @@ cr.define('options', function() { ...@@ -299,9 +302,7 @@ cr.define('options', function() {
}, },
/** @override */ /** @override */
canShowPage: function() { canShowPage: function() { return this.enabled_; },
return this.enabled_;
},
/** /**
* Enables or disables the page. When disabled, the page will not be able to * Enables or disables the page. When disabled, the page will not be able to
...@@ -401,8 +402,8 @@ cr.define('options', function() { ...@@ -401,8 +402,8 @@ cr.define('options', function() {
var primary = this.primaryDisplay_; var primary = this.primaryDisplay_;
var secondary = this.secondaryDisplay_; var secondary = this.secondaryDisplay_;
var offset; var offset;
if (this.layout_ == options.SecondaryDisplayLayout.LEFT || if (this.layout_ == options.DisplayLayoutType.LEFT ||
this.layout_ == options.SecondaryDisplayLayout.RIGHT) { this.layout_ == options.DisplayLayoutType.RIGHT) {
offset = secondary.div.offsetTop - primary.div.offsetTop; offset = secondary.div.offsetTop - primary.div.offsetTop;
} else { } else {
offset = secondary.div.offsetLeft - primary.div.offsetLeft; offset = secondary.div.offsetLeft - primary.div.offsetLeft;
...@@ -441,7 +442,8 @@ cr.define('options', function() { ...@@ -441,7 +442,8 @@ cr.define('options', function() {
/** /**
* Processes the actual dragging of display rectangle. * Processes the actual dragging of display rectangle.
* @param {Event} e The event which triggers this drag. * @param {Event} e The event which triggers this drag.
* @param {Object} eventLocation The location where the event happens. * @param {options.DisplayPosition} eventLocation The location where the
* event happens.
* @private * @private
*/ */
processDragging_: function(e, eventLocation) { processDragging_: function(e, eventLocation) {
...@@ -479,61 +481,59 @@ cr.define('options', function() { ...@@ -479,61 +481,59 @@ cr.define('options', function() {
newPosition.y = this.snapToEdge_(newPosition.y, draggingDiv.offsetHeight, newPosition.y = this.snapToEdge_(newPosition.y, draggingDiv.offsetHeight,
baseDiv.offsetTop, baseDiv.offsetHeight); baseDiv.offsetTop, baseDiv.offsetHeight);
var newCenter = { var newCenter = /** {!options.DisplayPosition} */({
x: newPosition.x + draggingDiv.offsetWidth / 2, x: newPosition.x + draggingDiv.offsetWidth / 2,
y: newPosition.y + draggingDiv.offsetHeight / 2 y: newPosition.y + draggingDiv.offsetHeight / 2
}; });
var baseBounds = { var baseBounds = /** {!options.DisplayBounds} */({
x: baseDiv.offsetLeft, left: baseDiv.offsetLeft,
y: baseDiv.offsetTop, top: baseDiv.offsetTop,
width: baseDiv.offsetWidth, width: baseDiv.offsetWidth,
height: baseDiv.offsetHeight height: baseDiv.offsetHeight
}; });
switch (getPositionToRectangle(baseBounds, newCenter)) { switch (getPositionToRectangle(baseBounds, newCenter)) {
case options.SecondaryDisplayLayout.RIGHT: case options.DisplayLayoutType.RIGHT:
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.LEFT : options.DisplayLayoutType.LEFT :
options.SecondaryDisplayLayout.RIGHT; options.DisplayLayoutType.RIGHT;
break; break;
case options.SecondaryDisplayLayout.LEFT: case options.DisplayLayoutType.LEFT:
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.RIGHT : options.DisplayLayoutType.RIGHT :
options.SecondaryDisplayLayout.LEFT; options.DisplayLayoutType.LEFT;
break; break;
case options.SecondaryDisplayLayout.TOP: case options.DisplayLayoutType.TOP:
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.BOTTOM : options.DisplayLayoutType.BOTTOM :
options.SecondaryDisplayLayout.TOP; options.DisplayLayoutType.TOP;
break; break;
case options.SecondaryDisplayLayout.BOTTOM: case options.DisplayLayoutType.BOTTOM:
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.TOP : options.DisplayLayoutType.TOP :
options.SecondaryDisplayLayout.BOTTOM; options.DisplayLayoutType.BOTTOM;
break; break;
} }
if (this.layout_ == options.SecondaryDisplayLayout.LEFT || if (this.layout_ == options.DisplayLayoutType.LEFT ||
this.layout_ == options.SecondaryDisplayLayout.RIGHT) { this.layout_ == options.DisplayLayoutType.RIGHT) {
if (newPosition.y > baseDiv.offsetTop + baseDiv.offsetHeight) if (newPosition.y > baseDiv.offsetTop + baseDiv.offsetHeight)
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.TOP : options.DisplayLayoutType.TOP :
options.SecondaryDisplayLayout.BOTTOM; options.DisplayLayoutType.BOTTOM;
else if (newPosition.y + draggingDiv.offsetHeight < else if (newPosition.y + draggingDiv.offsetHeight < baseDiv.offsetTop)
baseDiv.offsetTop)
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.BOTTOM : options.DisplayLayoutType.BOTTOM :
options.SecondaryDisplayLayout.TOP; options.DisplayLayoutType.TOP;
} else { } else {
if (newPosition.x > baseDiv.offsetLeft + baseDiv.offsetWidth) if (newPosition.x > baseDiv.offsetLeft + baseDiv.offsetWidth)
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.LEFT : options.DisplayLayoutType.LEFT :
options.SecondaryDisplayLayout.RIGHT; options.DisplayLayoutType.RIGHT;
else if (newPosition.x + draggingDiv.offsetWidth < else if (newPosition.x + draggingDiv.offsetWidth < baseDiv.offsetLeft)
baseDiv.offsetLeft)
this.layout_ = this.dragging_.display.isPrimary ? this.layout_ = this.dragging_.display.isPrimary ?
options.SecondaryDisplayLayout.RIGHT : options.DisplayLayoutType.RIGHT :
options.SecondaryDisplayLayout.LEFT; options.DisplayLayoutType.LEFT;
} }
var layoutToBase; var layoutToBase;
...@@ -541,38 +541,38 @@ cr.define('options', function() { ...@@ -541,38 +541,38 @@ cr.define('options', function() {
layoutToBase = this.layout_; layoutToBase = this.layout_;
} else { } else {
switch (this.layout_) { switch (this.layout_) {
case options.SecondaryDisplayLayout.RIGHT: case options.DisplayLayoutType.RIGHT:
layoutToBase = options.SecondaryDisplayLayout.LEFT; layoutToBase = options.DisplayLayoutType.LEFT;
break; break;
case options.SecondaryDisplayLayout.LEFT: case options.DisplayLayoutType.LEFT:
layoutToBase = options.SecondaryDisplayLayout.RIGHT; layoutToBase = options.DisplayLayoutType.RIGHT;
break; break;
case options.SecondaryDisplayLayout.TOP: case options.DisplayLayoutType.TOP:
layoutToBase = options.SecondaryDisplayLayout.BOTTOM; layoutToBase = options.DisplayLayoutType.BOTTOM;
break; break;
case options.SecondaryDisplayLayout.BOTTOM: case options.DisplayLayoutType.BOTTOM:
layoutToBase = options.SecondaryDisplayLayout.TOP; layoutToBase = options.DisplayLayoutType.TOP;
break; break;
} }
} }
switch (layoutToBase) { switch (layoutToBase) {
case options.SecondaryDisplayLayout.RIGHT: case options.DisplayLayoutType.RIGHT:
draggingDiv.style.left = draggingDiv.style.left =
baseDiv.offsetLeft + baseDiv.offsetWidth + 'px'; baseDiv.offsetLeft + baseDiv.offsetWidth + 'px';
draggingDiv.style.top = newPosition.y + 'px'; draggingDiv.style.top = newPosition.y + 'px';
break; break;
case options.SecondaryDisplayLayout.LEFT: case options.DisplayLayoutType.LEFT:
draggingDiv.style.left = draggingDiv.style.left =
baseDiv.offsetLeft - draggingDiv.offsetWidth + 'px'; baseDiv.offsetLeft - draggingDiv.offsetWidth + 'px';
draggingDiv.style.top = newPosition.y + 'px'; draggingDiv.style.top = newPosition.y + 'px';
break; break;
case options.SecondaryDisplayLayout.TOP: case options.DisplayLayoutType.TOP:
draggingDiv.style.top = draggingDiv.style.top =
baseDiv.offsetTop - draggingDiv.offsetHeight + 'px'; baseDiv.offsetTop - draggingDiv.offsetHeight + 'px';
draggingDiv.style.left = newPosition.x + 'px'; draggingDiv.style.left = newPosition.x + 'px';
break; break;
case options.SecondaryDisplayLayout.BOTTOM: case options.DisplayLayoutType.BOTTOM:
draggingDiv.style.top = draggingDiv.style.top =
baseDiv.offsetTop + baseDiv.offsetHeight + 'px'; baseDiv.offsetTop + baseDiv.offsetHeight + 'px';
draggingDiv.style.left = newPosition.x + 'px'; draggingDiv.style.left = newPosition.x + 'px';
...@@ -583,16 +583,15 @@ cr.define('options', function() { ...@@ -583,16 +583,15 @@ cr.define('options', function() {
}, },
/** /**
* start dragging of a display rectangle. * Start dragging of a display rectangle.
* @param {HTMLElement} target The event target. * @param {!HTMLElement} target The event target.
* @param {Object} eventLocation The object to hold the location where * @param {!options.DisplayPosition} eventLocation The event location.
* this event happens.
* @private * @private
*/ */
startDragging_: function(target, eventLocation) { startDragging_: function(target, eventLocation) {
var oldFocusedIndex = this.focusedIndex_; var oldFocusedIndex = this.focusedIndex_;
var willUpdateDisplayDescription = false; var willUpdateDisplayDescription = false;
this.focusedIndex_ = null; this.focusedIndex_ = -1;
for (var i = 0; i < this.displays_.length; i++) { for (var i = 0; i < this.displays_.length; i++) {
var display = this.displays_[i]; var display = this.displays_[i];
if (display.div == target || if (display.div == target ||
...@@ -637,24 +636,25 @@ cr.define('options', function() { ...@@ -637,24 +636,25 @@ cr.define('options', function() {
if (this.dragging_) { if (this.dragging_) {
// Make sure the dragging location is connected. // Make sure the dragging location is connected.
var baseDiv = this.dragging_.display.isPrimary ? var baseDiv = this.dragging_.display.isPrimary ?
this.secondaryDisplay_.div : this.primaryDisplay_.div; this.secondaryDisplay_.div :
this.primaryDisplay_.div;
var draggingDiv = this.dragging_.display.div; var draggingDiv = this.dragging_.display.div;
if (this.layout_ == options.SecondaryDisplayLayout.LEFT || if (this.layout_ == options.DisplayLayoutType.LEFT ||
this.layout_ == options.SecondaryDisplayLayout.RIGHT) { this.layout_ == options.DisplayLayoutType.RIGHT) {
var top = Math.max(draggingDiv.offsetTop, var top = Math.max(
baseDiv.offsetTop - draggingDiv.offsetHeight + draggingDiv.offsetTop, baseDiv.offsetTop -
MIN_OFFSET_OVERLAP); draggingDiv.offsetHeight + MIN_OFFSET_OVERLAP);
top = Math.min(top, top = Math.min(
baseDiv.offsetTop + baseDiv.offsetHeight - top,
MIN_OFFSET_OVERLAP); baseDiv.offsetTop + baseDiv.offsetHeight - MIN_OFFSET_OVERLAP);
draggingDiv.style.top = top + 'px'; draggingDiv.style.top = top + 'px';
} else { } else {
var left = Math.max(draggingDiv.offsetLeft, var left = Math.max(
baseDiv.offsetLeft - draggingDiv.offsetWidth + draggingDiv.offsetLeft, baseDiv.offsetLeft -
MIN_OFFSET_OVERLAP); draggingDiv.offsetWidth + MIN_OFFSET_OVERLAP);
left = Math.min(left, left = Math.min(
baseDiv.offsetLeft + baseDiv.offsetWidth - left,
MIN_OFFSET_OVERLAP); baseDiv.offsetLeft + baseDiv.offsetWidth - MIN_OFFSET_OVERLAP);
draggingDiv.style.left = left + 'px'; draggingDiv.style.left = left + 'px';
} }
var originalPosition = this.dragging_.display.originalPosition; var originalPosition = this.dragging_.display.originalPosition;
...@@ -711,7 +711,7 @@ cr.define('options', function() { ...@@ -711,7 +711,7 @@ cr.define('options', function() {
/** /**
* Updates the description of selected display section for the selected * Updates the description of selected display section for the selected
* display. * display.
* @param {Object} display The selected display object. * @param {options.DisplayInfo} display The selected display object.
* @private * @private
*/ */
updateSelectedDisplaySectionForDisplay_: function(display) { updateSelectedDisplaySectionForDisplay_: function(display) {
...@@ -804,7 +804,7 @@ cr.define('options', function() { ...@@ -804,7 +804,7 @@ cr.define('options', function() {
if (this.mirroring_) { if (this.mirroring_) {
this.updateSelectedDisplaySectionMirroring_(); this.updateSelectedDisplaySectionMirroring_();
} else if (this.focusedIndex_ == null || } else if (this.focusedIndex_ == -1 ||
this.displays_[this.focusedIndex_] == null) { this.displays_[this.focusedIndex_] == null) {
this.updateSelectedDisplaySectionNoSelected_(); this.updateSelectedDisplaySectionNoSelected_();
} else { } else {
...@@ -981,25 +981,25 @@ cr.define('options', function() { ...@@ -981,25 +981,25 @@ cr.define('options', function() {
// dragging. See crbug.com/386401 // dragging. See crbug.com/386401
var bounds = this.secondaryDisplay_.bounds; var bounds = this.secondaryDisplay_.bounds;
switch (this.layout_) { switch (this.layout_) {
case options.SecondaryDisplayLayout.TOP: case options.DisplayLayoutType.TOP:
secondaryDiv.style.left = secondaryDiv.style.left =
Math.floor(bounds.left * this.visualScale_) + offset.x + 'px'; Math.floor(bounds.left * this.visualScale_) + offset.x + 'px';
secondaryDiv.style.top = secondaryDiv.style.top =
primaryDiv.offsetTop - secondaryDiv.offsetHeight + 'px'; primaryDiv.offsetTop - secondaryDiv.offsetHeight + 'px';
break; break;
case options.SecondaryDisplayLayout.RIGHT: case options.DisplayLayoutType.RIGHT:
secondaryDiv.style.left = secondaryDiv.style.left =
primaryDiv.offsetLeft + primaryDiv.offsetWidth + 'px'; primaryDiv.offsetLeft + primaryDiv.offsetWidth + 'px';
secondaryDiv.style.top = secondaryDiv.style.top =
Math.floor(bounds.top * this.visualScale_) + offset.y + 'px'; Math.floor(bounds.top * this.visualScale_) + offset.y + 'px';
break; break;
case options.SecondaryDisplayLayout.BOTTOM: case options.DisplayLayoutType.BOTTOM:
secondaryDiv.style.left = secondaryDiv.style.left =
Math.floor(bounds.left * this.visualScale_) + offset.x + 'px'; Math.floor(bounds.left * this.visualScale_) + offset.x + 'px';
secondaryDiv.style.top = secondaryDiv.style.top =
primaryDiv.offsetTop + primaryDiv.offsetHeight + 'px'; primaryDiv.offsetTop + primaryDiv.offsetHeight + 'px';
break; break;
case options.SecondaryDisplayLayout.LEFT: case options.DisplayLayoutType.LEFT:
secondaryDiv.style.left = secondaryDiv.style.left =
primaryDiv.offsetLeft - secondaryDiv.offsetWidth + 'px'; primaryDiv.offsetLeft - secondaryDiv.offsetWidth + 'px';
secondaryDiv.style.top = secondaryDiv.style.top =
...@@ -1018,7 +1018,7 @@ cr.define('options', function() { ...@@ -1018,7 +1018,7 @@ cr.define('options', function() {
* @param {options.MultiDisplayMode} mode multi display mode. * @param {options.MultiDisplayMode} mode multi display mode.
* @param {Array<options.DisplayInfo>} displays The list of the display * @param {Array<options.DisplayInfo>} displays The list of the display
* information. * information.
* @param {options.SecondaryDisplayLayout} layout The layout strategy. * @param {options.DisplayLayoutType} layout The layout strategy.
* @param {number} offset The offset of the secondary display. * @param {number} offset The offset of the secondary display.
* @private * @private
*/ */
...@@ -1042,7 +1042,7 @@ cr.define('options', function() { ...@@ -1042,7 +1042,7 @@ cr.define('options', function() {
// Focus to the first display next to the primary one when |displays| list // Focus to the first display next to the primary one when |displays| list
// is updated. // is updated.
if (mirroring) { if (mirroring) {
this.focusedIndex_ = null; this.focusedIndex_ = -1;
} else if (this.mirroring_ != mirroring || } else if (this.mirroring_ != mirroring ||
this.unifiedDesktopEnabled_ != unifiedDesktopEnabled || this.unifiedDesktopEnabled_ != unifiedDesktopEnabled ||
this.displays_.length != displays.length) { this.displays_.length != displays.length) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment