зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1137555 - Add implementation of PuppetWidget::GetMaxTouchPoints(). r=smaug, r=jimm
--HG-- extra : rebase_source : 7460428da794e871de20cc5c23ca70c2d97141e6
This commit is contained in:
Родитель
c6ba641724
Коммит
d0ef015683
|
@ -10,15 +10,10 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
#ifdef XP_WIN
|
||||
namespace widget {
|
||||
extern int32_t IsTouchDeviceSupportPresent();
|
||||
} // namespace widget
|
||||
#endif // #ifdef XP_WIN
|
||||
|
||||
namespace dom {
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -188,8 +183,7 @@ TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
|
|||
{
|
||||
bool prefValue = false;
|
||||
int32_t flag = 0;
|
||||
if (NS_SUCCEEDED(Preferences::GetInt("dom.w3c_touch_events.enabled",
|
||||
&flag))) {
|
||||
if (NS_SUCCEEDED(Preferences::GetInt("dom.w3c_touch_events.enabled", &flag))) {
|
||||
if (flag == 2) {
|
||||
#ifdef XP_WIN
|
||||
static bool sDidCheckTouchDeviceSupport = false;
|
||||
|
@ -197,7 +191,7 @@ TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
|
|||
// On Windows we auto-detect based on device support.
|
||||
if (!sDidCheckTouchDeviceSupport) {
|
||||
sDidCheckTouchDeviceSupport = true;
|
||||
sIsTouchDeviceSupportPresent = widget::IsTouchDeviceSupportPresent();
|
||||
sIsTouchDeviceSupportPresent = WidgetUtils::IsTouchDeviceSupportPresent();
|
||||
}
|
||||
prefValue = sIsTouchDeviceSupportPresent;
|
||||
#else
|
||||
|
|
|
@ -347,6 +347,11 @@ parent:
|
|||
*/
|
||||
sync GetDefaultScale() returns (double value);
|
||||
|
||||
/**
|
||||
* Gets maximum of touch points at current device.
|
||||
*/
|
||||
sync GetMaxTouchPoints() returns (uint32_t value);
|
||||
|
||||
/**
|
||||
* Set the native cursor.
|
||||
* @param value
|
||||
|
|
|
@ -2966,6 +2966,13 @@ TabChild::GetDefaultScale(double* aScale)
|
|||
SendGetDefaultScale(aScale);
|
||||
}
|
||||
|
||||
void
|
||||
TabChild::GetMaxTouchPoints(uint32_t* aTouchPoints)
|
||||
{
|
||||
// Fallback to a sync call.
|
||||
SendGetMaxTouchPoints(aTouchPoints);
|
||||
}
|
||||
|
||||
void
|
||||
TabChild::NotifyPainted()
|
||||
{
|
||||
|
|
|
@ -429,6 +429,8 @@ public:
|
|||
void GetDPI(float* aDPI);
|
||||
void GetDefaultScale(double *aScale);
|
||||
|
||||
void GetMaxTouchPoints(uint32_t* aTouchPoints);
|
||||
|
||||
ScreenOrientation GetOrientation() { return mOrientation; }
|
||||
|
||||
void SetBackgroundColor(const nscolor& aColor);
|
||||
|
|
|
@ -2504,6 +2504,18 @@ TabParent::RecvGetDefaultScale(double* aValue)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvGetMaxTouchPoints(uint32_t* aTouchPoints)
|
||||
{
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
if (widget) {
|
||||
*aTouchPoints = widget->GetMaxTouchPoints();
|
||||
} else {
|
||||
*aTouchPoints = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue)
|
||||
{
|
||||
|
|
|
@ -216,6 +216,7 @@ public:
|
|||
virtual bool RecvGetTabOffset(LayoutDeviceIntPoint* aPoint) override;
|
||||
virtual bool RecvGetDPI(float* aValue) override;
|
||||
virtual bool RecvGetDefaultScale(double* aValue) override;
|
||||
virtual bool RecvGetMaxTouchPoints(uint32_t* aTouchPoints) override;
|
||||
virtual bool RecvGetWidgetNativeData(WindowsHandle* aValue) override;
|
||||
virtual bool RecvZoomToRect(const uint32_t& aPresShellId,
|
||||
const ViewID& aViewId,
|
||||
|
|
|
@ -1128,6 +1128,20 @@ PuppetWidget::GetScreenBounds(nsIntRect &aRect) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t PuppetWidget::GetMaxTouchPoints() const
|
||||
{
|
||||
static uint32_t sTouchPoints = 0;
|
||||
static bool sIsInitialized = false;
|
||||
if (sIsInitialized) {
|
||||
return sTouchPoints;
|
||||
}
|
||||
if (mTabChild) {
|
||||
mTabChild->GetMaxTouchPoints(&sTouchPoints);
|
||||
sIsInitialized = true;
|
||||
}
|
||||
return sTouchPoints;
|
||||
}
|
||||
|
||||
PuppetScreen::PuppetScreen(void *nativeScreen)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -241,6 +241,7 @@ public:
|
|||
bool aLongTap,
|
||||
nsIObserver* aObserver) override;
|
||||
virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver) override;
|
||||
virtual uint32_t GetMaxTouchPoints() const override;
|
||||
|
||||
protected:
|
||||
bool mEnabled;
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
#ifdef XP_WIN
|
||||
#include "WinUtils.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -89,4 +92,15 @@ nsIntRect RotateRect(nsIntRect aRect,
|
|||
return aRect;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
WidgetUtils::IsTouchDeviceSupportPresent()
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
return WinUtils::IsTouchDeviceSupportPresent();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -81,6 +81,11 @@ public:
|
|||
bool aIsCapsLock,
|
||||
uint32_t* aUnshiftedCharCode,
|
||||
uint32_t* aShiftedCharCode);
|
||||
|
||||
/**
|
||||
* Does device have touch support
|
||||
*/
|
||||
static uint32_t IsTouchDeviceSupportPresent();
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nsIThread.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "gfxColor.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
|
||||
#ifdef NS_ENABLE_TSF
|
||||
#include <textstor.h>
|
||||
|
@ -1670,5 +1671,25 @@ WinUtils::ShouldHideScrollbars()
|
|||
return false;
|
||||
}
|
||||
|
||||
// This is in use here and in dom/events/TouchEvent.cpp
|
||||
/* static */
|
||||
uint32_t
|
||||
WinUtils::IsTouchDeviceSupportPresent()
|
||||
{
|
||||
int32_t touchCapabilities = ::GetSystemMetrics(SM_DIGITIZER);
|
||||
return (touchCapabilities & NID_READY) &&
|
||||
(touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH));
|
||||
}
|
||||
|
||||
/* static */
|
||||
uint32_t
|
||||
WinUtils::GetMaxTouchPoints()
|
||||
{
|
||||
if (IsWin7OrLater() && IsTouchDeviceSupportPresent()) {
|
||||
return GetSystemMetrics(SM_MAXIMUMTOUCHES);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -123,7 +123,8 @@ public:
|
|||
};
|
||||
#endif
|
||||
|
||||
class WinUtils {
|
||||
class WinUtils
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Functions to convert between logical pixels as used by most Windows APIs
|
||||
|
@ -370,7 +371,22 @@ public:
|
|||
static void SetupKeyModifiersSequence(nsTArray<KeyPair>* aArray,
|
||||
uint32_t aModifiers);
|
||||
|
||||
// dwmapi.dll function typedefs and declarations
|
||||
/**
|
||||
* Does device have touch support
|
||||
*/
|
||||
static uint32_t IsTouchDeviceSupportPresent();
|
||||
|
||||
/**
|
||||
* The maximum number of simultaneous touch contacts supported by the device.
|
||||
* In the case of devices with multiple digitizers (e.g. multiple touch screens),
|
||||
* the value will be the maximum of the set of maximum supported contacts by
|
||||
* each individual digitizer.
|
||||
*/
|
||||
static uint32_t GetMaxTouchPoints();
|
||||
|
||||
/**
|
||||
* dwmapi.dll function typedefs and declarations
|
||||
*/
|
||||
typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset);
|
||||
typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled);
|
||||
typedef HRESULT (WINAPI*DwmSetIconicThumbnailProc)(HWND hWnd, HBITMAP hBitmap, DWORD dwSITFlags);
|
||||
|
@ -515,8 +531,6 @@ public:
|
|||
static int32_t GetICOCacheSecondsTimeout();
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -63,22 +63,10 @@ static int32_t GetSystemParam(long flag, int32_t def)
|
|||
return ::SystemParametersInfo(flag, 0, &value, 0) ? value : def;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
// This is in use here and in dom/events/TouchEvent.cpp
|
||||
int32_t IsTouchDeviceSupportPresent()
|
||||
{
|
||||
int32_t touchCapabilities;
|
||||
touchCapabilities = ::GetSystemMetrics(SM_DIGITIZER);
|
||||
return ((touchCapabilities & NID_READY) &&
|
||||
(touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH)));
|
||||
}
|
||||
} }
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
||||
{
|
||||
mozilla::Telemetry::Accumulate(mozilla::Telemetry::TOUCH_ENABLED_DEVICE,
|
||||
IsTouchDeviceSupportPresent());
|
||||
WinUtils::IsTouchDeviceSupportPresent());
|
||||
}
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel()
|
||||
|
@ -396,7 +384,7 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
|||
aResult = !IsAppThemed();
|
||||
break;
|
||||
case eIntID_TouchEnabled:
|
||||
aResult = IsTouchDeviceSupportPresent();
|
||||
aResult = WinUtils::IsTouchDeviceSupportPresent();
|
||||
break;
|
||||
case eIntID_WindowsDefaultTheme:
|
||||
aResult = nsUXThemeData::IsDefaultWindowTheme();
|
||||
|
|
|
@ -191,12 +191,6 @@ using namespace mozilla::gfx;
|
|||
using namespace mozilla::layers;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
extern int32_t IsTouchDeviceSupportPresent();
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
**************************************************************
|
||||
**
|
||||
|
@ -3562,10 +3556,7 @@ nsWindow::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries)
|
|||
uint32_t
|
||||
nsWindow::GetMaxTouchPoints() const
|
||||
{
|
||||
if (IsWin7OrLater() && IsTouchDeviceSupportPresent()) {
|
||||
return GetSystemMetrics(SM_MAXIMUMTOUCHES);
|
||||
}
|
||||
return 0;
|
||||
return WinUtils::GetMaxTouchPoints();
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
|
|
Загрузка…
Ссылка в новой задаче