Java Code Examples for android.graphics.Rect#setEmpty()

The following examples show how to use android.graphics.Rect#setEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeaderShadowDecoration.java    From UltimateRecyclerView with Apache License 2.0 6 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (parent.getChildAdapterPosition(view) < mColumns) {
        if (mHorizontal) {
            if (mView.getMeasuredWidth() <= 0) {
                mView.measure(View.MeasureSpec.makeMeasureSpec(parent.getMeasuredWidth(), View.MeasureSpec.AT_MOST),
                        View.MeasureSpec.makeMeasureSpec(parent.getMeasuredHeight(), View.MeasureSpec.AT_MOST));
            }
            outRect.set(mView.getMeasuredWidth(), 0, 0, 0);
        } else {
            if (mView.getMeasuredHeight() <= 0) {
                mView.measure(View.MeasureSpec.makeMeasureSpec(parent.getMeasuredWidth(), View.MeasureSpec.AT_MOST),
                        View.MeasureSpec.makeMeasureSpec(parent.getMeasuredHeight(), View.MeasureSpec.AT_MOST));
            }
            outRect.set(0, mView.getMeasuredHeight(), 0, 0);
        }
    } else {
        outRect.setEmpty();
    }
}
 
Example 2
Source File: SeparatorDecoration.java    From fritz-examples with MIT License 5 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

    // we want to retrieve the position in the list
    final int position = params.getViewAdapterPosition();

    // and add a separator to any view but the last one
    if (position < state.getItemCount()) {
        outRect.set(0, 0, 0, (int) mPaint.getStrokeWidth()); // left, top, right, bottom
    } else {
        outRect.setEmpty(); // 0, 0, 0, 0
    }
}
 
Example 3
Source File: DividerDecoration.java    From recyclerviewItemDecorations with MIT License 5 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (hasDividerOnBottom(view, parent, state)) {
        outRect.set(0, 0, 0, mHeightDp);
    } else {
        outRect.setEmpty();
    }
}
 
Example 4
Source File: BaseLayoutHelper.java    From vlayout with MIT License 5 votes vote down vote up
@Override
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
    if (requireLayoutView()) {
        View refer = null;
        Rect tempRect = new Rect();
        final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
        for (int i = 0; i < helper.getChildCount(); i++) {
            refer = helper.getChildAt(i);
            int anchorPos = helper.getPosition(refer);
            if (getRange().contains(anchorPos)) {
                if (refer.getVisibility() == View.GONE) {
                    tempRect.setEmpty();
                } else {
                    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
                        refer.getLayoutParams();
                    if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
                        tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
                            orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedRight(refer) + params.rightMargin,
                            orientationHelper.getDecoratedEnd(refer));
                    } else {
                        tempRect.union(orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
                            helper.getDecoratedBottom(refer) + params.bottomMargin);
                    }
                }
            }
        }
        if (!tempRect.isEmpty()) {
            mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
                tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
        } else {
            mLayoutRegion.setEmpty();
        }
        if (mLayoutView != null) {
            mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
        }
    }
}
 
Example 5
Source File: GsPreferenceFragmentCompat.java    From memetastic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    int position = parent.getChildAdapterPosition(view);
    int viewType = 0;
    try {
        viewType = parent.getAdapter() != null ? parent.getAdapter().getItemViewType(position) : 0;
    } catch (NullPointerException ignored) {
    }
    if (viewType != 1) {
        outRect.set(0, 0, 0, _heightDp);
    } else {
        outRect.setEmpty();
    }
}
 
Example 6
Source File: AutofillPopup.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Get desired popup window width by calculating the maximum text length from Autofill data.
 * @param data Autofill suggestion data.
 * @return The popup window width in DIP.
 */
