At Vivien's request I'm scaling this back. All that is needed for this project for now is a code cleanup in apps/homescreen/js/window_manager.js
My understanding of the homescreen architecture is that the window manager is the part of the app that ensures that the right things are displayed at the right time. The window manager doesn't have any visual representation itself; it is the event dispatching code that processes incoming events and makes the right things appear in response to those events. Tapping an icon launches its app, for example. And pressing the Home button brings up the homescreen. But the window manager also has to handle other things: the volume buttons should display a temporary volume change overlay, for example, and an incoming phone call should launch an app for answering the phone call.
Currently, that event dispatching is done in an ad-hoc way. The point of this project is to clean it all up, centralizing event dispatching, and making it easier to add new features in the future.
- The code needs to be really robust, because if the homescreen breaks, then the phone basically breaks.
- Tests, tests, tests
I've been conceptualizing the homescreen's as a finite state machine, with the window manager being the piece that is responsible for switching states in response to events. So I've been putting together a list of states and a list of events that the window manager may have to handle. Feel free to add others to the lists below:
Each of these states represents a different display, and each state may need its own set of event handlers.
- Blank, screen off
- Lock screen
- homescreen icon grid (pages 1 to n)
- homescreen with menu displayed (if we need a menu)
- app window
- fullscreen app window
- task switcher overlay
- view source overlay
- notifications screen
- volume change overlay
- virtual keyboard overlay
- CSS transitions between each of the above main states:
- lockscreen -> homescreen
- homescreen -> app
- app -> blank screen
These are some of the events that the window manager will need to handle, at least in some states:
- home button short press
- home button long press
- volume up/down
- back soft key
- view source soft key
- power/lock screen button
- other device buttons like a camera button?
- incoming call
- incoming text
- new notification ("you have mail", etc.)
- app installed event
- setting changed event
- css transitionend event
Some events are very specific and are handled by a single display module within the homescreen. The window manager probably does not need to listen for these, and can just allow homescreen modules to listen for them and display as needed:
- battery level change
- signal strength change
- timeout (for updating the clock in the status bar)
- ononline, onoffline