Bug 723200 - Enable multitouch by default on Android. r=mbrubeck a=akeybl
authorWes Johnston <wjohnston@mozilla.com>
Wed, 01 Feb 2012 17:08:04 -0800
changeset 87106 0eafcf050b50ab41138582b197d1c819917cb761
parent 87105 f010ed04ac8df00c737a6df02b0f0692d8b2aac4
child 87107 e222d18ba92cb8503af397d4054f6f3511410678
push id818
push usermfinkle@mozilla.com
push dateMon, 06 Feb 2012 17:06:02 +0000
treeherdermozilla-aurora@1f3329e303fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck, akeybl
bugs723200
milestone12.0a2
Bug 723200 - Enable multitouch by default on Android. r=mbrubeck a=akeybl
mobile/android/app/mobile.js
mobile/android/base/gfx/LayerView.java
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -612,17 +612,17 @@ pref("widget.ime.android.landscape_fulls
 pref("widget.ime.android.fullscreen_threshold", 250); // in hundreths of inches
 
 // optimize images memory usage
 pref("image.mem.decodeondraw", true);
 pref("content.image.allow_locking", false);
 pref("image.mem.min_discard_timeout_ms", 10000);
 
 // enable touch events interfaces
-pref("dom.w3c_touch_events.enabled", false);
+pref("dom.w3c_touch_events.enabled", true);
 
 #ifdef MOZ_SAFE_BROWSING
 // Safe browsing does nothing unless this pref is set
 pref("browser.safebrowsing.enabled", true);
 
 // Prevent loading of pages identified as malware
 pref("browser.safebrowsing.malware.enabled", true);
 
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -32,59 +32,50 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 package org.mozilla.gecko.gfx;
 
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.GeckoEvent;
-import org.mozilla.gecko.GeckoEventListener;
 import org.mozilla.gecko.gfx.FloatSize;
 import org.mozilla.gecko.gfx.InputConnectionHandler;
 import org.mozilla.gecko.gfx.LayerController;
 import org.mozilla.gecko.ui.SimpleScaleGestureDetector;
 import android.content.Context;
 import android.opengl.GLSurfaceView;
 import android.view.GestureDetector;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
 import android.util.Log;
 import java.nio.IntBuffer;
 import java.util.LinkedList;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 /**
  * A view rendered by the layer compositor.
  *
  * This view delegates to LayerRenderer to actually do the drawing. Its role is largely that of a
  * mediator between the LayerRenderer and the LayerController.
  */
-public class LayerView extends GLSurfaceView
-    implements GeckoEventListener {
+public class LayerView extends GLSurfaceView {
     private Context mContext;
     private LayerController mController;
     private InputConnectionHandler mInputConnectionHandler;
     private LayerRenderer mRenderer;
     private GestureDetector mGestureDetector;
     private SimpleScaleGestureDetector mScaleGestureDetector;
     private long mRenderTime;
     private boolean mRenderTimeReset;
     private static String LOGTAG = "GeckoLayerView";
     /* List of events to be processed if the page does not prevent them. Should only be touched on the main thread */
     private LinkedList<MotionEvent> mEventQueue = new LinkedList<MotionEvent>();
-    private boolean touchEventsEnabled = false;
-    private String touchEventsPrefName = "dom.w3c_touch_events.enabled";
+
 
     public LayerView(Context context, LayerController controller) {
         super(context);
 
         mContext = context;
         mController = controller;
         mRenderer = new LayerRenderer(this);
         setRenderer(mRenderer);
@@ -92,40 +83,16 @@ public class LayerView extends GLSurface
         mGestureDetector = new GestureDetector(context, controller.getGestureListener());
         mScaleGestureDetector =
             new SimpleScaleGestureDetector(controller.getScaleGestureListener());
         mGestureDetector.setOnDoubleTapListener(controller.getDoubleTapListener());
         mInputConnectionHandler = null;
 
         setFocusable(true);
         setFocusableInTouchMode(true);
-
-        GeckoAppShell.registerGeckoEventListener("Preferences:Data", this);
-        JSONArray jsonPrefs = new JSONArray();
-        jsonPrefs.put(touchEventsPrefName);
-        GeckoEvent event = new GeckoEvent("Preferences:Get", jsonPrefs.toString());
-        GeckoAppShell.sendEventToGecko(event);
-    }
-
-    public void handleMessage(String event, JSONObject message) {
-        if (event.equals("Preferences:Data")) {
-            try {
-                JSONArray jsonPrefs = message.getJSONArray("preferences");
-                for (int i = 0; i < jsonPrefs.length(); i++) {
-                    JSONObject jPref = jsonPrefs.getJSONObject(i);
-                    final String prefName = jPref.getString("name");
-                    if (prefName.equals(touchEventsPrefName)) {
-                        touchEventsEnabled = jPref.getBoolean("value");
-                        GeckoAppShell.unregisterGeckoEventListener("Preferences:Data", this);
-                    }
-                }
-            } catch(JSONException ex) {
-                Log.e(LOGTAG, "Error decoding JSON", ex);
-            }
-        }
     }
 
     private void addToEventQueue(MotionEvent event) {
         MotionEvent copy = MotionEvent.obtain(event);
         mEventQueue.add(copy);
     }
 
     public void processEventQueue() {
@@ -137,17 +104,17 @@ public class LayerView extends GLSurface
     }
 
     public void clearEventQueue() {
         mEventQueue.clear();
     }
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        if (touchEventsEnabled && mController.onTouchEvent(event)) {
+        if (mController.onTouchEvent(event)) {
             addToEventQueue(event);
             return true;
         }
         return processEvent(event);
     }
 
     private boolean processEvent(MotionEvent event) {
         if (mGestureDetector.onTouchEvent(event))