Bug 1149861 - Implement getMaxTouchPoints for Android. r=snorp

This commit is contained in:
Makoto Kato 2015-04-24 18:43:31 +09:00
parent 08f3961c3b
commit c8d42ba7de
5 changed files with 50 additions and 0 deletions

View File

@ -2651,4 +2651,23 @@ public class GeckoAppShell
}
return Environment.getExternalStoragePublicDirectory(systemType).getAbsolutePath();
}
@WrapElementForJNI
static int getMaxTouchPoints() {
PackageManager pm = getContext().getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND)) {
// at least, 5+ fingers.
return 5;
} else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT)) {
// at least, 2+ fingers.
return 2;
} else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
// 2 fingers
return 2;
} else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
// 1 finger
return 1;
}
return 0;
}
}

View File

@ -302,6 +302,14 @@ mozilla::jni::ByteArray::LocalRef GeckoAppShell::GetIconForExtensionWrapper(mozi
return mozilla::jni::Method<GetIconForExtensionWrapper_t>::Call(nullptr, nullptr, a0, a1);
}
constexpr char GeckoAppShell::GetMaxTouchPoints_t::name[];
constexpr char GeckoAppShell::GetMaxTouchPoints_t::signature[];
int32_t GeckoAppShell::GetMaxTouchPoints()
{
return mozilla::jni::Method<GetMaxTouchPoints_t>::Call(nullptr, nullptr);
}
constexpr char GeckoAppShell::GetMessageWrapper_t::name[];
constexpr char GeckoAppShell::GetMessageWrapper_t::signature[];

View File

@ -582,6 +582,21 @@ public:
static mozilla::jni::ByteArray::LocalRef GetIconForExtensionWrapper(mozilla::jni::String::Param, int32_t);
public:
struct GetMaxTouchPoints_t {
typedef GeckoAppShell Owner;
typedef int32_t ReturnType;
typedef int32_t SetterType;
static constexpr char name[] = "getMaxTouchPoints";
static constexpr char signature[] =
"()I";
static const bool isStatic = true;
static const bool isMultithreaded = false;
static const mozilla::jni::ExceptionMode exceptionMode = mozilla::jni::ExceptionMode::ABORT;
};
static int32_t GetMaxTouchPoints();
public:
struct GetMessageWrapper_t {
typedef GeckoAppShell Owner;

View File

@ -2542,3 +2542,9 @@ nsWindow::RootLayerTreeId()
MOZ_ASSERT(sCompositorParent);
return sCompositorParent->RootLayerTreeId();
}
uint32_t
nsWindow::GetMaxTouchPoints() const
{
return GeckoAppShell::GetMaxTouchPoints();
}

View File

@ -167,6 +167,8 @@ public:
virtual bool WidgetPaintsBackground();
virtual uint32_t GetMaxTouchPoints() const override;
protected:
void BringToFront();
nsWindow *FindTopLevel();