joncodo
joncodo

Reputation: 2328

Chrome app can't be maximized

I know that there is a maximize function but my boss wants to be able to click the little green button on his yosemite mac.

This was working at one point but now the little green button is disabled.

enter image description here

I am playing with the window sizes like this:

service.setChromeToMinSize = function(){
  var monitorWidth = window.screen.availWidth;
  var monitorHeight = window.screen.availHeight;
  var top = Math.round((monitorHeight / 2) - (568 / 2));
  var left = Math.round((monitorWidth / 2) - (400 / 2));

  chrome.app.window.current().innerBounds.maxWidth = 400;
  chrome.app.window.current().innerBounds.maxHeight = 568;
  chrome.app.window.current().innerBounds.minWidth = 400;
  chrome.app.window.current().innerBounds.minHeight = 568;
  chrome.app.window.current().innerBounds.top = top;
  chrome.app.window.current().innerBounds.left = left;
  chrome.app.window.current().innerBounds.width = 400;
  chrome.app.window.current().innerBounds.height = 568;
};

service.setChromeToVideoSize = function(){

  var monitorWidth = window.screen.availWidth;
  var monitorHeight = window.screen.availHeight;
  var videoWidth = Math.round(monitorWidth/2);
  var videoHeight = Math.round(videoWidth * 9 / 16);
  var top = Math.round((monitorHeight / 2) - (videoHeight / 2));
  var left = Math.round((monitorWidth / 2) - (videoWidth / 2));

  chrome.app.window.current().innerBounds.maxWidth = 10000;
  chrome.app.window.current().innerBounds.maxHeight = 10000;
  chrome.app.window.current().innerBounds.minWidth = 1;
  chrome.app.window.current().innerBounds.minHeight = 1;
  chrome.app.window.current().innerBounds.top = top;
  chrome.app.window.current().innerBounds.left = left;
  chrome.app.window.current().innerBounds.width = videoWidth;
  chrome.app.window.current().innerBounds.height = videoHeight;
};

But even with all that commented, I get the same problem.

I start the app like this:

chrome.app.runtime.onLaunched.addListener(function(launchData) {
 chrome.app.window.create(
   'index.html',
{
  id: 'mainWindow',
  bounds: {width: 400, height: 568},
  minWidth: 400,
  minHeight: 568,
  maxWidth: 400,
  maxHeight: 568
    }
  );
});

QUESTION: How can I enable the little green button?

Upvotes: 0

Views: 146

Answers (1)

jukempff
jukempff

Reputation: 965

As pointed out in the comments, you have to set the innerBounds maxWidth and maxHeight to null, instead of a large number.

From the bounds type documentation:

A value of null indicates 'unspecified'.

Although the resulting limitation on fullscreen mode is not mentioned, it somehow makes sense to disable fullscreen mode with maxWidth/Height being set.

Upvotes: 1

Related Questions