private float getDesiredWidth(ArrayList<AutofillSuggestion> data) {
    if (mLabelViewPaint == null || mSublabelViewPaint == null) {
        LayoutInflater inflater =
                (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.autofill_text, null);
        TextView labelView = (TextView) layout.findViewById(R.id.autofill_label);
        mLabelViewPaint = labelView.getPaint();
        TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sublabel);
        mSublabelViewPaint = sublabelView.getPaint();
    }

    float maxTextWidth = 0;
    Rect bounds = new Rect();
    for (int i = 0; i < data.size(); ++i) {
        bounds.setEmpty();
        String label = data.get(i).mLabel;
        if (!TextUtils.isEmpty(label)) {
            mLabelViewPaint.getTextBounds(label, 0, label.length(), bounds);
        }
        float labelWidth = bounds.width();

        bounds.setEmpty();
        String sublabel = data.get(i).mSublabel;
        if (!TextUtils.isEmpty(sublabel)) {
            mSublabelViewPaint.getTextBounds(sublabel, 0, sublabel.length(), bounds);
        }

        float localMax = Math.max(labelWidth, bounds.width());
        maxTextWidth = Math.max(maxTextWidth, localMax);
    }
    // Scale it down to make it unscaled by screen density.
    maxTextWidth = maxTextWidth / mContext.getResources().getDisplayMetrics().density;
    // Adding padding.
    return maxTextWidth + TEXT_PADDING_DP;
}
 
Example 7
Source File: LithoView.java    From litho with Apache License 2.0 5 votes vote down vote up
private void processVisibilityOutputs() {
  final Rect currentVisibleArea = new Rect();
  final boolean visible = getLocalVisibleRect(currentVisibleArea);
  if (!visible) {
    currentVisibleArea.setEmpty();
  }

  processVisibilityOutputs(currentVisibleArea);
}
 
Example 8
Source File: Switch.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
    super.onLayout(changed, left, top, right, bottom);

    wasLayout = true;
    int opticalInsetLeft = 0;
    int opticalInsetRight = 0;
    if (mThumbDrawable != null)
    {
        final Rect trackPadding = mTempRect;
        if (mTrackDrawable != null)
        {
            mTrackDrawable.getPadding(trackPadding);
        }
        else
        {
            trackPadding.setEmpty();
        }

        final Insets insets = Insets.NONE;
        opticalInsetLeft = Math.max(0, insets.left - trackPadding.left);
        opticalInsetRight = Math.max(0, insets.right - trackPadding.right);
    }

    final int switchRight;
    final int switchLeft;
    if (LocaleController.isRTL)
    {
        switchLeft = getPaddingLeft() + opticalInsetLeft;
        switchRight = switchLeft + mSwitchWidth - opticalInsetLeft - opticalInsetRight;
    }
    else
    {
        switchRight = getWidth() - getPaddingRight() - opticalInsetRight;
        switchLeft = switchRight - mSwitchWidth + opticalInsetLeft + opticalInsetRight;
    }

    final int switchTop;
    final int switchBottom;
    switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK)
    {
        default:
        case Gravity.TOP:
            switchTop = getPaddingTop();
            switchBottom = switchTop + mSwitchHeight;
            break;

        case Gravity.CENTER_VERTICAL:
            switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 - mSwitchHeight / 2;
            switchBottom = switchTop + mSwitchHeight;
            break;

        case Gravity.BOTTOM:
            switchBottom = getHeight() - getPaddingBottom();
            switchTop = switchBottom - mSwitchHeight;
            break;
    }

    mSwitchLeft = switchLeft;
    mSwitchTop = switchTop;
    mSwitchBottom = switchBottom;
    mSwitchRight = switchRight;
}
 
Example 9
Source File: Switch.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
    super.onLayout(changed, left, top, right, bottom);

    wasLayout = true;
    int opticalInsetLeft = 0;
    int opticalInsetRight = 0;
    if (mThumbDrawable != null)
    {
        final Rect trackPadding = mTempRect;
        if (mTrackDrawable != null)
        {
            mTrackDrawable.getPadding(trackPadding);
        }
        else
        {
            trackPadding.setEmpty();
        }

        final Insets insets = Insets.NONE;
        opticalInsetLeft = Math.max(0, insets.left - trackPadding.left);
        opticalInsetRight = Math.max(0, insets.right - trackPadding.right);
    }

    final int switchRight;
    final int switchLeft;
    if (LocaleController.isRTL)
    {
        switchLeft = getPaddingLeft() + opticalInsetLeft;
        switchRight = switchLeft + mSwitchWidth - opticalInsetLeft - opticalInsetRight;
    }
    else
    {
        switchRight = getWidth() - getPaddingRight() - opticalInsetRight;
        switchLeft = switchRight - mSwitchWidth + opticalInsetLeft + opticalInsetRight;
    }

    final int switchTop;
    final int switchBottom;
    switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK)
    {
        default:
        case Gravity.TOP:
            switchTop = getPaddingTop();
            switchBottom = switchTop + mSwitchHeight;
            break;

        case Gravity.CENTER_VERTICAL:
            switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 - mSwitchHeight / 2;
            switchBottom = switchTop + mSwitchHeight;
            break;

        case Gravity.BOTTOM:
            switchBottom = getHeight() - getPaddingBottom();
            switchTop = switchBottom - mSwitchHeight;
            break;
    }

    mSwitchLeft = switchLeft;
    mSwitchTop = switchTop;
    mSwitchBottom = switchBottom;
    mSwitchRight = switchRight;
}
 
