Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e83327e authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Always show the mouse pointer when there are mouse events" into gingerbread

parents a80f70ed e58fb279
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -2006,14 +2006,6 @@ public final class Settings {
         */
        public static final String POINTER_LOCATION = "pointer_location";

        /**
         * Show mouse pointer on screen?
         * 0 = no
         * 1 = yes
         * @hide
         */
        public static final String MOUSE_POINTER = "mouse_pointer";

        /**
         * Whether to play a sound for low-battery alerts.
         * @hide
+1 −8
Original line number Diff line number Diff line
@@ -370,13 +370,6 @@ public class BluetoothHidService extends IBluetoothHid.Stub {
                    state == BluetoothHid.STATE_CONNECTING ||
                    state == BluetoothHid.STATE_CONNECTED) {
                setHidDevicePriority(device, BluetoothHid.PRIORITY_AUTO_CONNECT);
		if ((device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PERIPHERAL_POINTING_DEVICE) || 
		    (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PERIPHERAL_COMBO_KEYBORD_POINTING)) {
		    Settings.System.putInt(mContext.getContentResolver(), Settings.System.MOUSE_POINTER, 1);
		}		
            }
	    else if (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PERIPHERAL_POINTING_DEVICE) {
		    Settings.System.putInt(mContext.getContentResolver(), Settings.System.MOUSE_POINTER, 0);
        }
            Intent intent = new Intent(BluetoothHid.HID_DEVICE_STATE_CHANGED_ACTION);
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+0 −85
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.MotionEvent;
import android.view.View;

public class MousePointerView extends View {
    private static final String TAG = "MousePointer";

    private float mouseX;
    private float mouseY;
    private float lastX;
    private float lastY;

    private Paint mPaint;
    private Path mPath;

    public MousePointerView(Context c) {
        super(c);
        setFocusable(true);
        mPaint = new Paint();
	mPaint.setAntiAlias(true);
        mPath = new Path();
    }
 
    @Override
    protected void onDraw(Canvas canvas) {
	if (mouseX == 0 && mouseY == 0) {
	}
	else if ((lastX == 0 && lastY == 0) || lastX - mouseX < 10.0f || lastY - mouseY < 10.0f) {
            // Draw mouse pointer
	    mPath.rewind();
            mPath.moveTo(mouseX, mouseY);
            mPath.lineTo(mouseX + 12.0f, mouseY + 12.0f);
            mPath.lineTo(mouseX + 7.0f, mouseY + 12.0f);
            mPath.lineTo(mouseX + 11.0f, mouseY + 20.0f);
            mPath.lineTo(mouseX + 8.0f, mouseY + 21.0f);
            mPath.lineTo(mouseX + 4.0f, mouseY + 13.0f);
            mPath.lineTo(mouseX + 0.0f, mouseY + 17.0f);
            mPath.close();
            mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            mPaint.setStrokeWidth(1);
            mPaint.setColor(0xffffffff);
            canvas.drawPath(mPath, mPaint);
	    mPaint.setStyle(Paint.Style.STROKE);
	    mPaint.setStrokeWidth(1);
            mPaint.setColor(0xff000000);
	    mPath.offset(0,0);
	    canvas.drawPath(mPath, mPaint);
	}
    }
    
    public void addTouchEvent(MotionEvent event) {
	lastX = mouseX;
	lastY = mouseY;
	mouseX = event.getX();
	mouseY = event.getY();
	postInvalidate();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        addTouchEvent(event);
        return true;
    }
}
+280 B
Loading image diff...
+0 −76
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.telephony.ITelephony;
import com.android.internal.view.BaseInputHandler;
import com.android.internal.widget.PointerLocationView;
import com.android.internal.widget.MousePointerView;

import android.util.Config;
import android.util.EventLog;
@@ -244,23 +243,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final long NEXT_DURATION = 400;
    private boolean mBottomBar;
    
    int mousePointerMode = 0;
    MousePointerView mousePointerView = null;
    InputChannel mousePointerInputChannel;

    private final InputHandler mousePointerInputHandler = new BaseInputHandler() {
        @Override
        public void handleMotion(MotionEvent event, Runnable finishedCallback) {
            finishedCallback.run();
            
            synchronized (mLock) {
                if ((mousePointerView != null) && ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE)) {
                    mousePointerView.addTouchEvent(event);
                }
            }
        }
    };

    int mPointerLocationMode = 0;
    PointerLocationView mPointerLocationView = null;
    InputChannel mPointerLocationInputChannel;
@@ -361,8 +343,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.System.SCREEN_OFF_TIMEOUT), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.POINTER_LOCATION), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.MOUSE_POINTER), false, this);
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
            resolver.registerContentObserver(Settings.System.getUriFor(
@@ -767,8 +747,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        boolean updateRotation = false;
        View addView = null;
        View removeView = null;
        View addMouseView = null;
        View removeMouseView = null;
        synchronized (mLock) {
            mEndcallBehavior = Settings.System.getInt(resolver,
                    Settings.System.END_BUTTON_BEHAVIOR,
@@ -793,22 +771,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                mAccelerometerDefault = accelerometerDefault;
                updateOrientationListenerLp();
            }
            if (mSystemReady) {
                int mousePointer = Settings.System.getInt(resolver,
                        Settings.System.MOUSE_POINTER, 0);
                if (mousePointerMode != mousePointer) {
                    mousePointerMode = mousePointer;
                    if (mousePointer != 0) {
                        if (mousePointerView == null) {
                            mousePointerView = new MousePointerView(mContext);
                            addMouseView = mousePointerView;
                        }
                    } else {
                        removeMouseView = mousePointerView;
                        mousePointerView = null;
                    }
                }
            }
            if (mSystemReady) {
                int pointerLocation = Settings.System.getInt(resolver,
                        Settings.System.POINTER_LOCATION, 0);
@@ -840,44 +802,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (updateRotation) {
            updateRotation(0);
        }
        if (addMouseView != null) {
            WindowManager.LayoutParams lpMouse = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT);
            lpMouse.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
            lpMouse.flags = 
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
            lpMouse.format = PixelFormat.TRANSLUCENT;
            lpMouse.setTitle("MousePointer");
            WindowManagerImpl wmMouse = (WindowManagerImpl)
                    mContext.getSystemService(Context.WINDOW_SERVICE);
            wmMouse.addView(addMouseView, lpMouse);
            
            if (mousePointerInputChannel == null) {
                try {
                    mousePointerInputChannel =
                        mWindowManager.monitorInput("MousePointerView");
                    InputQueue.registerInputChannel(mousePointerInputChannel,
                            mousePointerInputHandler, mHandler.getLooper().getQueue());
                } catch (RemoteException ex) {
                    Slog.e(TAG, "Could not set up input monitoring channel for MousePointer.",
                            ex);
                }
            }
        }
        if (removeMouseView != null) {
            if (mousePointerInputChannel != null) {
                InputQueue.unregisterInputChannel(mousePointerInputChannel);
                mousePointerInputChannel.dispose();
                mousePointerInputChannel = null;
            }
            
            WindowManagerImpl wmMouse = (WindowManagerImpl)
                    mContext.getSystemService(Context.WINDOW_SERVICE);
            wmMouse.removeView(removeMouseView);
        }
        if (addView != null) {
            WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.MATCH_PARENT,
Loading