Window 的 Type 失效了?IME 为什么在 Toast 下方?

看起来,输入法的层级是比 Toast 要高的,为什么显示的时候,toast 在 ime 上方?

可以看到 ime 最终挂载到 Activity 下方

在 wms 的 addWindow 中可能对 ime 的位置进行移动。imMayMove 为 true 时就可以调用 displayContent 进行移动。

java 复制代码
boolean imMayMove = true;

win.mToken.addWindow(win);
displayPolicy.addWindowLw(win, attrs);
displayPolicy.setDropInputModePolicy(win, win.mAttrs);
if (type == TYPE_APPLICATION_STARTING && activity != null) {
	activity.attachStartingWindow(win);
	ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "addWindow: %s startingWindow=%s",
			activity, win);
} else if (type == TYPE_INPUT_METHOD
		// IME window is always touchable.
		// Ignore non-touchable windows e.g. Stylus InkWindow.java.
		&& (win.getAttrs().flags & FLAG_NOT_TOUCHABLE) == 0) {
	displayContent.setInputMethodWindowLocked(win);
	imMayMove = false;
} else if (type == TYPE_INPUT_METHOD_DIALOG) {
	displayContent.computeImeTarget(true /* updateImeTarget */);
	imMayMove = false;
} else {
	if (type == TYPE_WALLPAPER) {
		displayContent.mWallpaperController.clearLastWallpaperTimeoutTime();
		displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
	} else if (win.hasWallpaper()) {
		displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
	} else if (displayContent.mWallpaperController.isBelowWallpaperTarget(win)) {
		// If there is currently a wallpaper being shown, and
		// the base layer of the new window is below the current
		// layer of the target window, then adjust the wallpaper.
		// This is to avoid a new window being placed between the
		// wallpaper and its target.
		displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
	}
}

final WindowStateAnimator winAnimator = win.mWinAnimator;
winAnimator.mEnterAnimationPending = true;
winAnimator.mEnteringAnimation = true;
// Check if we need to prepare a transition for replacing window first.
if (!win.mTransitionController.isShellTransitionsEnabled()
		&& activity != null && activity.isVisible()
		&& !prepareWindowReplacementTransition(activity)) {
	// If not, check if need to set up a dummy transition during display freeze
	// so that the unfreeze wait for the apps to draw. This might be needed if
	// the app is relaunching.
	prepareNoneTransitionForRelaunching(activity);
}

if (displayPolicy.areSystemBarsForcedConsumedLw()) {
	res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS;
}

if (mInTouchMode) {
	res |= WindowManagerGlobal.ADD_FLAG_IN_TOUCH_MODE;
}
if (win.mActivityRecord == null || win.mActivityRecord.isClientVisible()) {
	res |= WindowManagerGlobal.ADD_FLAG_APP_VISIBLE;
}

displayContent.getInputMonitor().setUpdateInputWindowsNeededLw();

boolean focusChanged = false;
if (win.canReceiveKeys()) {
	focusChanged = updateFocusedWindowLocked(UPDATE_FOCUS_WILL_ASSIGN_LAYERS,
			false /*updateInputWindows*/);
	if (focusChanged) {
		imMayMove = false;
	}
}

if (imMayMove) {
	displayContent.computeImeTarget(true /* updateImeTarget */);
}

com.android.server.wm.DisplayContent#computeImeTarget

相关推荐
foundbug9999 分钟前
Modbus协议C语言实现(易于移植版本)
java·c语言·前端
Luna-player10 分钟前
在前端中list.map的用法
前端·数据结构·list
用户479492835691514 分钟前
面试官问 React Fiber,这一篇文章就够了
前端·javascript·react.js
LYFlied26 分钟前
【一句话概述】Webpack、Vite、Rollup 核心区别
前端·webpack·node.js·rollup·vite·打包·一句话概述
reddingtons38 分钟前
PS 参考图像:线稿上色太慢?AI 3秒“喂”出精细厚涂
前端·人工智能·游戏·ui·aigc·游戏策划·游戏美术
一水鉴天39 分钟前
整体设计 定稿 之23+ dashboard.html 增加三层次动态记录体系仪表盘 之2 程序 (Q199 之2) (codebuddy)
开发语言·前端·javascript
刘发财41 分钟前
前端一行代码生成数千页PDF,dompdf.js新增分页功能
前端·typescript·开源
_请输入用户名1 小时前
Vue 3 源码项目结构详解
前端·vue.js
少卿1 小时前
Next.js 国际化实现方案详解
前端·next.js
掘金挖土1 小时前
手摸手快速搭建 Vue3 + ElementPlus 后台管理系统模板,使用 JavaScript
前端·javascript