• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.wm.shell.desktopmode
17 
18 import android.os.IBinder
19 import android.view.SurfaceControl
20 import android.window.TransitionInfo
21 import android.window.TransitionRequestInfo
22 import android.window.WindowContainerTransaction
23 import com.android.wm.shell.transition.Transitions
24 
25 /** Handles the transition to drag a window to another display by dragging the caption. */
26 class DragToDisplayTransitionHandler : Transitions.TransitionHandler {
handleRequestnull27     override fun handleRequest(
28         transition: IBinder,
29         request: TransitionRequestInfo,
30     ): WindowContainerTransaction? {
31         return null
32     }
33 
startAnimationnull34     override fun startAnimation(
35         transition: IBinder,
36         info: TransitionInfo,
37         startTransaction: SurfaceControl.Transaction,
38         finishTransaction: SurfaceControl.Transaction,
39         finishCallback: Transitions.TransitionFinishCallback,
40     ): Boolean {
41         for (change in info.changes) {
42             val sc = change.leash
43             val endBounds = change.endAbsBounds
44             val endPosition = change.endRelOffset
45             startTransaction
46                 .setWindowCrop(sc, endBounds.width(), endBounds.height())
47                 .setPosition(sc, endPosition.x.toFloat(), endPosition.y.toFloat())
48             finishTransaction
49                 .setWindowCrop(sc, endBounds.width(), endBounds.height())
50                 .setPosition(sc, endPosition.x.toFloat(), endPosition.y.toFloat())
51         }
52 
53         startTransaction.apply()
54         finishCallback.onTransitionFinished(null)
55         return true
56     }
57 }
58