1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.wm.shell.windowdecor; 18 19 import android.annotation.IntDef; 20 import android.graphics.Rect; 21 22 /** 23 * Callback called when receiving drag-resize or drag-move related input events. 24 */ 25 public interface DragPositioningCallback { 26 @IntDef(flag = true, value = { 27 CTRL_TYPE_UNDEFINED, CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT, CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM 28 }) 29 @interface CtrlType {} 30 31 int CTRL_TYPE_UNDEFINED = 0; 32 int CTRL_TYPE_LEFT = 1; 33 int CTRL_TYPE_RIGHT = 2; 34 int CTRL_TYPE_TOP = 4; 35 int CTRL_TYPE_BOTTOM = 8; 36 /** 37 * Called when a drag-resize or drag-move starts. 38 * 39 * @param ctrlType {@link CtrlType} indicating the direction of resizing, use 40 * {@code 0} to indicate it's a move 41 * @param x x coordinate in window decoration coordinate system where the drag starts 42 * @param y y coordinate in window decoration coordinate system where the drag starts 43 */ onDragPositioningStart(@trlType int ctrlType, float x, float y)44 void onDragPositioningStart(@CtrlType int ctrlType, float x, float y); 45 46 /** 47 * Called when the pointer moves during a drag-resize or drag-move. 48 * @param x x coordinate in window decoration coordinate system of the new pointer location 49 * @param y y coordinate in window decoration coordinate system of the new pointer location 50 * @return the updated task bounds 51 */ onDragPositioningMove(float x, float y)52 Rect onDragPositioningMove(float x, float y); 53 54 /** 55 * Called when a drag-resize or drag-move stops. 56 * @param x x coordinate in window decoration coordinate system where the drag resize stops 57 * @param y y coordinate in window decoration coordinate system where the drag resize stops 58 * @return the final bounds for the dragged task 59 */ onDragPositioningEnd(float x, float y)60 Rect onDragPositioningEnd(float x, float y); 61 } 62