Merge "GestureExclusion: Fix restriction priority" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-07-08 08:02:33 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 5 deletions

View File

@@ -140,7 +140,7 @@ import static com.android.server.wm.WindowManagerService.logSurface;
import static com.android.server.wm.WindowState.RESIZE_HANDLE_WIDTH_IN_DP; import static com.android.server.wm.WindowState.RESIZE_HANDLE_WIDTH_IN_DP;
import static com.android.server.wm.WindowStateAnimator.DRAW_PENDING; import static com.android.server.wm.WindowStateAnimator.DRAW_PENDING;
import static com.android.server.wm.WindowStateAnimator.READY_TO_SHOW; import static com.android.server.wm.WindowStateAnimator.READY_TO_SHOW;
import static com.android.server.wm.utils.RegionUtils.forEachRect; import static com.android.server.wm.utils.RegionUtils.forEachRectReverse;
import static com.android.server.wm.utils.RegionUtils.rectListToRegion; import static com.android.server.wm.utils.RegionUtils.rectListToRegion;
import android.animation.AnimationHandler; import android.animation.AnimationHandler;
@@ -5227,13 +5227,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
r.op(edge, Op.INTERSECT); r.op(edge, Op.INTERSECT);
final int[] remaining = {limit}; final int[] remaining = {limit};
forEachRect(r, rect -> { forEachRectReverse(r, rect -> {
if (remaining[0] <= 0) { if (remaining[0] <= 0) {
return; return;
} }
final int height = rect.height(); final int height = rect.height();
if (height > remaining[0]) { if (height > remaining[0]) {
rect.bottom = rect.top + remaining[0]; rect.top = rect.bottom - remaining[0];
} }
remaining[0] -= height; remaining[0] -= height;
global.op(rect, Op.UNION); global.op(rect, Op.UNION);

View File

@@ -20,6 +20,8 @@ import android.graphics.Rect;
import android.graphics.Region; import android.graphics.Region;
import android.graphics.RegionIterator; import android.graphics.RegionIterator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -48,14 +50,21 @@ public class RegionUtils {
/** /**
* Applies actions on each rect contained within a {@code Region}. * Applies actions on each rect contained within a {@code Region}.
* *
* Order is bottom to top, then right to left.
*
* @param region the given region. * @param region the given region.
* @param rectConsumer the action holder. * @param rectConsumer the action holder.
*/ */
public static void forEachRect(Region region, Consumer<Rect> rectConsumer) { public static void forEachRectReverse(Region region, Consumer<Rect> rectConsumer) {
final RegionIterator it = new RegionIterator(region); final RegionIterator it = new RegionIterator(region);
final ArrayList<Rect> rects = new ArrayList<>();
final Rect rect = new Rect(); final Rect rect = new Rect();
while (it.next(rect)) { while (it.next(rect)) {
rectConsumer.accept(rect); rects.add(new Rect(rect));
} }
// TODO: instead of creating an array and reversing it, expose the reverse iterator through
// JNI.
Collections.reverse(rects);
rects.forEach(rectConsumer);
} }
} }