diff options
Diffstat (limited to 'services/java/com/android/server/WindowManagerService.java')
-rw-r--r-- | services/java/com/android/server/WindowManagerService.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index efd0bb49dc1b..9e9d55a4db93 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -60,6 +60,7 @@ import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.Region; @@ -372,6 +373,13 @@ public class WindowManagerService extends IWindowManager.Stub boolean mBlurShown; Watermark mWatermark; + Surface mMouseSurface; + int mShowMouse = 0; + private int mMlx; + private int mMly; + int mMlw; + int mMlh; + int mTransactionSequence = 0; final float[] mTmpFloats = new float[9]; @@ -5400,6 +5408,30 @@ public class WindowManagerService extends IWindowManager.Stub } } + public boolean moveMouseSurface(int x, int y){ + if (mMouseSurface != null && (x != 0 || y != 0)) { + synchronized(mWindowMap) { + Surface.openTransaction(); + WindowState top = (WindowState)mWindows.get(mWindows.size() - 1); + try { + int mDisplayWidth = mDisplay.getWidth(); + mMlx = x; + mMly = y; + mMouseSurface.setPosition(mMlx, mMly); + mMouseSurface.setLayer(top.mAnimLayer + 1); + if (mShowMouse != 1) { + mMouseSurface.show(); + mShowMouse = 1; + } + } catch ( RuntimeException e) { + Slog.e(TAG, "Failure showing mouse surface",e); + } + Surface.closeTransaction(); + } + } + return true; + } + /** * Injects a keystroke event into the UI. * Even when sync is false, this method may block while waiting for current @@ -8497,6 +8529,54 @@ public class WindowManagerService extends IWindowManager.Stub createWatermark = true; } + if (mMouseSurface == null) { + int mMx, mMy, mMw, mMh; + Canvas mCanvas; + Path mPath = new Path(); + mMw = 12; + mMh = 20; + mMx = (mDisplay.getWidth() - mMw) / 2; + mMy = (mDisplay.getHeight() - mMh) / 2; + try { + /* + *First Mouse event, create Surface + */ + mMouseSurface = + new Surface(mFxSession, + 0, -1, mMw, mMh, + PixelFormat.TRANSPARENT, + Surface.FX_SURFACE_NORMAL); + mCanvas = mMouseSurface.lockCanvas(null); + Paint tPaint = new Paint(); + tPaint.setStyle(Paint.Style.STROKE); + tPaint.setStrokeWidth(2); + tPaint.setColor(0xffffffff); + mPath.moveTo(0.0f, 0.0f); + mPath.lineTo(12.0f, 12.0f); + mPath.lineTo(7.0f, 12.0f); + mPath.lineTo(11.0f, 20.0f); + mPath.lineTo(8.0f, 21.0f); + mPath.lineTo(4.0f, 13.0f); + mPath.lineTo(0.0f, 17.0f); + mPath.close(); + mCanvas.clipPath(mPath); + mCanvas.drawColor(0xff000000); + mCanvas.drawPath(mPath, tPaint); + + mMouseSurface.unlockCanvasAndPost(mCanvas); + mMouseSurface.openTransaction(); + mMouseSurface.setSize(mMw, mMh); + mMouseSurface.closeTransaction(); + + } catch (Exception e) { + Slog.e(TAG, "Exception creating mouse surface",e); + } + mMlx = mMx; + mMly = mMy; + mMlw = mMw; + mMlh = mMh; + } + if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION"); Surface.openTransaction(); |