blob: dd47e7a46777acdcf76dfab4302b3fa0307759d9 [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 Ogunwale3797c222015-10-27 14:21:58 -070021import static android.app.ActivityManager.StackId.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;
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -070026import static com.android.server.wm.DimLayer.RESIZING_HINT_ALPHA;
27import static com.android.server.wm.DimLayer.RESIZING_HINT_DURATION_MS;
Chong Zhang8e89b312015-09-09 15:09:30 -070028import static com.android.server.wm.WindowManagerService.DEBUG_TASK_POSITIONING;
Wale Ogunwale228d4042015-09-13 10:17:34 -070029import static com.android.server.wm.WindowManagerService.SHOW_TRANSACTIONS;
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -070030import static com.android.server.wm.WindowManagerService.dipToPixel;
Wale Ogunwale231b06e2015-09-16 12:03:09 -070031import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_HEIGHT_IN_DP;
32import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_WIDTH_IN_DP;
Chong Zhang8e89b312015-09-09 15:09:30 -070033
34import android.annotation.IntDef;
35import android.graphics.Point;
36import android.graphics.Rect;
37import android.os.Looper;
38import android.os.Process;
39import android.os.RemoteException;
Wale Ogunwalecad05a02015-09-25 10:41:44 -070040import android.os.Trace;
Chong Zhang8e89b312015-09-09 15:09:30 -070041import android.util.DisplayMetrics;
42import android.util.Slog;
Wale Ogunwale4f52bc62015-09-24 13:47:31 -070043import android.view.Choreographer;
Chong Zhang8e89b312015-09-09 15:09:30 -070044import android.view.Display;
Wale Ogunwale228d4042015-09-13 10:17:34 -070045import android.view.DisplayInfo;
Chong Zhang8e89b312015-09-09 15:09:30 -070046import android.view.InputChannel;
47import android.view.InputDevice;
48import android.view.InputEvent;
Wale Ogunwale4f52bc62015-09-24 13:47:31 -070049import android.view.BatchedInputEventReceiver;
Chong Zhang8e89b312015-09-09 15:09:30 -070050import android.view.MotionEvent;
Wale Ogunwale228d4042015-09-13 10:17:34 -070051import android.view.SurfaceControl;
Chong Zhang8e89b312015-09-09 15:09:30 -070052import android.view.WindowManager;
53
Wale Ogunwale228d4042015-09-13 10:17:34 -070054import com.android.server.input.InputApplicationHandle;
55import com.android.server.input.InputWindowHandle;
56import com.android.server.wm.WindowManagerService.H;
57
58import java.lang.annotation.Retention;
59import java.lang.annotation.RetentionPolicy;
60
61class TaskPositioner implements DimLayer.DimLayerUser {
Chong Zhang8e89b312015-09-09 15:09:30 -070062 private static final String TAG = "TaskPositioner";
63
Wale Ogunwale228d4042015-09-13 10:17:34 -070064 // The margin the pointer position has to be within the side of the screen to be
65 // considered at the side of the screen.
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -070066 static final int SIDE_MARGIN_DIP = 100;
Wale Ogunwale228d4042015-09-13 10:17:34 -070067
Chong Zhang8e89b312015-09-09 15:09:30 -070068 @IntDef(flag = true,
69 value = {
70 CTRL_NONE,
71 CTRL_LEFT,
72 CTRL_RIGHT,
73 CTRL_TOP,
74 CTRL_BOTTOM
75 })
76 @Retention(RetentionPolicy.SOURCE)
77 @interface CtrlType {}
78
79 private static final int CTRL_NONE = 0x0;
80 private static final int CTRL_LEFT = 0x1;
81 private static final int CTRL_RIGHT = 0x2;
82 private static final int CTRL_TOP = 0x4;
83 private static final int CTRL_BOTTOM = 0x8;
84
85 private final WindowManagerService mService;
86 private WindowPositionerEventReceiver mInputEventReceiver;
87 private Display mDisplay;
88 private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
Wale Ogunwale228d4042015-09-13 10:17:34 -070089 private DimLayer mDimLayer;
90 @CtrlType
91 private int mCurrentDimSide;
92 private Rect mTmpRect = new Rect();
93 private int mSideMargin;
Wale Ogunwaleb8051b82015-09-17 15:41:52 -070094 private int mMinVisibleWidth;
95 private int mMinVisibleHeight;
Chong Zhang8e89b312015-09-09 15:09:30 -070096
Chong Zhang3005e752015-09-18 18:46:28 -070097 private Task mTask;
Chong Zhang09b21ef2015-09-14 10:20:21 -070098 private boolean mResizing;
Chong Zhang8e89b312015-09-09 15:09:30 -070099 private final Rect mWindowOriginalBounds = new Rect();
100 private final Rect mWindowDragBounds = new Rect();
101 private float mStartDragX;
102 private float mStartDragY;
103 @CtrlType
104 private int mCtrlType = CTRL_NONE;
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700105 private boolean mDragEnded = false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700106
107 InputChannel mServerChannel;
108 InputChannel mClientChannel;
109 InputApplicationHandle mDragApplicationHandle;
110 InputWindowHandle mDragWindowHandle;
111
Wale Ogunwale4f52bc62015-09-24 13:47:31 -0700112 private final class WindowPositionerEventReceiver extends BatchedInputEventReceiver {
113 public WindowPositionerEventReceiver(
114 InputChannel inputChannel, Looper looper, Choreographer choreographer) {
115 super(inputChannel, looper, choreographer);
Chong Zhang8e89b312015-09-09 15:09:30 -0700116 }
117
118 @Override
119 public void onInputEvent(InputEvent event) {
120 if (!(event instanceof MotionEvent)
121 || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) {
122 return;
123 }
124 final MotionEvent motionEvent = (MotionEvent) event;
125 boolean handled = false;
126
127 try {
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700128 if (mDragEnded) {
129 // The drag has ended but the clean-up message has not been processed by
130 // window manager. Drop events that occur after this until window manager
131 // has a chance to clean-up the input handle.
132 handled = true;
133 return;
134 }
135
Chong Zhang8e89b312015-09-09 15:09:30 -0700136 final float newX = motionEvent.getRawX();
137 final float newY = motionEvent.getRawY();
138
139 switch (motionEvent.getAction()) {
140 case MotionEvent.ACTION_DOWN: {
141 if (DEBUG_TASK_POSITIONING) {
142 Slog.w(TAG, "ACTION_DOWN @ {" + newX + ", " + newY + "}");
143 }
144 } break;
145
146 case MotionEvent.ACTION_MOVE: {
147 if (DEBUG_TASK_POSITIONING){
148 Slog.w(TAG, "ACTION_MOVE @ {" + newX + ", " + newY + "}");
149 }
150 synchronized (mService.mWindowMap) {
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700151 mDragEnded = notifyMoveLocked(newX, newY);
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800152 mTask.getDimBounds(mTmpRect);
Chong Zhang8e89b312015-09-09 15:09:30 -0700153 }
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700154 if (!mTmpRect.equals(mWindowDragBounds)) {
155 Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER,
156 "wm.TaskPositioner.resizeTask");
157 try {
158 mService.mActivityManager.resizeTask(
159 mTask.mTaskId, mWindowDragBounds, RESIZE_MODE_USER);
160 } catch (RemoteException e) {
161 }
162 Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
163 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700164 } break;
165
166 case MotionEvent.ACTION_UP: {
167 if (DEBUG_TASK_POSITIONING) {
168 Slog.w(TAG, "ACTION_UP @ {" + newX + ", " + newY + "}");
169 }
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700170 mDragEnded = true;
Chong Zhang8e89b312015-09-09 15:09:30 -0700171 } break;
172
173 case MotionEvent.ACTION_CANCEL: {
174 if (DEBUG_TASK_POSITIONING) {
175 Slog.w(TAG, "ACTION_CANCEL @ {" + newX + ", " + newY + "}");
176 }
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700177 mDragEnded = true;
Chong Zhang8e89b312015-09-09 15:09:30 -0700178 } break;
179 }
180
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700181 if (mDragEnded) {
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700182 final boolean wasResizing = mResizing;
Chong Zhang3005e752015-09-18 18:46:28 -0700183 synchronized (mService.mWindowMap) {
184 endDragLocked();
185 }
Chong Zhang09b21ef2015-09-14 10:20:21 -0700186 try {
Wale Ogunwale04ad7b12015-10-02 12:43:27 -0700187 if (wasResizing) {
Chong Zhang3005e752015-09-18 18:46:28 -0700188 // We were using fullscreen surface during resizing. Request
189 // resizeTask() one last time to restore surface to window size.
190 mService.mActivityManager.resizeTask(
Chong Zhang6de2ae82015-09-30 18:25:21 -0700191 mTask.mTaskId, mWindowDragBounds, RESIZE_MODE_USER_FORCED);
Chong Zhang3005e752015-09-18 18:46:28 -0700192 }
193
194 if (mCurrentDimSide != CTRL_NONE) {
195 final int createMode = mCurrentDimSide == CTRL_LEFT
196 ? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
197 : DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
198 mService.mActivityManager.moveTaskToDockedStack(
199 mTask.mTaskId, createMode, true /*toTop*/);
200 }
Chong Zhang09b21ef2015-09-14 10:20:21 -0700201 } catch(RemoteException e) {}
Chong Zhang3005e752015-09-18 18:46:28 -0700202
Chong Zhang8e89b312015-09-09 15:09:30 -0700203 // Post back to WM to handle clean-ups. We still need the input
204 // event handler for the last finishInputEvent()!
205 mService.mH.sendEmptyMessage(H.FINISH_TASK_POSITIONING);
206 }
207 handled = true;
208 } catch (Exception e) {
209 Slog.e(TAG, "Exception caught by drag handleMotion", e);
210 } finally {
211 finishInputEvent(event, handled);
212 }
213 }
214 }
215
216 TaskPositioner(WindowManagerService service) {
217 mService = service;
218 }
219
220 /**
221 * @param display The Display that the window being dragged is on.
222 */
223 void register(Display display) {
224 if (DEBUG_TASK_POSITIONING) {
225 Slog.d(TAG, "Registering task positioner");
226 }
227
228 if (mClientChannel != null) {
229 Slog.e(TAG, "Task positioner already registered");
230 return;
231 }
232
233 mDisplay = display;
234 mDisplay.getMetrics(mDisplayMetrics);
235 final InputChannel[] channels = InputChannel.openInputChannelPair(TAG);
236 mServerChannel = channels[0];
237 mClientChannel = channels[1];
238 mService.mInputManager.registerInputChannel(mServerChannel, null);
239
Wale Ogunwale4f52bc62015-09-24 13:47:31 -0700240 mInputEventReceiver = new WindowPositionerEventReceiver(
241 mClientChannel, mService.mH.getLooper(), mService.mChoreographer);
Chong Zhang8e89b312015-09-09 15:09:30 -0700242
243 mDragApplicationHandle = new InputApplicationHandle(null);
244 mDragApplicationHandle.name = TAG;
245 mDragApplicationHandle.dispatchingTimeoutNanos =
246 WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
247
248 mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null,
249 mDisplay.getDisplayId());
250 mDragWindowHandle.name = TAG;
251 mDragWindowHandle.inputChannel = mServerChannel;
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -0700252 mDragWindowHandle.layer = mService.getDragLayerLocked();
Chong Zhang8e89b312015-09-09 15:09:30 -0700253 mDragWindowHandle.layoutParamsFlags = 0;
254 mDragWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_DRAG;
255 mDragWindowHandle.dispatchingTimeoutNanos =
256 WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
257 mDragWindowHandle.visible = true;
258 mDragWindowHandle.canReceiveKeys = false;
259 mDragWindowHandle.hasFocus = true;
260 mDragWindowHandle.hasWallpaper = false;
261 mDragWindowHandle.paused = false;
262 mDragWindowHandle.ownerPid = Process.myPid();
263 mDragWindowHandle.ownerUid = Process.myUid();
264 mDragWindowHandle.inputFeatures = 0;
265 mDragWindowHandle.scaleFactor = 1.0f;
266
267 // The drag window cannot receive new touches.
268 mDragWindowHandle.touchableRegion.setEmpty();
269
270 // The drag window covers the entire display
271 mDragWindowHandle.frameLeft = 0;
272 mDragWindowHandle.frameTop = 0;
273 final Point p = new Point();
274 mDisplay.getRealSize(p);
275 mDragWindowHandle.frameRight = p.x;
276 mDragWindowHandle.frameBottom = p.y;
277
278 // Pause rotations before a drag.
279 if (WindowManagerService.DEBUG_ORIENTATION) {
280 Slog.d(TAG, "Pausing rotation during re-position");
281 }
282 mService.pauseRotationLocked();
Wale Ogunwale228d4042015-09-13 10:17:34 -0700283
284 mDimLayer = new DimLayer(mService, this, mDisplay.getDisplayId());
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -0700285 mSideMargin = dipToPixel(SIDE_MARGIN_DIP, mDisplayMetrics);
286 mMinVisibleWidth = dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, mDisplayMetrics);
287 mMinVisibleHeight = dipToPixel(MINIMUM_VISIBLE_HEIGHT_IN_DP, mDisplayMetrics);
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700288
289 mDragEnded = false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700290 }
291
292 void unregister() {
293 if (DEBUG_TASK_POSITIONING) {
294 Slog.d(TAG, "Unregistering task positioner");
295 }
296
297 if (mClientChannel == null) {
298 Slog.e(TAG, "Task positioner not registered");
299 return;
300 }
301
302 mService.mInputManager.unregisterInputChannel(mServerChannel);
303
304 mInputEventReceiver.dispose();
305 mInputEventReceiver = null;
306 mClientChannel.dispose();
307 mServerChannel.dispose();
308 mClientChannel = null;
309 mServerChannel = null;
310
311 mDragWindowHandle = null;
312 mDragApplicationHandle = null;
313 mDisplay = null;
314
Wale Ogunwale228d4042015-09-13 10:17:34 -0700315 if (mDimLayer != null) {
316 mDimLayer.destroySurface();
317 mDimLayer = null;
318 }
319 mCurrentDimSide = CTRL_NONE;
Wale Ogunwale6a804b82015-09-23 21:04:21 -0700320 mDragEnded = true;
Wale Ogunwale228d4042015-09-13 10:17:34 -0700321
Chong Zhang8e89b312015-09-09 15:09:30 -0700322 // Resume rotations after a drag.
323 if (WindowManagerService.DEBUG_ORIENTATION) {
324 Slog.d(TAG, "Resuming rotation after re-position");
325 }
326 mService.resumeRotationLocked();
327 }
328
329 void startDragLocked(WindowState win, boolean resize, float startX, float startY) {
Wale Ogunwale228d4042015-09-13 10:17:34 -0700330 if (DEBUG_TASK_POSITIONING) {
331 Slog.d(TAG, "startDragLocked: win=" + win + ", resize=" + resize
Chong Zhang8e89b312015-09-09 15:09:30 -0700332 + ", {" + startX + ", " + startY + "}");
333 }
334 mCtrlType = CTRL_NONE;
335 if (resize) {
336 final Rect visibleFrame = win.mVisibleFrame;
337 if (startX < visibleFrame.left) {
338 mCtrlType |= CTRL_LEFT;
339 }
340 if (startX > visibleFrame.right) {
341 mCtrlType |= CTRL_RIGHT;
342 }
343 if (startY < visibleFrame.top) {
344 mCtrlType |= CTRL_TOP;
345 }
346 if (startY > visibleFrame.bottom) {
347 mCtrlType |= CTRL_BOTTOM;
348 }
Chong Zhang09b21ef2015-09-14 10:20:21 -0700349 mResizing = true;
Chong Zhang8e89b312015-09-09 15:09:30 -0700350 }
351
Chong Zhang3005e752015-09-18 18:46:28 -0700352 mTask = win.getTask();
Chong Zhang8e89b312015-09-09 15:09:30 -0700353 mStartDragX = startX;
354 mStartDragY = startY;
355
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800356 // Use the visible bounds, not the original task bounds. The cursor
357 // movement should be calculated relative to the visible bounds.
358 mWindowOriginalBounds.set(win.mVisibleFrame);
Chong Zhang3005e752015-09-18 18:46:28 -0700359 }
360
361 private void endDragLocked() {
362 mResizing = false;
363 mTask.setDragResizing(false);
Chong Zhang8e89b312015-09-09 15:09:30 -0700364 }
365
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700366 /** Returns true if the move operation should be ended. */
367 private boolean notifyMoveLocked(float x, float y) {
Chong Zhang8e89b312015-09-09 15:09:30 -0700368 if (DEBUG_TASK_POSITIONING) {
369 Slog.d(TAG, "notifyMoveLw: {" + x + "," + y + "}");
370 }
371
372 if (mCtrlType != CTRL_NONE) {
373 // This is a resizing operation.
374 final int deltaX = Math.round(x - mStartDragX);
375 final int deltaY = Math.round(y - mStartDragY);
Chong Zhang8e89b312015-09-09 15:09:30 -0700376 int left = mWindowOriginalBounds.left;
377 int top = mWindowOriginalBounds.top;
378 int right = mWindowOriginalBounds.right;
379 int bottom = mWindowOriginalBounds.bottom;
380 if ((mCtrlType & CTRL_LEFT) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700381 left = Math.min(left + deltaX, right - mMinVisibleWidth);
Chong Zhang8e89b312015-09-09 15:09:30 -0700382 }
383 if ((mCtrlType & CTRL_TOP) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700384 top = Math.min(top + deltaY, bottom - mMinVisibleHeight);
Chong Zhang8e89b312015-09-09 15:09:30 -0700385 }
386 if ((mCtrlType & CTRL_RIGHT) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700387 right = Math.max(left + mMinVisibleWidth, right + deltaX);
Chong Zhang8e89b312015-09-09 15:09:30 -0700388 }
389 if ((mCtrlType & CTRL_BOTTOM) != 0) {
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700390 bottom = Math.max(top + mMinVisibleHeight, bottom + deltaY);
Chong Zhang8e89b312015-09-09 15:09:30 -0700391 }
392 mWindowDragBounds.set(left, top, right, bottom);
Chong Zhang3005e752015-09-18 18:46:28 -0700393 mTask.setDragResizing(true);
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700394 return false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700395 }
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700396
397 // This is a moving operation.
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800398 mTask.mStack.getDimBounds(mTmpRect);
Wale Ogunwaleb8051b82015-09-17 15:41:52 -0700399 mTmpRect.inset(mMinVisibleWidth, mMinVisibleHeight);
400 if (!mTmpRect.contains((int) x, (int) y)) {
401 // We end the moving operation if position is outside the stack bounds.
402 return true;
403 }
404 mWindowDragBounds.set(mWindowOriginalBounds);
405 mWindowDragBounds.offset(Math.round(x - mStartDragX), Math.round(y - mStartDragY));
406 updateDimLayerVisibility((int) x);
407 return false;
Chong Zhang8e89b312015-09-09 15:09:30 -0700408 }
409
Wale Ogunwale228d4042015-09-13 10:17:34 -0700410 private void updateDimLayerVisibility(int x) {
411 @CtrlType
412 int dimSide = getDimSide(x);
413 if (dimSide == mCurrentDimSide) {
414 return;
415 }
416
417 mCurrentDimSide = dimSide;
418
419 if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION updateDimLayerVisibility");
420 SurfaceControl.openTransaction();
421 if (mCurrentDimSide == CTRL_NONE) {
422 mDimLayer.hide();
423 } else {
424 showDimLayer();
425 }
426 SurfaceControl.closeTransaction();
427 }
428
429 /**
430 * Returns the side of the screen the dim layer should be shown.
431 * @param x horizontal coordinate used to determine if the dim layer should be shown
432 * @return Returns {@link #CTRL_LEFT} if the dim layer should be shown on the left half of the
433 * screen, {@link #CTRL_RIGHT} if on the right side, or {@link #CTRL_NONE} if the dim layer
434 * shouldn't be shown.
435 */
436 private int getDimSide(int x) {
Chong Zhang3005e752015-09-18 18:46:28 -0700437 if (mTask.mStack.mStackId != FREEFORM_WORKSPACE_STACK_ID
438 || !mTask.mStack.isFullscreen()
Wale Ogunwale228d4042015-09-13 10:17:34 -0700439 || mService.mCurConfiguration.orientation != ORIENTATION_LANDSCAPE) {
440 return CTRL_NONE;
441 }
442
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800443 mTask.mStack.getDimBounds(mTmpRect);
Wale Ogunwale228d4042015-09-13 10:17:34 -0700444 if (x - mSideMargin <= mTmpRect.left) {
445 return CTRL_LEFT;
446 }
447 if (x + mSideMargin >= mTmpRect.right) {
448 return CTRL_RIGHT;
449 }
450
451 return CTRL_NONE;
452 }
453
454 private void showDimLayer() {
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800455 mTask.mStack.getDimBounds(mTmpRect);
Wale Ogunwale228d4042015-09-13 10:17:34 -0700456 if (mCurrentDimSide == CTRL_LEFT) {
457 mTmpRect.right = mTmpRect.centerX();
458 } else if (mCurrentDimSide == CTRL_RIGHT) {
459 mTmpRect.left = mTmpRect.centerX();
460 }
461
462 mDimLayer.setBounds(mTmpRect);
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -0700463 mDimLayer.show(mService.getDragLayerLocked(), RESIZING_HINT_ALPHA,
464 RESIZING_HINT_DURATION_MS);
Wale Ogunwale228d4042015-09-13 10:17:34 -0700465 }
466
467 @Override /** {@link DimLayer.DimLayerUser} */
468 public boolean isFullscreen() {
469 return false;
470 }
471
472 @Override /** {@link DimLayer.DimLayerUser} */
473 public DisplayInfo getDisplayInfo() {
Chong Zhang3005e752015-09-18 18:46:28 -0700474 return mTask.mStack.getDisplayInfo();
Wale Ogunwale228d4042015-09-13 10:17:34 -0700475 }
476
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700477 @Override
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800478 public void getDimBounds(Rect out) {
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700479 // This dim layer user doesn't need this.
480 }
481
482 @Override
483 public String toShortString() {
484 return TAG;
485 }
Wale Ogunwale228d4042015-09-13 10:17:34 -0700486}