1 /* 2 * Copyright (C) 2025 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.tiling 18 19 import android.app.ActivityManager.RunningTaskInfo 20 import android.graphics.Rect 21 import com.android.wm.shell.desktopmode.DesktopTasksController.SnapPosition 22 23 /** Interface for handling snap to half screen events. */ 24 interface SnapEventHandler { 25 /** Snaps an app to half the screen for tiling. */ snapToHalfScreennull26 fun snapToHalfScreen( 27 taskInfo: RunningTaskInfo, 28 currentDragBounds: Rect, 29 position: SnapPosition, 30 ): Boolean 31 32 /** Removes a task from tiling if it's tiled, for example on task exiting. */ 33 fun removeTaskIfTiled(displayId: Int, taskId: Int) 34 35 /** Notifies the tiling handler of user switch. */ 36 fun onUserChange() 37 38 /** Notifies the tiling handler of overview animation state change. */ 39 fun onOverviewAnimationStateChange(running: Boolean) 40 41 /** If a task is tiled, delegate moving to front to tiling infrastructure. */ 42 fun moveTaskToFrontIfTiled(taskInfo: RunningTaskInfo): Boolean 43 44 /** 45 * Returns the bounds of a task tiled on the left on the specified display, defaults to default 46 * snapping bounds if no task is tiled. 47 */ 48 fun getLeftSnapBoundsIfTiled(displayId: Int): Rect 49 50 /** 51 * Returns the bounds of a task tiled on the right on the specified display, defaults to default 52 * snapping bounds if no task is tiled. 53 */ 54 fun getRightSnapBoundsIfTiled(displayId: Int): Rect 55 } 56