Example 10
Source File: Switch.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
    final Rect padding = mTempRect;
    int thumbWidth;
    int thumbHeight;
    if (mThumbDrawable != null)
    {
        mThumbDrawable.getPadding(padding);
        thumbWidth = mThumbDrawable.getIntrinsicWidth() - padding.left - padding.right;
        thumbHeight = mThumbDrawable.getIntrinsicHeight();
    }
    else
    {
        thumbWidth = 0;
        thumbHeight = 0;
    }


    mThumbWidth = thumbWidth;

    int trackHeight;
    if (mTrackDrawable != null)
    {
        mTrackDrawable.getPadding(padding);
        trackHeight = mTrackDrawable.getIntrinsicHeight();
    }
    else
    {
        padding.setEmpty();
        trackHeight = 0;
    }

    int paddingLeft = padding.left;
    int paddingRight = padding.right;
    if (mThumbDrawable != null)
    {
        final Insets inset = Insets.NONE;
        paddingLeft = Math.max(paddingLeft, inset.left);
        paddingRight = Math.max(paddingRight, inset.right);
    }

    final int switchWidth = Math.max(mSwitchMinWidth, 2 * mThumbWidth + paddingLeft + paddingRight);
    final int switchHeight = Math.max(trackHeight, thumbHeight);
    mSwitchWidth = switchWidth;
    mSwitchHeight = switchHeight;

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    final int measuredHeight = getMeasuredHeight();
    if (measuredHeight < switchHeight)
    {
        setMeasuredDimension(switchWidth, switchHeight);
    }
}
 
Example 11
Source File: ItemTouchHelper.java    From letv with Apache License 2.0 4 votes vote down vote up
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) {
    outRect.setEmpty();
}
 
Example 12
Source File: WeSwipeHelper.java    From monero-wallet-android-app with MIT License 4 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                           RecyclerView.State state) {
    outRect.setEmpty();
}
 
Example 13
Source File: ItemTouchHelper.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
        RecyclerView.State state) {
    outRect.setEmpty();
}
 
Example 14
Source File: Switch.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (mShowText) {
        if (mOnLayout == null) {
            mOnLayout = makeLayout(mTextOn);
        }

        if (mOffLayout == null) {
            mOffLayout = makeLayout(mTextOff);
        }
    }

    final Rect padding = mTempRect;
    final int thumbWidth;
    final int thumbHeight;
    if (mThumbDrawable != null) {
        // Cached thumb width does not include padding.
        mThumbDrawable.getPadding(padding);
        thumbWidth = mThumbDrawable.getIntrinsicWidth() - padding.left - padding.right;
        thumbHeight = mThumbDrawable.getIntrinsicHeight();
    } else {
        thumbWidth = 0;
        thumbHeight = 0;
    }

    final int maxTextWidth;
    if (mShowText) {
        maxTextWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth())
                + mThumbTextPadding * 2;
    } else {
        maxTextWidth = 0;
    }

    mThumbWidth = Math.max(maxTextWidth, thumbWidth);

    final int trackHeight;
    if (mTrackDrawable != null) {
        mTrackDrawable.getPadding(padding);
        trackHeight = mTrackDrawable.getIntrinsicHeight();
    } else {
        padding.setEmpty();
        trackHeight = 0;
    }

    // Adjust left and right padding to ensure there's enough room for the
    // thumb's padding (when present).
    int paddingLeft = padding.left;
    int paddingRight = padding.right;
    if (mThumbDrawable != null) {
        final Insets inset = mThumbDrawable.getOpticalInsets();
        paddingLeft = Math.max(paddingLeft, inset.left);
        paddingRight = Math.max(paddingRight, inset.right);
    }

    final int switchWidth = Math.max(mSwitchMinWidth,
            2 * mThumbWidth + paddingLeft + paddingRight);
    final int switchHeight = Math.max(trackHeight, thumbHeight);
    mSwitchWidth = switchWidth;
    mSwitchHeight = switchHeight;

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    final int measuredHeight = getMeasuredHeight();
    if (measuredHeight < switchHeight) {
        setMeasuredDimension(getMeasuredWidthAndState(), switchHeight);
    }
}
 
