blob: 290c2eaf0bf3c5796404de559d43f05322d8fc6d [file] [log] [blame]
Chong Zhang8e89b312015-09-09 15:09:30 -07001/*
2 * Copyright (C) 2015 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
17package com.android.server.wm;
18
Wale Ogunwale59a73ca2015-09-14 12:54:50 -070019import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
20import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
Wale Ogunwale228d4042015-09-13 10:17:34 -070021import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
Chong Zhang87b21722015-09-21 15:39:51 -070022import static android.app.ActivityManager.RESIZE_MODE_USER;
Chong Zhang6de2ae82015-09-30 18:25:21 -070023import static android.app.ActivityManager.RESIZE_MODE_USER_FORCED;
Wale Ogunwale228d4042015-09-13 10:17:34 -070024import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
Wale Ogunwalecad05a02015-09-25 10:41:44 -070025import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
Chong Zhang8e89b312015-09-09 15:09:30 -070026import static com.android.server.wm.WindowManagerService.DEBUG_TASK_POSITIONING;
Wale Ogunwale228d4042015-09-13 10:17:34 -070027import static com.android.server.wm.WindowManagerService.SHOW_TRANSACTIONS;
Wale Ogunwale231b06e2015-09-16 12:03:09 -070028import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_HEIGHT_IN_DP;
29import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_WIDTH_IN_DP;
Chong Zhang8e89b312015-09-09 15:09:30 -070030
31import android.annotation.IntDef;
32import android.graphics.Point;
33import android.graphics.Rect;
34import android.os.Looper;
35import android.os.Process;
36import android.os.RemoteException;
Wale Ogunwalecad05a02015-09-25 10:41:44 -070037import android.os.Trace;
Chong Zhang8e89b312015-09-09 15:09:30 -070038import android.util.DisplayMetrics;
39import android.util.Slog;
Wale Ogunwale4f52bc62015-09-24 13:47:31 -070040import android.view.Choreographer;
Chong Zhang8e89b312015-09-09 15:09:30 -070041import android.view.Display;
Wale Ogunwale228d4042015-09-13 10:17:34 -070042import android.view.DisplayInfo;
Chong Zhang8e89b312015-09-09 15:09:30 -070043import android.view.InputChannel;
44import android.view.InputDevice;
45import android.view.InputEvent;
Wale Ogunwale4f52bc62015-09-24 13:47:31 -070046import android.view.BatchedInputEventReceiver;
Chong Zhang8e89b312015-09-09 15:09:30 -070047import android.view.MotionEvent;
Wale Ogunwale228d4042015-09-13 10:17:34 -070048import android.view.SurfaceControl;
Chong Zhang8e89b312015-09-09 15:09:30 -070049import android.view.WindowManager;
50
Wale Ogunwale228d4042015-09-13 10:17:34 -070051import com.android.server.input.InputApplicationHandle;
52import com.android.server.input.InputWindowHandle;
53import com.android.server.wm.WindowManagerService.H;
54
55import java.lang.annotation.Retention;
56import java.lang.annotation.RetentionPolicy;
57
58class TaskPositioner implements DimLayer.DimLayerUser {
Chong Zhang8e89b312015-09-09 15:09:30 -070059 private static final String TAG = "TaskPositioner";
60
Wale Ogunwale228d4042015-09-13 10:17:34 -070061 // The margin the pointer position has to be within the side of the screen to be
62 // considered at the side of the screen.
Wale Ogunwalef5a67f52015-09-15 09:54:33 -070063 private static final int SIDE_MARGIN_DIP = 100;
Wale Ogunwale228d4042015-09-13 10:17:34 -070064
Chong Zhang8e89b312015-09-09 15:09:30 -070065 @IntDef(flag = true,
66 value = {
67 CTRL_NONE,
68 CTRL_LEFT,
69 CTRL_RIGHT,
70 CTRL_TOP,
71 CTRL_BOTTOM
72 })
73 @Retention(RetentionPolicy.SOURCE)
74 @interface CtrlType {}
75
76 private static final int CTRL_NONE = 0x0;
77 private static final int CTRL_LEFT = 0x1;
78 private static final int CTRL_RIGHT = 0x2;
79 private static final int CTRL_TOP = 0x4;
80 private static final int CTRL_BOTTOM = 0x8;
81
82 private final WindowManagerService mService;
83 private WindowPositionerEventReceiver mInputEventReceiver;
84 private Display mDisplay;
85 private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
Wale Ogunwale228d4042015-09-13 10:17:34 -070086 private DimLayer mDimLayer;
87 @CtrlType
88 private int mCurrentDimSide;
89 private Rect mTmpRect = new Rect();
90 private int mSideMargin;
Wale Ogunwaleb8051b82015-09-17 15:41:52 -070091 private int mMinVisibleWidth;
92 private int mMinVisibleHeight;
Chong Zhang8e89b312015-09-09 15:09:30 -070093
Chong Zhang3005e752015-09-18 18:46:28 -070094 private Task mTask;
Chong Zhang09b21ef2015-09-14 10:20:21 -070095 private boolean mResizing;
Chong Zhang8e89b312015-09-09 15:09:30 -070096 private final Rect mWindowOriginalBounds = new Rect();
97 private final Rect mWindowDragBounds = new Rect();
98 private float mStartDragX;
99 private float mStartDragY;
100 @CtrlType
101 private int mCtrlType = CTRL_NONE;
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700102 private boolean mDragEnded = false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700103
104 InputChannel mServerChannel;
105 InputChannel mClientChannel;
106 InputApplicationHandle mDragApplicationHandle;
107 InputWindowHandle mDragWindowHandle;
108
Wale Ogunwale4f52bc62015-09-24 13:47:31 -0700109 private final class WindowPositionerEventReceiver extends BatchedInputEventReceiver {
110 public WindowPositionerEventReceiver(
111 InputChannel inputChannel, Looper looper, Choreographer choreographer) {
112 super(inputChannel, looper, choreographer);
Chong Zhang8e89b312015-09-09 15:09:30 -0700113 }
114
115 @Override
116 public void onInputEvent(InputEvent event) {
117 if (!(event instanceof MotionEvent)
118 || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) {
119 return;
120 }
121 final MotionEvent motionEvent = (MotionEvent) event;
122 boolean handled = false;
123
124 try {
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700125 if (mDragEnded) {
126 // The drag has ended but the clean-up message has not been processed by
127 // window manager. Drop events that occur after this until window manager
128 // has a chance to clean-up the input handle.
129 handled = true;
130 return;
131 }
132
Chong Zhang8e89b312015-09-09 15:09:30 -0700133 final float newX = motionEvent.getRawX();
134 final float newY = motionEvent.getRawY();
135
136 switch (motionEvent.getAction()) {
137 case MotionEvent.ACTION_DOWN: {
138 if (DEBUG_TASK_POSITIONING) {
139 Slog.w(TAG, "ACTION_DOWN @ {" + newX + ", " + newY + "}");
140 }
141 } break;
142
143 case MotionEvent.ACTION_MOVE: {
144 if (DEBUG_TASK_POSITIONING){
145 Slog.w(TAG, "ACTION_MOVE @ {" + newX + ", " + newY + "}");
146 }
147 synchronized (mService.mWindowMap) {
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700148 mDragEnded = notifyMoveLocked(newX, newY);
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700149 mTask.getBounds(mTmpRect);
Chong Zhang8e89b312015-09-09 15:09:30 -0700150 }
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700151 if (!mTmpRect.equals(mWindowDragBounds)) {
152 Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER,
153 "wm.TaskPositioner.resizeTask");
154 try {
155 mService.mActivityManager.resizeTask(
156 mTask.mTaskId, mWindowDragBounds, RESIZE_MODE_USER);
157 } catch (RemoteException e) {
158 }
159 Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
160 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700161 } break;
162
163 case MotionEvent.ACTION_UP: {
164 if (DEBUG_TASK_POSITIONING) {
165 Slog.w(TAG, "ACTION_UP @ {" + newX + ", " + newY + "}");
166 }
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700167 mDragEnded = true;
Chong Zhang8e89b312015-09-09 15:09:30 -0700168 } break;
169
170 case MotionEvent.ACTION_CANCEL: {
171 if (DEBUG_TASK_POSITIONING) {
172 Slog.w(TAG, "ACTION_CANCEL @ {" + newX + ", " + newY + "}");
173 }
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700174 mDragEnded = true;
Chong Zhang8e89b312015-09-09 15:09:30 -0700175 } break;
176 }
177
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700178 if (mDragEnded) {
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700179 final boolean wasResizing = mResizing;
Chong Zhang3005e752015-09-18 18:46:28 -0700180 synchronized (mService.mWindowMap) {
181 endDragLocked();
182 }
Chong Zhang09b21ef2015-09-14 10:20:21 -0700183 try {
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700184 if (wasResizing) {
Chong Zhang3005e752015-09-18 18:46:28 -0700185 // We were using fullscreen surface during resizing. Request
186 // resizeTask() one last time to restore surface to window size.
187 mService.mActivityManager.resizeTask(
Chong Zhang6de2ae82015-09-30 18:25:21 -0700188 mTask.mTaskId, mWindowDragBounds, RESIZE_MODE_USER_FORCED);
Chong Zhang3005e752015-09-18 18:46:28 -0700189 }
190
191 if (mCurrentDimSide != CTRL_NONE) {
192 final int createMode = mCurrentDimSide == CTRL_LEFT
193 ? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
194 : DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
195 mService.mActivityManager.moveTaskToDockedStack(
196 mTask.mTaskId, createMode, true /*toTop*/);
197 }
Chong Zhang09b21ef2015-09-14 10:20:21 -0700198 } catch(RemoteException e) {}
Chong Zhang3005e752015-09-18 18:46:28 -0700199
Chong Zhang8e89b312015-09-09 15:09:30 -0700200 // Post back to WM to handle clean-ups. We still need the input
201 // event handler for the last finishInputEvent()!
202 mService.mH.sendEmptyMessage(H.FINISH_TASK_POSITIONING);
203 }
204 handled = true;
205 } catch (Exception e) {
206 Slog.e(TAG, "Exception caught by drag handleMotion", e);
207 } finally {
208 finishInputEvent(event, handled);
209 }
210 }
211 }
212
213 TaskPositioner(WindowManagerService service) {
214 mService = service;
215 }
216
217 /**
218 * @param display The Display that the window being dragged is on.
219 */
220 void register(Display display) {
221 if (DEBUG_TASK_POSITIONING) {
222 Slog.d(TAG, "Registering task positioner");
223 }
224
225 if (mClientChannel != null) {
226 Slog.e(TAG, "Task positioner already registered");
227 return;
228 }
229
230 mDisplay = display;
231 mDisplay.getMetrics(mDisplayMetrics);
232 final InputChannel[] channels = InputChannel.openInputChannelPair(TAG);
233 mServerChannel = channels[0];
234 mClientChannel = channels[1];
235 mService.mInputManager.registerInputChannel(mServerChannel, null);
236
Wale Ogunwale4f52bc62015-09-24 13:47:31 -0700237 mInputEventReceiver = new WindowPositionerEventReceiver(
238 mClientChannel, mService.mH.getLooper(), mService.mChoreographer);
Chong Zhang8e89b312015-09-09 15:09:30 -0700239
240 mDragApplicationHandle = new InputApplicationHandle(null);
241 mDragApplicationHandle.name = TAG;
242 mDragApplicationHandle.dispatchingTimeoutNanos =
243 WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
244
245 mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null,
246 mDisplay.getDisplayId());
247 mDragWindowHandle.name = TAG;
248 mDragWindowHandle.inputChannel = mServerChannel;
249 mDragWindowHandle.layer = getDragLayerLocked();
250 mDragWindowHandle.layoutParamsFlags = 0;
251 mDragWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_DRAG;
252 mDragWindowHandle.dispatchingTimeoutNanos =
253 WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
254 mDragWindowHandle.visible = true;
255 mDragWindowHandle.canReceiveKeys = false;
256 mDragWindowHandle.hasFocus = true;
257 mDragWindowHandle.hasWallpaper = false;
258 mDragWindowHandle.paused = false;
259 mDragWindowHandle.ownerPid = Process.myPid();
260 mDragWindowHandle.ownerUid = Process.myUid();
261 mDragWindowHandle.inputFeatures = 0;
262 mDragWindowHandle.scaleFactor = 1.0f;
263
264 // The drag window cannot receive new touches.
265 mDragWindowHandle.touchableRegion.setEmpty();
266
267 // The drag window covers the entire display
268 mDragWindowHandle.frameLeft = 0;
269 mDragWindowHandle.frameTop = 0;
270 final Point p = new Point();
271 mDisplay.getRealSize(p);
272 mDragWindowHandle.frameRight = p.x;
273 mDragWindowHandle.frameBottom = p.y;
274
275 // Pause rotations before a drag.
276 if (WindowManagerService.DEBUG_ORIENTATION) {
277 Slog.d(TAG, "Pausing rotation during re-position");
278 }
279 mService.pauseRotationLocked();
Wale Ogunwale228d4042015-09-13 10:17:34 -0700280
281 mDimLayer = new DimLayer(mService, this, mDisplay.getDisplayId());
Wale Ogunwale231b06e2015-09-16 12:03:09 -0700282 mSideMargin = mService.dipToPixel(SIDE_MARGIN_DIP, mDisplayMetrics);
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700283 mMinVisibleWidth = mService.dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, mDisplayMetrics);
284 mMinVisibleHeight = mService.dipToPixel(MINIMUM_VISIBLE_HEIGHT_IN_DP, mDisplayMetrics);
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700285
286 mDragEnded = false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700287 }
288
289 void unregister() {
290 if (DEBUG_TASK_POSITIONING) {
291 Slog.d(TAG, "Unregistering task positioner");
292 }
293
294 if (mClientChannel == null) {
295 Slog.e(TAG, "Task positioner not registered");
296 return;
297 }
298
299 mService.mInputManager.unregisterInputChannel(mServerChannel);
300
301 mInputEventReceiver.dispose();
302 mInputEventReceiver = null;
303 mClientChannel.dispose();
304 mServerChannel.dispose();
305 mClientChannel = null;
306 mServerChannel = null;
307
308 mDragWindowHandle = null;
309 mDragApplicationHandle = null;
310 mDisplay = null;
311
Wale Ogunwale228d4042015-09-13 10:17:34 -0700312 if (mDimLayer != null) {
313 mDimLayer.destroySurface();
314 mDimLayer = null;
315 }
316 mCurrentDimSide = CTRL_NONE;
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700317 mDragEnded = true;
Wale Ogunwale228d4042015-09-13 10:17:34 -0700318
Chong Zhang8e89b312015-09-09 15:09:30 -0700319 // Resume rotations after a drag.
320 if (WindowManagerService.DEBUG_ORIENTATION) {
321 Slog.d(TAG, "Resuming rotation after re-position");
322 }
323 mService.resumeRotationLocked();
324 }
325
326 void startDragLocked(WindowState win, boolean resize, float startX, float startY) {
Wale Ogunwale228d4042015-09-13 10:17:34 -0700327 if (DEBUG_TASK_POSITIONING) {
328 Slog.d(TAG, "startDragLocked: win=" + win + ", resize=" + resize
Chong Zhang8e89b312015-09-09 15:09:30 -0700329 + ", {" + startX + ", " + startY + "}");
330 }
331 mCtrlType = CTRL_NONE;
332 if (resize) {
333 final Rect visibleFrame = win.mVisibleFrame;
334 if (startX < visibleFrame.left) {
335 mCtrlType |= CTRL_LEFT;
336 }
337 if (startX > visibleFrame.right) {
338 mCtrlType |= CTRL_RIGHT;
339 }
340 if (startY < visibleFrame.top) {
341 mCtrlType |= CTRL_TOP;
342 }
343 if (startY > visibleFrame.bottom) {
344 mCtrlType |= CTRL_BOTTOM;
345 }
Chong Zhang09b21ef2015-09-14 10:20:21 -0700346 mResizing = true;
Chong Zhang8e89b312015-09-09 15:09:30 -0700347 }
348
Chong Zhang3005e752015-09-18 18:46:28 -0700349 mTask = win.getTask();
Chong Zhang8e89b312015-09-09 15:09:30 -0700350 mStartDragX = startX;
351 mStartDragY = startY;
352
Chong Zhang3005e752015-09-18 18:46:28 -0700353 mService.getTaskBounds(mTask.mTaskId, mWindowOriginalBounds);
354 }
355
356 private void endDragLocked() {
357 mResizing = false;
358 mTask.setDragResizing(false);
Chong Zhang8e89b312015-09-09 15:09:30 -0700359 }
360
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700361 /** Returns true if the move operation should be ended. */
362 private boolean notifyMoveLocked(float x, float y) {
Chong Zhang8e89b312015-09-09 15:09:30 -0700363 if (DEBUG_TASK_POSITIONING) {
364 Slog.d(TAG, "notifyMoveLw: {" + x + "," + y + "}");
365 }
366
367 if (mCtrlType != CTRL_NONE) {
368 // This is a resizing operation.
369 final int deltaX = Math.round(x - mStartDragX);
370 final int deltaY = Math.round(y - mStartDragY);
Chong Zhang8e89b312015-09-09 15:09:30 -0700371 int left = mWindowOriginalBounds.left;
372 int top = mWindowOriginalBounds.top;
373 int right = mWindowOriginalBounds.right;
374 int bottom = mWindowOriginalBounds.bottom;
375 if ((mCtrlType & CTRL_LEFT) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700376 left = Math.min(left + deltaX, right - mMinVisibleWidth);
Chong Zhang8e89b312015-09-09 15:09:30 -0700377 }
378 if ((mCtrlType & CTRL_TOP) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700379 top = Math.min(top + deltaY, bottom - mMinVisibleHeight);
Chong Zhang8e89b312015-09-09 15:09:30 -0700380 }
381 if ((mCtrlType & CTRL_RIGHT) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700382 right = Math.max(left + mMinVisibleWidth, right + deltaX);
Chong Zhang8e89b312015-09-09 15:09:30 -0700383 }
384 if ((mCtrlType & CTRL_BOTTOM) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700385 bottom = Math.max(top + mMinVisibleHeight, bottom + deltaY);
Chong Zhang8e89b312015-09-09 15:09:30 -0700386 }
387 mWindowDragBounds.set(left, top, right, bottom);
Chong Zhang3005e752015-09-18 18:46:28 -0700388 mTask.setDragResizing(true);
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700389 return false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700390 }
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700391
392 // This is a moving operation.
Chong Zhang3005e752015-09-18 18:46:28 -0700393 mTask.mStack.getBounds(mTmpRect);
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700394 mTmpRect.inset(mMinVisibleWidth, mMinVisibleHeight);
395 if (!mTmpRect.contains((int) x, (int) y)) {
396 // We end the moving operation if position is outside the stack bounds.
397 return true;
398 }
399 mWindowDragBounds.set(mWindowOriginalBounds);
400 mWindowDragBounds.offset(Math.round(x - mStartDragX), Math.round(y - mStartDragY));
401 updateDimLayerVisibility((int) x);
402 return false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700403 }
404
Wale Ogunwale228d4042015-09-13 10:17:34 -0700405 private void updateDimLayerVisibility(int x) {
406 @CtrlType
407 int dimSide = getDimSide(x);
408 if (dimSide == mCurrentDimSide) {
409 return;
410 }
411
412 mCurrentDimSide = dimSide;
413
414 if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION updateDimLayerVisibility");
415 SurfaceControl.openTransaction();
416 if (mCurrentDimSide == CTRL_NONE) {
417 mDimLayer.hide();
418 } else {
419 showDimLayer();
420 }
421 SurfaceControl.closeTransaction();
422 }
423
424 /**
425 * Returns the side of the screen the dim layer should be shown.
426 * @param x horizontal coordinate used to determine if the dim layer should be shown
427 * @return Returns {@link #CTRL_LEFT} if the dim layer should be shown on the left half of the
428 * screen, {@link #CTRL_RIGHT} if on the right side, or {@link #CTRL_NONE} if the dim layer
429 * shouldn't be shown.
430 */
431 private int getDimSide(int x) {
Chong Zhang3005e752015-09-18 18:46:28 -0700432 if (mTask.mStack.mStackId != FREEFORM_WORKSPACE_STACK_ID
433 || !mTask.mStack.isFullscreen()
Wale Ogunwale228d4042015-09-13 10:17:34 -0700434 || mService.mCurConfiguration.orientation != ORIENTATION_LANDSCAPE) {
435 return CTRL_NONE;
436 }
437
Chong Zhang3005e752015-09-18 18:46:28 -0700438 mTask.mStack.getBounds(mTmpRect);
Wale Ogunwale228d4042015-09-13 10:17:34 -0700439 if (x - mSideMargin <= mTmpRect.left) {
440 return CTRL_LEFT;
441 }
442 if (x + mSideMargin >= mTmpRect.right) {
443 return CTRL_RIGHT;
444 }
445
446 return CTRL_NONE;
447 }
448
449 private void showDimLayer() {
Chong Zhang3005e752015-09-18 18:46:28 -0700450 mTask.mStack.getBounds(mTmpRect);
Wale Ogunwale228d4042015-09-13 10:17:34 -0700451 if (mCurrentDimSide == CTRL_LEFT) {
452 mTmpRect.right = mTmpRect.centerX();
453 } else if (mCurrentDimSide == CTRL_RIGHT) {
454 mTmpRect.left = mTmpRect.centerX();
455 }
456
457 mDimLayer.setBounds(mTmpRect);
458 mDimLayer.show(getDragLayerLocked(), 0.5f, 0);
459 }
460
461 @Override /** {@link DimLayer.DimLayerUser} */
462 public boolean isFullscreen() {
463 return false;
464 }
465
466 @Override /** {@link DimLayer.DimLayerUser} */
467 public DisplayInfo getDisplayInfo() {
Chong Zhang3005e752015-09-18 18:46:28 -0700468 return mTask.mStack.getDisplayInfo();
Wale Ogunwale228d4042015-09-13 10:17:34 -0700469 }
470
Chong Zhang8e89b312015-09-09 15:09:30 -0700471 private int getDragLayerLocked() {
472 return mService.mPolicy.windowTypeToLayerLw(WindowManager.LayoutParams.TYPE_DRAG)
473 * WindowManagerService.TYPE_LAYER_MULTIPLIER
474 + WindowManagerService.TYPE_LAYER_OFFSET;
475 }
Wale Ogunwale228d4042015-09-13 10:17:34 -0700476}