Merge
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 03 Apr 2013 17:55:14 -0400
changeset 127465 2a547aac01cd91ee2b4c306f15ad3ea1ae8fdfb0
parent 127462 f20b0ce9e5280e9add20742262aa90440404f9cc (current diff)
parent 127464 6348af4fe6aad522b35859d48fdbfb7562f1f751 (diff)
child 127510 475dc5f51bdba58f0042b460e6e65a83c0e9fc2b
push id24505
push userkgupta@mozilla.com
push dateWed, 03 Apr 2013 21:55:59 +0000
treeherdermozilla-central@2a547aac01cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -447,17 +447,21 @@ abstract public class BrowserApp extends
         ((GeckoApp.MainLayout) mMainLayout).setTouchEventInterceptor(new HideTabsTouchListener());
         ((GeckoApp.MainLayout) mMainLayout).setMotionEventInterceptor(new MotionEventInterceptor() {
             @Override
             public boolean onInterceptMotionEvent(View view, MotionEvent event) {
                 // If we get a gamepad panning MotionEvent while the focus is not on the layerview,
                 // put the focus on the layerview and carry on
                 LayerView layerView = mLayerView;
                 if (layerView != null && !layerView.hasFocus() && GamepadUtils.isPanningControl(event)) {
-                    layerView.requestFocus();
+                    if (Boolean.FALSE.equals(mAboutHomeShowing)) {
+                        layerView.requestFocus();
+                    } else {
+                        mAboutHomeContent.requestFocus();
+                    }
                 }
                 return false;
             }
         });
 
 
         mBrowserToolbar = new BrowserToolbar(this);
         mBrowserToolbar.from(actionBar);
--- a/mobile/android/base/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/gfx/JavaPanZoomController.java
@@ -7,16 +7,17 @@ package org.mozilla.gecko.gfx;
 
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.ZoomConstraints;
 import org.mozilla.gecko.util.EventDispatcher;
 import org.mozilla.gecko.util.FloatUtils;
+import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import org.json.JSONObject;
 
 import android.graphics.PointF;
 import android.graphics.RectF;
 import android.os.Build;
@@ -505,44 +506,35 @@ class JavaPanZoomController
 
             scrollBy(scrollX * MAX_SCROLL, scrollY * MAX_SCROLL);
             bounce();
             return true;
         }
         return false;
     }
 
-    private float filterDeadZone(float value, InputDevice.MotionRange range) {
-        // The 1e-2 here should really be range.getFlat() + range.getFuzz() but the
-        // values those functions return on the Ouya are zero so we're just hard-coding
-        // it for now.
-        if (Math.abs(value) < 1e-2) {
-            return 0;
-        }
-        return value;
+    private float filterDeadZone(MotionEvent event, int axis) {
+        return (GamepadUtils.isValueInDeadZone(event, axis) ? 0 : event.getAxisValue(axis));
     }
 
-    private float normalizeJoystickScroll(float value, InputDevice.MotionRange range) {
-        return filterDeadZone(value, range) * MAX_SCROLL;
+    private float normalizeJoystickScroll(MotionEvent event, int axis) {
+        return filterDeadZone(event, axis) * MAX_SCROLL;
     }
 
-    private float normalizeJoystickZoom(float value, InputDevice.MotionRange range) {
+    private float normalizeJoystickZoom(MotionEvent event, int axis) {
         // negate MAX_ZOOM_DELTA so that pushing up on the stick zooms in
-        return filterDeadZone(value, range) * -MAX_ZOOM_DELTA;
+        return filterDeadZone(event, axis) * -MAX_ZOOM_DELTA;
     }
 
     // Since this event is a position-based event rather than a motion-based event, we need to
     // set up an AUTONAV animation to keep scrolling even while we don't get events.
     private boolean handleJoystickNav(MotionEvent event) {
-        float velocityX = normalizeJoystickScroll(event.getAxisValue(MotionEvent.AXIS_X),
-                                                  event.getDevice().getMotionRange(MotionEvent.AXIS_X));
-        float velocityY = normalizeJoystickScroll(event.getAxisValue(MotionEvent.AXIS_Y),
-                                                  event.getDevice().getMotionRange(MotionEvent.AXIS_Y));
-        float zoomDelta = normalizeJoystickZoom(event.getAxisValue(MotionEvent.AXIS_RZ),
-                                                event.getDevice().getMotionRange(MotionEvent.AXIS_RZ));
+        float velocityX = normalizeJoystickScroll(event, MotionEvent.AXIS_X);
+        float velocityY = normalizeJoystickScroll(event, MotionEvent.AXIS_Y);
+        float zoomDelta = normalizeJoystickZoom(event, MotionEvent.AXIS_RZ);
 
         if (velocityX == 0 && velocityY == 0 && zoomDelta == 0) {
             if (mState == PanZoomState.AUTONAV) {
                 bounce(); // if not needed, this will automatically go to state NOTHING
                 return true;
             }
             return false;
         }
--- a/mobile/android/base/util/GamepadUtils.java
+++ b/mobile/android/base/util/GamepadUtils.java
@@ -34,21 +34,38 @@ public final class GamepadUtils {
     public static boolean isActionKeyDown(KeyEvent event) {
         return isActionKey(event) && event.getAction() == KeyEvent.ACTION_DOWN;
     }
 
     public static boolean isBackKey(KeyEvent event) {
         return (isGamepadKey(event) && (event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_B));
     }
 
+    public static boolean isValueInDeadZone(MotionEvent event, int axis) {
+        float value = event.getAxisValue(axis);
+        // The 1e-2 here should really be range.getFlat() + range.getFuzz() (where range is
+        // event.getDevice().getMotionRange(axis)), but the values those functions return
+        // on the Ouya are zero so we're just hard-coding it for now.
+        return (Math.abs(value) < 1e-2);
+    }
+
     public static boolean isPanningControl(MotionEvent event) {
-        if (Build.VERSION.SDK_INT >= 12) {
-            return (event.getSource() & InputDevice.SOURCE_CLASS_MASK) == InputDevice.SOURCE_CLASS_JOYSTICK;
+        if (Build.VERSION.SDK_INT < 12) {
+            return false;
+        }
+        if ((event.getSource() & InputDevice.SOURCE_CLASS_MASK) != InputDevice.SOURCE_CLASS_JOYSTICK) {
+            return false;
         }
-        return false;
+        if (isValueInDeadZone(event, MotionEvent.AXIS_X)
+                && isValueInDeadZone(event, MotionEvent.AXIS_Y)
+                && isValueInDeadZone(event, MotionEvent.AXIS_Z)
+                && isValueInDeadZone(event, MotionEvent.AXIS_RZ)) {
+            return false;
+        }
+        return true;
     }
 
     public static View.OnKeyListener getClickDispatcher() {
         if (sClickDispatcher == null) {
             sClickDispatcher = new View.OnKeyListener() {
                 @Override
                 public boolean onKey(View v, int keyCode, KeyEvent event) {
                     if (isActionKeyDown(event)) {