Example 15
Source File: SwipeOpenItemTouchHelper.java    From SwipeOpenItemTouchHelper with Apache License 2.0 4 votes vote down vote up
@Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
    @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
  outRect.setEmpty();
}
 
Example 16
Source File: Switch.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
    final Rect padding = mTempRect;
    int thumbWidth;
    int thumbHeight;
    if (mThumbDrawable != null)
    {
        mThumbDrawable.getPadding(padding);
        thumbWidth = mThumbDrawable.getIntrinsicWidth() - padding.left - padding.right;
        thumbHeight = mThumbDrawable.getIntrinsicHeight();
    }
    else
    {
        thumbWidth = 0;
        thumbHeight = 0;
    }


    mThumbWidth = thumbWidth;

    int trackHeight;
    if (mTrackDrawable != null)
    {
        mTrackDrawable.getPadding(padding);
        trackHeight = mTrackDrawable.getIntrinsicHeight();
    }
    else
    {
        padding.setEmpty();
        trackHeight = 0;
    }

    int paddingLeft = padding.left;
    int paddingRight = padding.right;
    if (mThumbDrawable != null)
    {
        final Insets inset = Insets.NONE;
        paddingLeft = Math.max(paddingLeft, inset.left);
        paddingRight = Math.max(paddingRight, inset.right);
    }

    final int switchWidth = Math.max(mSwitchMinWidth, 2 * mThumbWidth + paddingLeft + paddingRight);
    final int switchHeight = Math.max(trackHeight, thumbHeight);
    mSwitchWidth = switchWidth;
    mSwitchHeight = switchHeight;

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    final int measuredHeight = getMeasuredHeight();
    if (measuredHeight < switchHeight)
    {
        setMeasuredDimension(switchWidth, switchHeight);
    }
}
 
Example 17
Source File: RectUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
/**
 * Find the largest sub-rectangle that doesn't intersect a specified one. <strong>Note:</strong>
 * {@code rectToModify} and {@code otherRect} will be sorted after operation.
 *
 * @param rectToModify The rect that may be modified to avoid intersections
 * @param otherRect The rect that should be avoided
 */
public static void adjustRectToAvoidIntersection(Rect rectToModify, Rect otherRect) {
  /*
   * Some rectangles are flipped around (left > right). Make sure we have two Rects free of
   * such pathologies.
   */
  rectToModify.sort();
  otherRect.sort();

  if (rectToModify.contains(otherRect) || !Rect.intersects(rectToModify, otherRect)) {
    return;
  }

  /*
   * Intersect rectToModify with four rects that represent cuts of the entire space along
   * lines defined by the otherRect's edges
   */
  Rect[] cuts = {
    new Rect(rectToModify.left, rectToModify.top, otherRect.left, rectToModify.bottom),
    new Rect(rectToModify.left, rectToModify.top, rectToModify.right, otherRect.top),
    new Rect(otherRect.right, rectToModify.top, rectToModify.right, rectToModify.bottom),
    new Rect(rectToModify.left, otherRect.bottom, rectToModify.right, rectToModify.bottom)
  };

  int maxIntersectingRectArea = 0;
  int indexOfLargestIntersection = -1;
  for (int i = 0; i < cuts.length; i++) {
    if (!isSorted(cuts[i])) {
      continue;
    }
    if (Rect.intersects(cuts[i], rectToModify)) {
      /* Reassign this cut to its intersection with rectToModify */
      int visibleRectArea = cuts[i].width() * cuts[i].height();
      if (visibleRectArea > maxIntersectingRectArea) {
        maxIntersectingRectArea = visibleRectArea;
        indexOfLargestIntersection = i;
      }
    }
  }
  if (maxIntersectingRectArea <= 0) {
    // The rectToModify isn't within any of our cuts, so it's entirely occuled by otherRect.
    rectToModify.setEmpty();
    return;
  }
  rectToModify.set(cuts[indexOfLargestIntersection]);
}
 
