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 /** 27 * Indicates the direction of resizing. May be combined together to indicate a diagonal drag. 28 */ 29 @IntDef(flag = true, value = { 30 CTRL_TYPE_UNDEFINED, CTRL_TYPE_LEFT, CTRL_TYPE_RIGHT, CTRL_TYPE_TOP, CTRL_TYPE_BOTTOM 31 }) 32 @interface CtrlType {} 33 34 int CTRL_TYPE_UNDEFINED = 0; 35 int CTRL_TYPE_LEFT = 1; 36 int CTRL_TYPE_RIGHT = 2; 37 int CTRL_TYPE_TOP = 4; 38 int CTRL_TYPE_BOTTOM = 8; 39 /** 40 * Called when a drag-resize or drag-move starts. 41 * 42 * @param ctrlType {@link CtrlType} indicating the direction of resizing, use 43 * {@code 0} to indicate it's a move 44 * @param x x coordinate in window decoration coordinate system where the drag starts 45 * @param y y coordinate in window decoration coordinate system where the drag starts 46 * @return the starting task bounds 47 */ onDragPositioningStart(@trlType int ctrlType, float x, float y)48 Rect onDragPositioningStart(@CtrlType int ctrlType, float x, float y); 49 50 /** 51 * Called when the pointer moves during a drag-resize or drag-move. 52 * @param x x coordinate in window decoration coordinate system of the new pointer location 53 * @param y y coordinate in window decoration coordinate system of the new pointer location 54 * @return the updated task bounds 55 */ onDragPositioningMove(float x, float y)56 Rect onDragPositioningMove(float x, float y); 57 58 /** 59 * Called when a drag-resize or drag-move stops. 60 * @param x x coordinate in window decoration coordinate system where the drag resize stops 61 * @param y y coordinate in window decoration coordinate system where the drag resize stops 62 * @return the final bounds for the dragged task 63 */ onDragPositioningEnd(float x, float y)64 Rect onDragPositioningEnd(float x, float y); 65 } 66