从WindowManagerService角度看,一个窗口并不是Window类,而是一个View类。WindowManagerService收到用户消息后,需要把消息派发到窗口,View类本身并不能直接接收WindowManagerService传递过来的消息,真正接收用户消息的必须是IWindow类,而实现IWindow类的是ViewRoot.W类,每一个W内部都包含了一个View变量。
WmS并不介意该窗口(View)是属于哪个应用程序的,WmS会按一定的规则判断哪个窗口处于活动状态,然后把用户消息给W类,W类再把用户消息传递给内部的View变量,剩下的消息处理就由View对象完成。
WindowManager的LayoutParams中窗口类型与定义:
frameworks\base\core\java\android\view\WindowManager.java
/**
-
Start of window types that represent normal application windows.
-
ZMS:首个普通应用窗口
*/
public static final int FIRST_APPLICATION_WINDOW = 1;
/**
-
Window type: an application window that serves as the “base” window
-
of the overall application; all other application windows will
-
appear on top of it.
-
In multiuser systems shows only on the owning user’s window.
-
ZMS:基础窗口-其他应用窗口会显示在此窗口之上
*/
public static final int TYPE_BASE_APPLICATION = 1;
/**
-
Window type: a normal application window. The {@link #token} must be
-
an Activity token identifying who the window belongs to.
-
In multiuser systems shows only on the owning user’s window.
-
ZMS:普通应用窗口-此窗口需要归属于Activity,多用户系统中仅仅在对应用户的窗口中显示
*/
public static final int TYPE_APPLICATION = 2;
/**
-
Window type: special application window that is displayed while the
-
application is starting. Not for use by applications themselves;
-
this is used by the system to display something until the
-
application can show its own windows.
-
In multiuser systems shows on all users’ windows.
-
ZMS:应用启动窗口-应用启动显示的窗口,不受应用本身控制。由系统在应用显示应用本身的窗口之前显示。
*/
public static final int TYPE_APPLICATION_STARTING = 3;
/**
-
End of types of application windows.
-
ZMS:终极应用窗口-所有Activity默认的窗口类型都是TYPE_APPLICATION,
-
WindowManagerService在进行窗口叠加时,会动态改变应用窗口的层值,但不会大于99。
*/