Example 18
Source File: RangeStyle.java    From vlayout with MIT License 4 votes vote down vote up
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
    if (!isChildrenEmpty()) {
        for (Map.Entry<Range<Integer>, T> entry : mChildren.entrySet()) {
            RangeStyle rangeStyle = entry.getValue();
            rangeStyle.adjustLayout(startPosition, endPosition, helper);
        }
    }
    if (requireLayoutView()) {
        View refer = null;
        Rect tempRect = new Rect();
        final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
        for (int i = 0; i < helper.getChildCount(); i++) {
            refer = helper.getChildAt(i);
            int anchorPos = helper.getPosition(refer);
            if (getRange().contains(anchorPos)) {
                if (refer.getVisibility() == View.GONE) {
                    tempRect.setEmpty();
                } else {
                    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
                        refer.getLayoutParams();
                    if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
                        tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
                            orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedRight(refer) + params.rightMargin,
                            orientationHelper.getDecoratedEnd(refer));
                    } else {
                        tempRect.union(orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
                            helper.getDecoratedBottom(refer) + params.bottomMargin);
                    }
                }
            }
        }
        if (!tempRect.isEmpty()) {
            mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
                tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
        } else {
            mLayoutRegion.setEmpty();
        }
        if (mLayoutView != null) {
            mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
        }
    }
}
 
Example 19
Source File: ItemTouchHelperExtension.java    From CrazyDaily with Apache License 2.0 4 votes vote down vote up
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                           RecyclerView.State state) {
    outRect.setEmpty();
}
 
Example 20
Source File: WindowStateAnimator.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Calculate the window-space crop rect and fill clipRect.
 * @return true if clipRect has been filled otherwise, no window space crop should be applied.
 */
private boolean calculateCrop(Rect clipRect) {
    final WindowState w = mWin;
    final DisplayContent displayContent = w.getDisplayContent();
    clipRect.setEmpty();

    if (displayContent == null) {
        return false;
    }

    if (w.inPinnedWindowingMode()) {
        return false;
    }

    // During forced seamless rotation, the surface bounds get updated with the crop in the
    // new rotation, which is not compatible with showing the surface in the old rotation.
    // To work around that we disable cropping for such windows, as it is not necessary anyways.
    if (w.mForceSeamlesslyRotate) {
        return false;
    }

    // If we're animating, the wallpaper should only
    // be updated at the end of the animation.
    if (w.mAttrs.type == TYPE_WALLPAPER) {
        return false;
    }

    if (DEBUG_WINDOW_CROP) Slog.d(TAG,
            "Updating crop win=" + w + " mLastCrop=" + mLastClipRect);

    w.calculatePolicyCrop(mSystemDecorRect);

    if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Applying decor to crop win=" + w + " mDecorFrame="
            + w.mDecorFrame + " mSystemDecorRect=" + mSystemDecorRect);

    final Task task = w.getTask();
    final boolean fullscreen = w.fillsDisplay() || (task != null && task.isFullscreen());
    final boolean isFreeformResizing =
            w.isDragResizing() && w.getResizeMode() == DRAG_RESIZE_MODE_FREEFORM;

    // We use the clip rect as provided by the tranformation for non-fullscreen windows to
    // avoid premature clipping with the system decor rect.
    clipRect.set(mSystemDecorRect);
    if (DEBUG_WINDOW_CROP) Slog.d(TAG, "win=" + w + " Initial clip rect: " + clipRect
            + " fullscreen=" + fullscreen);

    w.expandForSurfaceInsets(clipRect);

    // The clip rect was generated assuming (0,0) as the window origin,
    // so we need to translate to match the actual surface coordinates.
    clipRect.offset(w.mAttrs.surfaceInsets.left, w.mAttrs.surfaceInsets.top);

    if (DEBUG_WINDOW_CROP) Slog.d(TAG,
            "win=" + w + " Clip rect after stack adjustment=" + clipRect);

    w.transformClipRectFromScreenToSurfaceSpace(clipRect);

    return true;
}