5

I recently purchased an ASUS c100p Chromebook and noticed that when the device is flipped all the way back into "tablet" mode that sizable windows are maximized by default. If they have fixed window bounds they are effectively treated as modal (centered, immovable, and peripheral areas are dimmed) when in the foreground, unless they are set to have the alwaysOnTop attribute in which case they can be moved freely. I want to be able to detect this change so I can have an app with fixed window bounds perform some sort of action (maximize, close, set to alwaysOnTop, etc.). Is there a some way of detecting this transition in Javascript?

I've tried the following events with no success:

  • chrome.app.window.onFullscreened - Nothing fires on transition.
  • chrome.app.window.onMaximized - Fires on resizable windows, but not windows with fixed bounds.
  • chrome.system.display.onDisplayChanged - Fires if device is rotated from landscape to portrait while transitioning, but not if going straight to landscape tablet mode.
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

You could detect to see if the inner width and height of the window is the same as the fixed bounds with this code:

if(window.innerWidth != 400 || window.innerHeight != 400) {
  // some code, eg window.close()
}

Replace the 400s with the width and height the window is being opened with.