2. Window Manager
A core module in an operating system, which is
responsible to display and maintain the window
based UI.
3. Window Mgmt. at FxOS
● A clustor of modules mainly serves to create
web apps.
● A re-implementation of a browser.
● Ability to handle WebAPI request between
apps.
12. AppWindow
● The basic unit which wraps the mozbrowser
iframe.
● (Mostly) Standalone library to create a
webapp instance.
● Each appWindow instance maintains its own
states and display proper UI according to
these states.
16. App Visibility
● Active app is basically foreground, but we
are having some more complex rules; for
instance, a chaining activities are all
foreground.
● Page visibility is particially impacting the
process priority.
● The timing of visibilitychange was bind to
transition states.
17. App Orientation
● Passive orientation requested in manifest
● Active orientation requested by
screen.lockOrientation()
o System app does not being involed too
much in this progress but is expected to.
o What if lock orientation during
transitioning?
● Query by screen.mozOrientation
18. App has no knowledge about (x, y),
but (w, h) is affecting app by window.innerHeight,
window.innerWidth, and reflow/resize if that changed.
Layout = (x, y,
w, h)
19. Use small piece of codes
doing limited tasks
AppWindow: Submodule
To avoid a giant AppWindow class..
20. AppWindow Submodules
AppWindow
Each submodule is responsible to handle a specific request
from the appWindow. Their only dependency is the
appWindow who launches/instantiates them.
M
M
M
M
M
MHW
M
M
M
M
M M
At
W
M
M
M
M
M
M
submodule
22. Developing Submodules
var MyModule = function(app) {
this.app = app;
this.app.element.addEventListener(‘_opened’, this);
};
MyModule.prototype = {
handleEvent: function() {
// ...
}
};
AppWindow.SUB_MODULES = {
‘myModule’: window.MyModule
};
var a = new AppWindow();
typeof(a.myModule) // === MyModule
23. Transition Finite State Machine
● A submodule to process transition related
events to maintain the state and perform the
transition.
● States: opened/opening/closed/closing
● Transition state should be standalone from
other states.
26. Interactions between AppWindows..
We are living in a world of multiple apps. An
appWindow should not do anything it wants to
do.
Request before permitted!
30. LifeCycle Management
● Maintain a list of alive windows
● Manage the interaction between window
instances
● Events happens inside an appWindow is
delegated to the appWindow itself.
● Interactions involved multiple appWindows
needs the manager to decide what to do.
31. Life cycle - launch
● AppWindowManager has an appWindow
factory to deal with launch request from the
gecko(system message) or the user.
● Each AppWindow instances has a child
window factory to deal with launch request
from the app.
33. Life cycle - kill
● active kill
o window.close()
o ParentWindow is killed
o The user kills it from task manager.
● When an appWindow is killed inactively by
gecko due to OOM or crash, it will enter
suspend state.
37. *WindowManager
*Window *Window (active)
Modules affecting
transition
*Window
Transition
FSM
*Window
request to open
close the active instance
Basically only the same
type window will be taken
into account.
39. MultiTasking - Nested Windows
Dialer App Gallery AppHomescreen App Contact App
Contact Activity
Gallery Activity
Camera Activity
Camera App
40. MultiTasking - Nested Windows
AppWindow
AppWindowAppWindow
AppWindow
ActivityWindow
Activity
Window
ActivityWindow
AppWindow
FrontWindow is rendered inside BottomWindow’s container.
41. AppWindow#1
Activity
Window#A
Nested Window
Activity
Window#B
● AppWindow#1 manages ActivityWindow#A
● ActivityWindow#A manages ActivityWindow#B
● Only parentWindow/childWindow refers each
other; the grandparentWindow(AppWindow#1)
does not need to know the state of the
grandchildWindow(ActivityWindow#B)
● However, kill a parentWindow will kill the
childWindow which causes a chaining kill.
42. We are having a principal pattern now.
AppWindowManagerAppWindow AppWindow
Application Core
AppWindow AppWindow
AppWindow
One Manager + Instances Pattern fits usual webapp
management requirements.
43. Hierarchy
In an operation system, there would be some
system level user interface which are not usual
applications but has certain interaction with
applications.
Lockscreen, Attention, SystemDialog,
Rocketbar...
44. We are having a principal pattern now.
Scale this design.
59. Look at the Transition FSM closely
● statechange will trigger the inner handler
o Enter closed state: send to background
o Enter opened state: request to foreground
60. Develop a window manager
● What windows to manage/create?
● Reuse/Inherit AppWindow
● Make HierachyManagement Modules know
your existence
61. Best Practice: Rocketbar
● Search app is different from a normal
appWindow.
● Implement SearchWindow
● Implement
SearchWindowManager(rocketbar.js)
● Modify HierachyManagement Modules
64. Manager(Mediator) Pattern
● A manager is usually a singleton.
● What to manage? Interactions between
instances.
● A manager is expected to maintain a list
multiple instances coming from the same
class.