Merge "WM: Use task bounds for modal window touchable region" into sc-v2-dev
This commit is contained in:
@@ -4769,6 +4769,16 @@ public interface WindowManager extends ViewManager {
|
|||||||
return Integer.toString(inputFeature);
|
return Integer.toString(inputFeature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the window should consume all pointer events itself, regardless of whether they
|
||||||
|
* are inside of the window. If the window is modal, its touchable region will expand to the
|
||||||
|
* size of its task.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean isModal() {
|
||||||
|
return (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import static com.android.server.wm.WindowManagerService.LOGTAG_INPUT_FOCUS;
|
|||||||
import static java.lang.Integer.MAX_VALUE;
|
import static java.lang.Integer.MAX_VALUE;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -303,9 +302,6 @@ final class InputMonitor {
|
|||||||
&& !mDisableWallpaperTouchEvents;
|
&& !mDisableWallpaperTouchEvents;
|
||||||
inputWindowHandle.setHasWallpaper(hasWallpaper);
|
inputWindowHandle.setHasWallpaper(hasWallpaper);
|
||||||
|
|
||||||
final Rect frame = w.getFrame();
|
|
||||||
inputWindowHandle.setFrame(frame.left, frame.top, frame.right, frame.bottom);
|
|
||||||
|
|
||||||
// Surface insets are hardcoded to be the same in all directions
|
// Surface insets are hardcoded to be the same in all directions
|
||||||
// and we could probably deprecate the "left/right/top/bottom" concept.
|
// and we could probably deprecate the "left/right/top/bottom" concept.
|
||||||
// we avoid reintroducing this concept by just choosing one of them here.
|
// we avoid reintroducing this concept by just choosing one of them here.
|
||||||
@@ -315,11 +311,19 @@ final class InputMonitor {
|
|||||||
// what is on screen to what is actually being touched in the UI.
|
// what is on screen to what is actually being touched in the UI.
|
||||||
inputWindowHandle.setScaleFactor(w.mGlobalScale != 1f ? (1f / w.mGlobalScale) : 1f);
|
inputWindowHandle.setScaleFactor(w.mGlobalScale != 1f ? (1f / w.mGlobalScale) : 1f);
|
||||||
|
|
||||||
final int flags = w.getSurfaceTouchableRegion(mTmpRegion, w.mAttrs.flags);
|
// Update layout params flags to force the window to be not touch modal. We do this to
|
||||||
inputWindowHandle.setTouchableRegion(mTmpRegion);
|
// restrict the window's touchable region to the task even if it request touches outside its
|
||||||
|
// window bounds. An example is a dialog in primary split should get touches outside its
|
||||||
|
// window within the primary task but should not get any touches going to the secondary
|
||||||
|
// task.
|
||||||
|
int flags = w.mAttrs.flags;
|
||||||
|
if (w.mAttrs.isModal()) {
|
||||||
|
flags = flags | FLAG_NOT_TOUCH_MODAL;
|
||||||
|
}
|
||||||
inputWindowHandle.setLayoutParamsFlags(flags);
|
inputWindowHandle.setLayoutParamsFlags(flags);
|
||||||
|
|
||||||
boolean useSurfaceCrop = false;
|
boolean useSurfaceBoundsAsTouchRegion = false;
|
||||||
|
SurfaceControl touchableRegionCrop = null;
|
||||||
final Task task = w.getTask();
|
final Task task = w.getTask();
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
// TODO(b/165794636): Remove the special case for freeform window once drag resizing is
|
// TODO(b/165794636): Remove the special case for freeform window once drag resizing is
|
||||||
@@ -331,20 +335,22 @@ final class InputMonitor {
|
|||||||
// we need to make sure that these changes in crop are reflected in the input
|
// we need to make sure that these changes in crop are reflected in the input
|
||||||
// windows, and so ensure this flag is set so that the input crop always reflects
|
// windows, and so ensure this flag is set so that the input crop always reflects
|
||||||
// the surface hierarchy.
|
// the surface hierarchy.
|
||||||
// TODO(b/168252846): we have some issues with modal-windows, so we need to cross
|
useSurfaceBoundsAsTouchRegion = true;
|
||||||
// that bridge now that we organize full-screen Tasks.
|
|
||||||
inputWindowHandle.setTouchableRegionCrop(null /* Use this surfaces crop */);
|
if (w.mAttrs.isModal()) {
|
||||||
inputWindowHandle.setReplaceTouchableRegionWithCrop(true);
|
TaskFragment parent = w.getTaskFragment();
|
||||||
useSurfaceCrop = true;
|
touchableRegionCrop = parent != null ? parent.getSurfaceControl() : null;
|
||||||
|
}
|
||||||
} else if (task.cropWindowsToRootTaskBounds() && !w.inFreeformWindowingMode()) {
|
} else if (task.cropWindowsToRootTaskBounds() && !w.inFreeformWindowingMode()) {
|
||||||
inputWindowHandle.setTouchableRegionCrop(task.getRootTask().getSurfaceControl());
|
touchableRegionCrop = task.getRootTask().getSurfaceControl();
|
||||||
inputWindowHandle.setReplaceTouchableRegionWithCrop(false);
|
|
||||||
useSurfaceCrop = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!useSurfaceCrop) {
|
inputWindowHandle.setReplaceTouchableRegionWithCrop(useSurfaceBoundsAsTouchRegion);
|
||||||
inputWindowHandle.setReplaceTouchableRegionWithCrop(false);
|
inputWindowHandle.setTouchableRegionCrop(touchableRegionCrop);
|
||||||
inputWindowHandle.setTouchableRegionCrop(null);
|
|
||||||
|
if (!useSurfaceBoundsAsTouchRegion) {
|
||||||
|
w.getSurfaceTouchableRegion(mTmpRegion, w.mAttrs);
|
||||||
|
inputWindowHandle.setTouchableRegion(mTmpRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
|
|||||||
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
|
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
|
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
|
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
|
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
|
||||||
@@ -2882,10 +2881,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSurfaceTouchableRegion(Region region, int flags) {
|
void getSurfaceTouchableRegion(Region region, WindowManager.LayoutParams attrs) {
|
||||||
final boolean modal = (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
|
final boolean modal = attrs.isModal();
|
||||||
if (modal) {
|
if (modal) {
|
||||||
flags |= FLAG_NOT_TOUCH_MODAL;
|
|
||||||
if (mActivityRecord != null) {
|
if (mActivityRecord != null) {
|
||||||
// Limit the outer touch to the activity root task region.
|
// Limit the outer touch to the activity root task region.
|
||||||
updateRegionForModalActivityWindow(region);
|
updateRegionForModalActivityWindow(region);
|
||||||
@@ -2917,8 +2915,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
if (mInvGlobalScale != 1.f) {
|
if (mInvGlobalScale != 1.f) {
|
||||||
region.scale(mInvGlobalScale);
|
region.scale(mInvGlobalScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3766,10 +3762,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
* {@link WindowManager.LayoutParams#FLAG_NOT_TOUCH_MODAL touch modality.}
|
* {@link WindowManager.LayoutParams#FLAG_NOT_TOUCH_MODAL touch modality.}
|
||||||
*/
|
*/
|
||||||
void getEffectiveTouchableRegion(Region outRegion) {
|
void getEffectiveTouchableRegion(Region outRegion) {
|
||||||
final boolean modal = (mAttrs.flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
|
|
||||||
final DisplayContent dc = getDisplayContent();
|
final DisplayContent dc = getDisplayContent();
|
||||||
|
|
||||||
if (modal && dc != null) {
|
if (mAttrs.isModal() && dc != null) {
|
||||||
outRegion.set(dc.getBounds());
|
outRegion.set(dc.getBounds());
|
||||||
cropRegionToRootTaskBoundsIfNeeded(outRegion);
|
cropRegionToRootTaskBoundsIfNeeded(outRegion);
|
||||||
subtractTouchExcludeRegionIfNeeded(outRegion);
|
subtractTouchExcludeRegionIfNeeded(outRegion);
|
||||||
|
|||||||
Reference in New Issue
Block a user