Bug 479901 - Add WM_GESTURE support for Windows 7. r=vlad+smaug.

This commit is contained in:
Jim Mathies 2009-04-02 14:34:31 -05:00
parent d5b404e0cd
commit bf62e148ca
21 changed files with 1320 additions and 369 deletions

View File

@ -434,8 +434,13 @@ pref("browser.gesture.swipe.left", "Browser:BackOrBackDuplicate");
pref("browser.gesture.swipe.right", "Browser:ForwardOrForwardDuplicate");
pref("browser.gesture.swipe.up", "cmd_scrollTop");
pref("browser.gesture.swipe.down", "cmd_scrollBottom");
#ifdef XP_MACOSX
pref("browser.gesture.pinch.latched", true);
pref("browser.gesture.pinch.threshold", 150);
#else
pref("browser.gesture.pinch.latched", false);
pref("browser.gesture.pinch.threshold", 25);
#endif
pref("browser.gesture.pinch.out", "cmd_fullZoomEnlarge");
pref("browser.gesture.pinch.in", "cmd_fullZoomReduce");
pref("browser.gesture.pinch.out.shift", "cmd_fullZoomReset");
@ -444,6 +449,7 @@ pref("browser.gesture.twist.latched", false);
pref("browser.gesture.twist.threshold", 25);
pref("browser.gesture.twist.right", "Browser:NextTab");
pref("browser.gesture.twist.left", "Browser:PrevTab");
pref("browser.gesture.tap", "cmd_fullZoomReset");
// 0=lines, 1=pages, 2=history , 3=text size
#ifdef XP_MACOSX

View File

@ -688,7 +688,8 @@ let gGestureSupport = {
init: function GS_init(aAddListener) {
const gestureEvents = ["SwipeGesture",
"MagnifyGestureStart", "MagnifyGestureUpdate", "MagnifyGesture",
"RotateGestureStart", "RotateGestureUpdate", "RotateGesture"];
"RotateGestureStart", "RotateGestureUpdate", "RotateGesture",
"TapGesture", "PressTapGesture"];
let addRemove = aAddListener ? window.addEventListener :
window.removeEventListener;
@ -714,14 +715,28 @@ let gGestureSupport = {
switch (aEvent.type) {
case "MozSwipeGesture":
aEvent.preventDefault();
return this.onSwipe(aEvent);
case "MozMagnifyGestureStart":
aEvent.preventDefault();
#ifdef XP_WIN
return this._setupGesture(aEvent, "pinch", def(25, 0), "out", "in");
#else
return this._setupGesture(aEvent, "pinch", def(150, 1), "out", "in");
#endif
case "MozRotateGestureStart":
aEvent.preventDefault();
return this._setupGesture(aEvent, "twist", def(25, 0), "right", "left");
case "MozMagnifyGestureUpdate":
case "MozRotateGestureUpdate":
aEvent.preventDefault();
return this._doUpdate(aEvent);
case "MozTapGesture":
aEvent.preventDefault();
return this._doAction(aEvent, ["tap"]);
case "MozPressTapGesture":
// Fall through to default behavior
return;
}
},

View File

@ -153,10 +153,14 @@ function test_TestEventListeners()
e("MozMagnifyGesture", 0, 30.0, 0);
// rotate gesture events
e("MozRotateGestureStart", SimpleGestureEvent.DIRECTION_RIGHT, 33.0, 0);
e("MozRotateGestureUpdate", SimpleGestureEvent.DIRECTION_LEFT, -13.0, 0);
e("MozRotateGestureUpdate", SimpleGestureEvent.DIRECTION_RIGHT, 13.0, 0);
e("MozRotateGesture", SimpleGestureEvent.DIRECTION_RIGHT, 33.0, 0);
e("MozRotateGestureStart", SimpleGestureEvent.ROTATION_CLOCKWISE, 33.0, 0);
e("MozRotateGestureUpdate", SimpleGestureEvent.ROTATION_COUNTERCLOCKWISE, -13.0, 0);
e("MozRotateGestureUpdate", SimpleGestureEvent.ROTATION_CLOCKWISE, 13.0, 0);
e("MozRotateGesture", SimpleGestureEvent.ROTATION_CLOCKWISE, 33.0, 0);
// Tap and presstap gesture events
e("MozTapGesture", 0, 0.0, 0);
e("MozPressTapGesture", 0, 0.0, 0);
// event.shiftKey
let modifier = Components.interfaces.nsIDOMNSEvent.SHIFT_MASK;
@ -249,12 +253,16 @@ function test_EnsureConstantsAreDisjoint()
let left = SimpleGestureEvent.DIRECTION_LEFT;
let right = SimpleGestureEvent.DIRECTION_RIGHT;
let clockwise = SimpleGestureEvent.ROTATION_CLOCKWISE;
let cclockwise = SimpleGestureEvent.ROTATION_COUNTERCLOCKWISE;
ok(up ^ down, "DIRECTION_UP and DIRECTION_DOWN are not bitwise disjoint");
ok(up ^ left, "DIRECTION_UP and DIRECTION_LEFT are not bitwise disjoint");
ok(up ^ right, "DIRECTION_UP and DIRECTION_RIGHT are not bitwise disjoint");
ok(down ^ left, "DIRECTION_DOWN and DIRECTION_LEFT are not bitwise disjoint");
ok(down ^ right, "DIRECTION_DOWN and DIRECTION_RIGHT are not bitwise disjoint");
ok(left ^ right, "DIRECTION_LEFT and DIRECTION_RIGHT are not bitwise disjoint");
ok(clockwise ^ cclockwise, "ROTATION_CLOCKWISE and ROTATION_COUNTERCLOCKWISE are not bitwise disjoint");
}
// Helper for test of latched event processing. Emits the actual

View File

@ -490,7 +490,9 @@ nsContentUtils::InitializeEventTable() {
{ &nsGkAtoms::onMozMagnifyGesture, { NS_SIMPLE_GESTURE_MAGNIFY, EventNameType_None } },
{ &nsGkAtoms::onMozRotateGestureStart, { NS_SIMPLE_GESTURE_ROTATE_START, EventNameType_None } },
{ &nsGkAtoms::onMozRotateGestureUpdate, { NS_SIMPLE_GESTURE_ROTATE_UPDATE, EventNameType_None } },
{ &nsGkAtoms::onMozRotateGesture, { NS_SIMPLE_GESTURE_ROTATE, EventNameType_None } }
{ &nsGkAtoms::onMozRotateGesture, { NS_SIMPLE_GESTURE_ROTATE, EventNameType_None } },
{ &nsGkAtoms::onMozTapGesture, { NS_SIMPLE_GESTURE_TAP, EventNameType_None } },
{ &nsGkAtoms::onMozPressTapGesture, { NS_SIMPLE_GESTURE_PRESSTAP, EventNameType_None } }
};
sEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>;

View File

@ -1489,6 +1489,8 @@ GK_ATOM(onMozMagnifyGesture, "onMozMagnifyGesture")
GK_ATOM(onMozRotateGestureStart, "onMozRotateGestureStart")
GK_ATOM(onMozRotateGestureUpdate, "onMozRotateGestureUpdate")
GK_ATOM(onMozRotateGesture, "onMozRotateGesture")
GK_ATOM(onMozTapGesture, "onMozTapGesture")
GK_ATOM(onMozPressTapGesture, "onMozPressTapGesture")
//---------------------------------------------------------------------------

View File

@ -89,7 +89,9 @@ static const char* const sEventNames[] = {
"MozMagnifyGesture",
"MozRotateGestureStart",
"MozRotateGestureUpdate",
"MozRotateGesture"
"MozRotateGesture",
"MozTapGesture",
"MozPressTapGesture"
};
static char *sPopupAllowedEvents;
@ -682,6 +684,10 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
mEvent->message = NS_SIMPLE_GESTURE_ROTATE_UPDATE;
else if (atom == nsGkAtoms::onMozRotateGesture)
mEvent->message = NS_SIMPLE_GESTURE_ROTATE;
else if (atom == nsGkAtoms::onMozPressTapGesture)
mEvent->message = NS_SIMPLE_GESTURE_PRESSTAP;
else if (atom == nsGkAtoms::onMozTapGesture)
mEvent->message = NS_SIMPLE_GESTURE_TAP;
}
if (mEvent->message == NS_USER_DEFINED_EVENT)
@ -1531,6 +1537,10 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return sEventNames[eDOMEvents_MozRotateGestureUpdate];
case NS_SIMPLE_GESTURE_ROTATE:
return sEventNames[eDOMEvents_MozRotateGesture];
case NS_SIMPLE_GESTURE_TAP:
return sEventNames[eDOMEvents_MozTapGesture];
case NS_SIMPLE_GESTURE_PRESSTAP:
return sEventNames[eDOMEvents_MozPressTapGesture];
default:
break;
}

View File

@ -168,7 +168,9 @@ public:
eDOMEvents_MozMagnifyGesture,
eDOMEvents_MozRotateGestureStart,
eDOMEvents_MozRotateGestureUpdate,
eDOMEvents_MozRotateGesture
eDOMEvents_MozRotateGesture,
eDOMEvents_MozTapGesture,
eDOMEvents_MozPressTapGesture
};
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);

View File

@ -50,6 +50,7 @@ nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(nsPresContext* aPresContext, ns
} else {
mEventIsInternal = PR_TRUE;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
}
}

View File

@ -163,7 +163,6 @@
static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
//we will use key binding by default now. this wil lbreak viewer for now
#define NON_KEYBINDING 0
@ -192,6 +191,14 @@ static PRUint32 gMouseOrKeyboardEventCounter = 0;
static nsITimer* gUserInteractionTimer = nsnull;
static nsITimerCallback* gUserInteractionTimerCallback = nsnull;
// Pixel scroll accumulation for synthetic line scrolls
static nscoord gPixelScrollDeltaX = 0;
static nscoord gPixelScrollDeltaY = 0;
static PRUint32 gPixelScrollDeltaTimeout = 0;
static nscoord
GetScrollableViewLineHeight(nsPresContext* aPresContext, nsIFrame* aTargetFrame);
#ifdef DEBUG_DOCSHELL_FOCUS
static void
PrintDocTree(nsIDocShellTreeItem* aParentItem, int aLevel)
@ -447,12 +454,12 @@ public:
static void EndTransaction();
static void OnEvent(nsEvent* aEvent);
static void Shutdown();
static PRUint32 GetTimeoutTime();
protected:
static nsIntPoint GetScreenPoint(nsGUIEvent* aEvent);
static void OnFailToScrollTarget();
static void OnTimeout(nsITimer *aTimer, void *aClosure);
static void SetTimeout();
static PRUint32 GetTimeoutTime();
static PRUint32 GetIgnoreMoveDelayTime();
static nsWeakFrame sTargetFrame;
@ -1650,8 +1657,53 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
mCurrentTargetContent = mCurrentFocus;
}
// When the last line scroll has been canceled, eat the pixel scroll event
nsMouseScrollEvent *msEvent = static_cast<nsMouseScrollEvent*>(aEvent);
// Clear old deltas after a period of non action
if (OutOfTime(gPixelScrollDeltaTimeout, nsMouseWheelTransaction::GetTimeoutTime())) {
gPixelScrollDeltaX = gPixelScrollDeltaY = 0;
}
gPixelScrollDeltaTimeout = PR_IntervalToMilliseconds(PR_IntervalNow());
// If needed send a line scroll event for pixel scrolls with kNoLines
if (msEvent->scrollFlags & nsMouseScrollEvent::kNoLines) {
nscoord pixelHeight = aPresContext->AppUnitsToIntCSSPixels(
GetScrollableViewLineHeight(aPresContext, aTargetFrame));
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsVertical) {
gPixelScrollDeltaX += msEvent->delta;
if (!gPixelScrollDeltaX || !pixelHeight)
break;
if (PR_ABS(gPixelScrollDeltaX) >= pixelHeight) {
PRInt32 numLines = (PRInt32)ceil((float)gPixelScrollDeltaX/(float)pixelHeight);
gPixelScrollDeltaX -= numLines*pixelHeight;
nsWeakFrame weakFrame(aTargetFrame);
SendLineScrollEvent(aTargetFrame, msEvent, aPresContext,
aStatus, numLines);
NS_ENSURE_STATE(weakFrame.IsAlive());
}
} else if (msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) {
gPixelScrollDeltaY += msEvent->delta;
if (!gPixelScrollDeltaY || !pixelHeight)
break;
if (PR_ABS(gPixelScrollDeltaY) >= pixelHeight) {
PRInt32 numLines = (PRInt32)ceil((float)gPixelScrollDeltaY/(float)pixelHeight);
gPixelScrollDeltaY -= numLines*pixelHeight;
nsWeakFrame weakFrame(aTargetFrame);
SendLineScrollEvent(aTargetFrame, msEvent, aPresContext,
aStatus, numLines);
NS_ENSURE_STATE(weakFrame.IsAlive());
}
}
}
// When the last line scroll has been canceled, eat the pixel scroll event
if ((msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) ?
mLastLineScrollConsumedX : mLastLineScrollConsumedY) {
*aStatus = nsEventStatus_eConsumeNoDefault;
@ -2728,6 +2780,57 @@ GetScrollableViewForFrame(nsPresContext* aPresContext, nsIFrame* aFrame)
return nsnull;
}
static nscoord
GetScrollableViewLineHeight(nsPresContext* aPresContext, nsIFrame* aTargetFrame)
{
nsIScrollableView* scrollView = GetScrollableViewForFrame(aPresContext, aTargetFrame);
nscoord lineHeight = 0;
if (scrollView) {
scrollView->GetLineHeight(&lineHeight);
} else {
// Fall back to the font height of the target frame.
const nsStyleFont* font = aTargetFrame->GetStyleFont();
const nsFont& f = font->mFont;
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(f);
NS_ASSERTION(fm, "FontMetrics is null!");
if (fm)
fm->GetHeight(lineHeight);
}
return lineHeight;
}
void
nsEventStateManager::SendLineScrollEvent(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aEvent,
nsPresContext* aPresContext,
nsEventStatus* aStatus,
PRInt32 aNumLines)
{
nsCOMPtr<nsIContent> targetContent = aTargetFrame->GetContent();
if (!targetContent)
GetFocusedContent(getter_AddRefs(targetContent));
if (!targetContent)
return;
while (targetContent->IsNodeOfType(nsINode::eTEXT)) {
targetContent = targetContent->GetParent();
}
PRBool isTrusted = (aEvent->flags & NS_EVENT_FLAG_TRUSTED) != 0;
nsMouseScrollEvent event(isTrusted, NS_MOUSE_SCROLL, nsnull);
event.refPoint = aEvent->refPoint;
event.widget = aEvent->widget;
event.time = aEvent->time;
event.isShift = aEvent->isShift;
event.isControl = aEvent->isControl;
event.isAlt = aEvent->isAlt;
event.isMeta = aEvent->isMeta;
event.scrollFlags = aEvent->scrollFlags;
event.delta = aNumLines;
nsEventDispatcher::Dispatch(targetContent, aPresContext, &event, nsnull, aStatus);
}
void
nsEventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aEvent,
@ -2744,19 +2847,7 @@ nsEventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame,
targetContent = targetContent->GetParent();
}
nsIScrollableView* scrollView = GetScrollableViewForFrame(aPresContext, aTargetFrame);
nscoord lineHeight = 0;
if (scrollView) {
scrollView->GetLineHeight(&lineHeight);
} else {
// Fall back to the font height of the target frame.
const nsStyleFont* font = aTargetFrame->GetStyleFont();
const nsFont& f = font->mFont;
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(f);
NS_ASSERTION(fm, "FontMetrics is null!");
if (fm)
fm->GetHeight(lineHeight);
}
nscoord lineHeight = GetScrollableViewLineHeight(aPresContext, aTargetFrame);
PRBool isTrusted = (aEvent->flags & NS_EVENT_FLAG_TRUSTED) != 0;
nsMouseScrollEvent event(isTrusted, NS_MOUSE_PIXEL_SCROLL, nsnull);

View File

@ -291,12 +291,16 @@ protected:
void GetPrevDocShell(nsIDocShellTreeNode* aNode,
nsIDocShellTreeItem** aResult);
// These functions are for mousewheel scrolling
// These functions are for mousewheel and pixel scrolling
nsresult GetParentScrollingView(nsInputEvent* aEvent,
nsPresContext* aPresContext,
nsIFrame* &targetOuterFrame,
nsPresContext* &presCtxOuter);
void SendLineScrollEvent(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aEvent,
nsPresContext* aPresContext,
nsEventStatus* aStatus,
PRInt32 aNumLines);
void SendPixelScrollEvent(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aEvent,
nsPresContext* aPresContext,

View File

@ -541,6 +541,10 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
msg = NS_SIMPLE_GESTURE_ROTATE_UPDATE;
else if (aType.EqualsLiteral("MozRotateGesture"))
msg = NS_SIMPLE_GESTURE_ROTATE;
else if (aType.EqualsLiteral("MozTapGesture"))
msg = NS_SIMPLE_GESTURE_TAP;
else if (aType.EqualsLiteral("MozPressTapGesture"))
msg = NS_SIMPLE_GESTURE_PRESSTAP;
else
return NS_ERROR_FAILURE;

View File

@ -246,9 +246,9 @@ interface nsIDOMWindowUtils : nsISupports {
/** Synthesize a simple gesture event for a window. The event types
* supported are: MozSwipeGesture, MozMagnifyGestureStart,
* MozMagnifyGestureUpdate, MozMagnifyGesture,
* MozRotateGestureStart, MozRotateGestureUpdate, and
* MozRotateGesture.
* MozMagnifyGestureUpdate, MozMagnifyGesture, MozRotateGestureStart,
* MozRotateGestureUpdate, MozRotateGesture, MozPressTapGesture, and
* MozTapGesture.
*
* Cannot be accessed from unprivileged context (not
* content-accessible) Will throw a DOM security error if called

View File

@ -44,7 +44,7 @@
*
* The following events are generated:
*
* MozSwipeGesture - Generated when the user swipes their fingers
* MozSwipeGesture - Generated when the user completes a swipe across
* across the input device.
*
* MozMagnifyGestureStart - Generated when the user begins the magnify
@ -77,17 +77,39 @@
* and can safely ignore the MozRotateGestureStart and the
* MozRotateGestureUpdate events. The "delta" value is the cumulative
* amount of rotation represented by the user's gesture.
*
* MozTapGesture - Generated when the user executes a two finger
* tap gesture on the input device. Client coordinates contain the
* center point of the tap.
* (XXX Not implemented on Mac)
*
* MozPressTapGesture - Generated when the user executes a press
* and tap two finger gesture (first finger down, second finger down,
* second finger up, first finger up) on the input device.
* Client coordinates contain the center pivot point of the action.
* (XXX Not implemented on Mac)
*
* Default behavior:
*
* Some operating systems support default behaviors for gesture events
* when they are not handled by the application. Consumers should
* use event.preventDefault() to prevent default behavior when
* consuming events.
*/
[scriptable, uuid(8aa40c61-9be7-4de1-93fa-30d6406d345b)]
[scriptable, uuid(cb68e879-f710-415d-a871-9a550860df01)]
interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
{
/* Direction constants */
/* Swipe direction constants */
const unsigned long DIRECTION_UP = 1;
const unsigned long DIRECTION_DOWN = 2;
const unsigned long DIRECTION_LEFT = 4;
const unsigned long DIRECTION_RIGHT = 8;
/* Rotational direction constants */
const unsigned long ROTATION_COUNTERCLOCKWISE = 1;
const unsigned long ROTATION_CLOCKWISE = 2;
/* Direction of a gesture. Diagonals are indicated by OR'ing the
* applicable constants together.
*
@ -95,8 +117,8 @@ interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
*
* Magnify gestures do not have a direction.
*
* Rotation gestures will be either DIRECTION_LEFT or
* DIRECTION_RIGHT (i.e., counter-clockwise and clockwise).
* Rotation gestures will be either ROTATION_COUNTERCLOCKWISE or
* ROTATION_CLOCKWISE.
*/
readonly attribute unsigned long direction;
@ -104,9 +126,7 @@ interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
*
* For rotation, the value is in degrees and is positive for
* clockwise rotation and negative for counterclockwise
* rotation. The "direction" attribute also denotes the direction of
* the rotation: clockwise is DIRECTION_RIGHT and counterclockwise
* is DIRECTION_LEFT.
* rotation.
*
* For magnification, the value will be positive for a "zoom in"
* (i.e, increased magnification) and negative for a "zoom out"
@ -118,6 +138,10 @@ interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
* undocumented. The values are typically in the range of 0.0 to
* 100.0, but it is only safe currently to rely on the delta being
* positive or negative.
*
* Units on Windows represent the difference between the initial
* and current/final width between the two touch points on the input
* device and are measured in pixels.
*/
readonly attribute double delta;

View File

@ -1121,6 +1121,9 @@ pref("config.use_system_prefs", false);
// if the system has enabled accessibility
pref("config.use_system_prefs.accessibility", false);
// enable single finger gesture input (win7+ tablets)
pref("gestures.enable_single_finger_input", true);
/*
* What are the entities that you want Mozilla to save using mnemonic
* names rather than numeric codes? E.g. If set, we'll output &nbsp;

View File

@ -409,6 +409,8 @@ class nsHashKey;
#define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
#define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
#define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
#define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
#define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
// Plug-in event. This is used when a plug-in has focus and when the native
// event needs to be passed to the focused plug-in directly.
@ -943,7 +945,7 @@ public:
kIsFullPage = 1 << 0,
kIsVertical = 1 << 1,
kIsHorizontal = 1 << 2,
kHasPixels = 1 << 3 // Marks line scroll events that are provided as
kHasPixels = 1 << 3, // Marks line scroll events that are provided as
// a fallback for pixel scroll events.
// These scroll events are used by things that can't
// be scrolled pixel-wise, like trees. You should
@ -952,6 +954,11 @@ public:
// When kHasPixels is set, the event is guaranteed to
// be followed up by an event that contains pixel
// scrolling information.
kNoLines = 1 << 4 // Marks pixel scroll events that will not be
// followed by a line scroll events. EventStateManager
// will compute the appropriate height/width based on
// view lineHeight and generate line scroll events
// as needed.
};
nsMouseScrollEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)

View File

@ -3438,9 +3438,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
geckoEvent.delta = -rotation;
if (rotation > 0.0) {
geckoEvent.direction = nsIDOMSimpleGestureEvent::DIRECTION_LEFT;
geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
} else {
geckoEvent.direction = nsIDOMSimpleGestureEvent::DIRECTION_RIGHT;
geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_CLOCKWISE;
}
// Send the event.
@ -3487,9 +3487,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
[self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
geckoEvent.delta = -mCumulativeRotation;
if (mCumulativeRotation > 0.0) {
geckoEvent.direction = nsIDOMSimpleGestureEvent::DIRECTION_LEFT;
geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
} else {
geckoEvent.direction = nsIDOMSimpleGestureEvent::DIRECTION_RIGHT;
geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_CLOCKWISE;
}
// Send the event.

View File

@ -83,6 +83,7 @@ CPPSRCS = \
nsLookAndFeel.cpp \
nsUXThemeData.cpp \
nsNativeThemeWin.cpp \
nsWinGesture.cpp \
$(NULL)
ifdef NS_PRINTING

View File

@ -0,0 +1,427 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jim Mathies <jmathies@mozilla.com>.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* 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 ***** */
#ifndef WinGesture_cpp__
#define WinGesture_cpp__
#include "nscore.h"
#include "nsWinGesture.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsIDOMSimpleGestureEvent.h"
#include "nsGUIEvent.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
const PRUnichar nsWinGesture::kGestureLibraryName[] = L"user32.dll";
HMODULE nsWinGesture::sLibraryHandle = nsnull;
nsWinGesture::GetGestureInfoPtr nsWinGesture::getGestureInfo = nsnull;
nsWinGesture::CloseGestureInfoHandlePtr nsWinGesture::closeGestureInfoHandle = nsnull;
nsWinGesture::GetGestureExtraArgsPtr nsWinGesture::getGestureExtraArgs = nsnull;
nsWinGesture::SetGestureConfigPtr nsWinGesture::setGestureConfig = nsnull;
nsWinGesture::GetGestureConfigPtr nsWinGesture::getGestureConfig = nsnull;
static PRBool gEnableSingleFingerPanEvents = PR_FALSE;
nsWinGesture::nsWinGesture() :
mAvailable(PR_FALSE)
{
(void)InitLibrary();
}
nsWinGesture::~nsWinGesture()
{
ShutdownLibrary();
}
/* Load and shutdown */
PRBool nsWinGesture::InitLibrary()
{
#ifdef WINCE
return PR_FALSE;
#else
if (getGestureInfo) {
mAvailable = PR_TRUE;
return PR_TRUE;
} else if (sLibraryHandle) {
return PR_FALSE;
}
sLibraryHandle = ::LoadLibraryW(kGestureLibraryName);
if (sLibraryHandle) {
getGestureInfo = (GetGestureInfoPtr)GetProcAddress(sLibraryHandle, "GetGestureInfo");
closeGestureInfoHandle = (CloseGestureInfoHandlePtr)GetProcAddress(sLibraryHandle, "CloseGestureInfoHandle");
getGestureExtraArgs = (GetGestureExtraArgsPtr)GetProcAddress(sLibraryHandle, "GetGestureExtraArgs");
setGestureConfig = (SetGestureConfigPtr)GetProcAddress(sLibraryHandle, "SetGestureConfig");
getGestureConfig = (GetGestureConfigPtr)GetProcAddress(sLibraryHandle, "GetGestureConfig");
}
if (!getGestureInfo || !closeGestureInfoHandle || !getGestureExtraArgs ||
!setGestureConfig || !getGestureConfig) {
getGestureInfo = nsnull;
closeGestureInfoHandle = nsnull;
getGestureExtraArgs = nsnull;
setGestureConfig = nsnull;
getGestureConfig = nsnull;
return PR_FALSE;
}
mAvailable = PR_TRUE;
// Check to see if we want single finger gesture input. Only do this once
// for the app so we don't have to look it up on every window create.
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
nsCOMPtr<nsIPrefBranch> prefBranch;
prefs->GetBranch(0, getter_AddRefs(prefBranch));
if (prefBranch) {
PRBool flag;
if (NS_SUCCEEDED(prefBranch->GetBoolPref("gestures.enable_single_finger_input", &flag))
&& flag)
gEnableSingleFingerPanEvents = PR_TRUE;
}
}
return PR_TRUE;
#endif
}
void nsWinGesture::ShutdownLibrary()
{
mAvailable = PR_FALSE;
}
#define GCOUNT 5
PRBool nsWinGesture::InitWinGestureSupport(HWND hWnd)
{
if (!mAvailable)
return PR_FALSE;
GESTURECONFIG config[GCOUNT];
memset(&config, 0, sizeof(config));
config[0].dwID = GID_ZOOM;
config[0].dwWant = GC_ZOOM;
config[0].dwBlock = 0;
config[1].dwID = GID_ROTATE;
config[1].dwWant = GC_ROTATE;
config[1].dwBlock = 0;
config[2].dwID = GID_PAN;
if (gEnableSingleFingerPanEvents) {
config[2].dwWant = GC_PAN|GC_PAN_WITH_INERTIA|
GC_PAN_WITH_GUTTER|
GC_PAN_WITH_SINGLE_FINGER_VERTICALLY|
GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
config[2].dwBlock = 0;
}
else {
config[2].dwWant = GC_PAN|GC_PAN_WITH_INERTIA|
GC_PAN_WITH_GUTTER;
config[2].dwBlock = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY|
GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
}
config[3].dwWant = GC_TWOFINGERTAP;
config[3].dwID = GID_TWOFINGERTAP;
config[3].dwBlock = 0;
config[4].dwWant = GC_ROLLOVER;
config[4].dwID = GID_ROLLOVER;
config[4].dwBlock = 0;
return SetGestureConfig(hWnd, GCOUNT, (PGESTURECONFIG)&config);
}
/* Helpers */
PRBool nsWinGesture::IsAvailable()
{
return mAvailable;
}
PRBool nsWinGesture::GetGestureInfo(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo)
{
if (!mAvailable || !hGestureInfo || !pGestureInfo)
return PR_FALSE;
ZeroMemory(pGestureInfo, sizeof(GESTUREINFO));
pGestureInfo->cbSize = sizeof(GESTUREINFO);
return getGestureInfo(hGestureInfo, pGestureInfo);
}
PRBool nsWinGesture::CloseGestureInfoHandle(HGESTUREINFO hGestureInfo)
{
if (!mAvailable || !hGestureInfo)
return PR_FALSE;
return closeGestureInfoHandle(hGestureInfo);
}
PRBool nsWinGesture::GetGestureExtraArgs(HGESTUREINFO hGestureInfo, UINT cbExtraArgs, PBYTE pExtraArgs)
{
if (!mAvailable || !hGestureInfo || !pExtraArgs)
return PR_FALSE;
return getGestureExtraArgs(hGestureInfo, cbExtraArgs, pExtraArgs);
}
PRBool nsWinGesture::SetGestureConfig(HWND hWnd, UINT cIDs, PGESTURECONFIG pGestureConfig)
{
if (!mAvailable || !pGestureConfig)
return PR_FALSE;
return setGestureConfig(hWnd, 0, cIDs, pGestureConfig, sizeof(GESTURECONFIG));
}
PRBool nsWinGesture::GetGestureConfig(HWND hWnd, DWORD dwFlags, PUINT pcIDs, PGESTURECONFIG pGestureConfig)
{
if (!mAvailable || !pGestureConfig)
return PR_FALSE;
return getGestureConfig(hWnd, 0, dwFlags, pcIDs, pGestureConfig, sizeof(GESTURECONFIG));
}
PRBool nsWinGesture::IsPanEvent(LPARAM lParam)
{
GESTUREINFO gi;
ZeroMemory(&gi,sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
BOOL result = GetGestureInfo((HGESTUREINFO)lParam, &gi);
if (!result)
return PR_FALSE;
if (gi.dwID == GID_PAN)
return PR_TRUE;
return PR_FALSE;
}
/* Gesture event processing */
PRBool
nsWinGesture::ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, nsSimpleGestureEvent& evt)
{
GESTUREINFO gi;
ZeroMemory(&gi,sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
BOOL result = GetGestureInfo((HGESTUREINFO)lParam, &gi);
if (!result)
return PR_FALSE;
// The coordinates of this event
nsPointWin coord;
coord = gi.ptsLocation;
coord.ScreenToClient(hWnd);
evt.refPoint.x = coord.x;
evt.refPoint.y = coord.y;
// Multiple gesture can occur at the same time so gesture state
// info can't be shared.
switch(gi.dwID)
{
case GID_BEGIN:
case GID_END:
// These should always fall through to DefWndProc
return PR_FALSE;
break;
case GID_ZOOM:
{
if (gi.dwFlags & GF_BEGIN) {
// Send a zoom start event
// The low 32 bits are the distance in pixels.
mZoomIntermediate = (float)gi.ullArguments;
evt.message = NS_SIMPLE_GESTURE_MAGNIFY_START;
evt.delta = 0.0;
}
else {
// Send a zoom intermediate/end event, the delta is the change
// in touch points.
evt.message = NS_SIMPLE_GESTURE_MAGNIFY_UPDATE;
// (positive for a "zoom in")
evt.delta = -1.0 * (mZoomIntermediate - (float)gi.ullArguments);
mZoomIntermediate = (float)gi.ullArguments;
}
}
break;
case GID_ROTATE:
{
// Send a rotate start event
double radians = 0.0;
// On GF_BEGIN, ullArguments contains the absolute rotation at the
// start of the gesture. In later events it contains the offset from
// the start angle.
if (gi.ullArguments != 0)
radians = GID_ROTATE_ANGLE_FROM_ARGUMENT(gi.ullArguments);
double degrees = -1 * radians * (180/M_PI);
if (gi.dwFlags & GF_BEGIN) {
// At some point we should pass the initial angle in
// along with delta. It's useful.
degrees = mRotateIntermediate = 0.0;
}
evt.direction = 0;
evt.delta = degrees - mRotateIntermediate;
mRotateIntermediate = degrees;
if (evt.delta > 0)
evt.direction = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
else if (evt.delta < 0)
evt.direction = nsIDOMSimpleGestureEvent::ROTATION_CLOCKWISE;
if (gi.dwFlags & GF_BEGIN)
evt.message = NS_SIMPLE_GESTURE_ROTATE_START;
else if (gi.dwFlags & GF_END)
evt.message = NS_SIMPLE_GESTURE_ROTATE;
else
evt.message = NS_SIMPLE_GESTURE_ROTATE_UPDATE;
}
break;
case GID_TWOFINGERTAP:
{
// Normally maps to "restore" from whatever you may have recently changed. A simple
// double click.
evt.message = NS_SIMPLE_GESTURE_TAP;
}
break;
case GID_ROLLOVER:
{
// Two finger drum roll. Defaults to right click if it falls through.
evt.message = NS_SIMPLE_GESTURE_PRESSTAP;
}
break;
}
return PR_TRUE;
}
PRBool
nsWinGesture::ProcessPanMessage(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
GESTUREINFO gi;
ZeroMemory(&gi,sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
BOOL result = GetGestureInfo((HGESTUREINFO)lParam, &gi);
if (!result)
return PR_FALSE;
// The coordinates of this event
nsPointWin coord;
coord = gi.ptsLocation;
coord.ScreenToClient(hWnd);
switch(gi.dwID)
{
case GID_BEGIN:
case GID_END:
// These should always fall through to DefWndProc
return PR_FALSE;
break;
// Setup pixel scroll events for both axis
case GID_PAN:
{
if (gi.dwFlags & GF_BEGIN) {
mPanIntermediate = coord;
mPixelScrollDelta = 0;
} else {
mPixelScrollDelta.x = mPanIntermediate.x - coord.x;
mPixelScrollDelta.y = mPanIntermediate.y - coord.y;
mPanIntermediate = coord;
}
}
break;
}
return PR_TRUE;
}
PRBool
nsWinGesture::PanDeltaToPixelScrollX(nsMouseScrollEvent& evt)
{
if (mPixelScrollDelta.x != 0)
{
evt.scrollFlags = nsMouseScrollEvent::kIsHorizontal|nsMouseScrollEvent::kHasPixels|nsMouseScrollEvent::kNoLines;
evt.delta = mPixelScrollDelta.x;
evt.refPoint.x = mPanIntermediate.x;
evt.refPoint.y = mPanIntermediate.y;
return PR_TRUE;
}
return PR_FALSE;
}
PRBool
nsWinGesture::PanDeltaToPixelScrollY(nsMouseScrollEvent& evt)
{
if (mPixelScrollDelta.y != 0)
{
evt.scrollFlags = nsMouseScrollEvent::kIsVertical|nsMouseScrollEvent::kHasPixels|nsMouseScrollEvent::kNoLines;
evt.delta = mPixelScrollDelta.y;
evt.refPoint.x = mPanIntermediate.x;
evt.refPoint.y = mPanIntermediate.y;
return PR_TRUE;
}
return PR_FALSE;
}
#endif /* WinGesture_cpp__ */

View File

@ -0,0 +1,255 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jim Mathies <jmathies@mozilla.com>.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* 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 ***** */
#ifndef WinGesture_h__
#define WinGesture_h__
#include "nsdefs.h"
#include <winuser.h>
#include "nsPoint.h"
#include "nsGUIEvent.h"
#if !defined(NTDDI_WIN7) || NTDDI_VERSION < NTDDI_WIN7
DECLARE_HANDLE(HGESTUREINFO);
/*
* Gesture flags - GESTUREINFO.dwFlags
*/
#define GF_BEGIN 0x00000001
#define GF_INERTIA 0x00000002
#define GF_END 0x00000004
/*
* Gesture configuration structure
* - Used in SetGestureConfig and GetGestureConfig
* - Note that any setting not included in either GESTURECONFIG.dwWant or
* GESTURECONFIG.dwBlock will use the parent window's preferences or
* system defaults.
*/
typedef struct tagGESTURECONFIG {
DWORD dwID; // gesture ID
DWORD dwWant; // settings related to gesture ID that are to be turned on
DWORD dwBlock; // settings related to gesture ID that are to be turned off
} GESTURECONFIG, *PGESTURECONFIG;
/*
* Gesture information structure
* - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the
* GetGestureInfo function to retrieve this information.
* - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE
* message lParam into the GetGestureExtraArgs function to retrieve extended
* argument information.
*/
typedef struct tagGESTUREINFO {
UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
DWORD dwFlags; // see GF_* flags
DWORD dwID; // gesture ID, see GID_* defines
HWND hwndTarget; // handle to window targeted by this gesture
POINTS ptsLocation; // current location of this gesture
DWORD dwInstanceID; // internally used
DWORD dwSequenceID; // internally used
ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
} GESTUREINFO, *PGESTUREINFO;
typedef GESTUREINFO const * PCGESTUREINFO;
/*
* Gesture notification structure
* - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
* - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
* in progress and a gesture will be generated if one is recognized under the
* current gesture settings.
*/
typedef struct tagGESTURENOTIFYSTRUCT {
UINT cbSize; // size, in bytes, of this structure
DWORD dwFlags; // unused
HWND hwndTarget; // handle to window targeted by the gesture
POINTS ptsLocation; // starting location
DWORD dwInstanceID; // internally used
} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
/*
* Gesture argument helpers
* - Angle should be a double in the range of -2pi to +2pi
* - Argument should be an unsigned 16-bit value
*/
#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
/*
* Gesture configuration flags
*/
#define GC_ALLGESTURES 0x00000001
#define GC_ZOOM 0x00000001
#define GC_PAN 0x00000001
#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
#define GC_PAN_WITH_GUTTER 0x00000008
#define GC_PAN_WITH_INERTIA 0x00000010
#define GC_ROTATE 0x00000001
#define GC_TWOFINGERTAP 0x00000001
#define GC_ROLLOVER 0x00000001
/*
* Gesture IDs
*/
#define GID_BEGIN 1
#define GID_END 2
#define GID_ZOOM 3
#define GID_PAN 4
#define GID_ROTATE 5
#define GID_TWOFINGERTAP 6
#define GID_ROLLOVER 7
// Maximum number of gestures that can be included
// in a single call to SetGestureConfig / GetGestureConfig
#define GESTURECONFIGMAXCOUNT 256
// If specified, GetGestureConfig returns consolidated configuration
// for the specified window and it's parent window chain
#define GCF_INCLUDE_ANCESTORS 0x00000001
// Window events we need to respond to or receive
#define WM_TABLET_QUERYSYSTEMGESTURESTATUS 0x02CC
#define WM_GESTURE 0x0119
#define WM_GESTURENOTIFY 0x011A
// WM_TABLET_QUERYSYSTEMGESTURESTATUS return values
#define TABLET_ROTATE_GESTURE_ENABLE 0x02000000
#endif /* NTDDI_VERSION < NTDDI_WIN7 */
class nsPointWin : public nsIntPoint
{
public:
nsPointWin& operator=(const POINTS& aPoint) {
x = aPoint.x; y = aPoint.y;
return *this;
}
nsPointWin& operator=(const POINT& aPoint) {
x = aPoint.x; y = aPoint.y;
return *this;
}
nsPointWin& operator=(int val) {
x = y = val;
return *this;
}
void ScreenToClient(HWND hWnd) {
POINT tmp;
tmp.x = x; tmp.y = y;
::ScreenToClient(hWnd, &tmp);
*this = tmp;
}
};
class nsWinGesture
{
public:
nsWinGesture();
~nsWinGesture();
public:
PRBool InitWinGestureSupport(HWND hWnd);
PRBool ShutdownWinGestureSupport();
PRBool IsAvailable();
// Simple gesture process
PRBool ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, nsSimpleGestureEvent& evt);
// Pan processing
PRBool IsPanEvent(LPARAM lParam);
PRBool ProcessPanMessage(HWND hWnd, WPARAM wParam, LPARAM lParam);
PRBool PanDeltaToPixelScrollX(nsMouseScrollEvent& evt);
PRBool PanDeltaToPixelScrollY(nsMouseScrollEvent& evt);
public:
// Helpers
PRBool GetGestureInfo(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo);
PRBool CloseGestureInfoHandle(HGESTUREINFO hGestureInfo);
PRBool GetGestureExtraArgs(HGESTUREINFO hGestureInfo, UINT cbExtraArgs, PBYTE pExtraArgs);
PRBool SetGestureConfig(HWND hWnd, UINT cIDs, PGESTURECONFIG pGestureConfig);
PRBool GetGestureConfig(HWND hWnd, DWORD dwFlags, PUINT pcIDs, PGESTURECONFIG pGestureConfig);
protected:
private:
// Function prototypes
typedef BOOL (WINAPI * GetGestureInfoPtr)(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo);
typedef BOOL (WINAPI * CloseGestureInfoHandlePtr)(HGESTUREINFO hGestureInfo);
typedef BOOL (WINAPI * GetGestureExtraArgsPtr)(HGESTUREINFO hGestureInfo, UINT cbExtraArgs, PBYTE pExtraArgs);
typedef BOOL (WINAPI * SetGestureConfigPtr)(HWND hwnd, DWORD dwReserved, UINT cIDs, PGESTURECONFIG pGestureConfig, UINT cbSize);
typedef BOOL (WINAPI * GetGestureConfigPtr)(HWND hwnd, DWORD dwReserved, DWORD dwFlags, PUINT pcIDs, PGESTURECONFIG pGestureConfig, UINT cbSize);
// Static function pointers
static GetGestureInfoPtr getGestureInfo;
static CloseGestureInfoHandlePtr closeGestureInfoHandle;
static GetGestureExtraArgsPtr getGestureExtraArgs;
static SetGestureConfigPtr setGestureConfig;
static GetGestureConfigPtr getGestureConfig;
// Delay load info
PRBool InitLibrary();
void ShutdownLibrary();
static HMODULE sLibraryHandle;
static const PRUnichar kGestureLibraryName[];
PRBool mAvailable;
// Pan state
nsPointWin mPanIntermediate;
nsPointWin mPixelScrollDelta;
// Zoom state
double mZoomIntermediate;
// Rotate state
double mRotateIntermediate;
};
#endif /* WinGesture_h__ */

View File

@ -74,8 +74,8 @@
#include "nsUnicharUtils.h"
#include "prlog.h"
#include "nsISupportsPrimitives.h"
#include "gfxImageSurface.h"
#include "nsIDOMNSUIEvent.h"
#ifdef WINCE
@ -1311,6 +1311,18 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent,
CreateSoftKeyMenuBar(mWnd);
#endif
// Enable gesture support for this window.
if (mWindowType != eWindowType_invisible &&
mWindowType != eWindowType_plugin &&
mWindowType != eWindowType_java &&
mWindowType != eWindowType_toplevel) {
// eWindowType_toplevel is the top level main frame window. Gesture support
// there prevents the user from interacting with the title bar or nc
// areas using a single finger. Java and plugin windows can make their
// own calls.
mGesture.InitWinGestureSupport(mWnd);
}
return NS_OK;
}
@ -3705,331 +3717,334 @@ typedef struct {
} EventMsgInfo;
EventMsgInfo gAllEvents[] = {
{"WM_NULL", 0x0000},
{"WM_CREATE", 0x0001},
{"WM_DESTROY", 0x0002},
{"WM_MOVE", 0x0003},
{"WM_SIZE", 0x0005},
{"WM_ACTIVATE", 0x0006},
{"WM_SETFOCUS", 0x0007},
{"WM_KILLFOCUS", 0x0008},
{"WM_ENABLE", 0x000A},
{"WM_SETREDRAW", 0x000B},
{"WM_SETTEXT", 0x000C},
{"WM_GETTEXT", 0x000D},
{"WM_GETTEXTLENGTH", 0x000E},
{"WM_PAINT", 0x000F},
{"WM_CLOSE", 0x0010},
{"WM_QUERYENDSESSION", 0x0011},
{"WM_QUIT", 0x0012},
{"WM_QUERYOPEN", 0x0013},
{"WM_ERASEBKGND", 0x0014},
{"WM_SYSCOLORCHANGE", 0x0015},
{"WM_ENDSESSION", 0x0016},
{"WM_SHOWWINDOW", 0x0018},
{"WM_SETTINGCHANGE", 0x001A},
{"WM_DEVMODECHANGE", 0x001B},
{"WM_ACTIVATEAPP", 0x001C},
{"WM_FONTCHANGE", 0x001D},
{"WM_TIMECHANGE", 0x001E},
{"WM_CANCELMODE", 0x001F},
{"WM_SETCURSOR", 0x0020},
{"WM_MOUSEACTIVATE", 0x0021},
{"WM_CHILDACTIVATE", 0x0022},
{"WM_QUEUESYNC", 0x0023},
{"WM_GETMINMAXINFO", 0x0024},
{"WM_PAINTICON", 0x0026},
{"WM_ICONERASEBKGND", 0x0027},
{"WM_NEXTDLGCTL", 0x0028},
{"WM_SPOOLERSTATUS", 0x002A},
{"WM_DRAWITEM", 0x002B},
{"WM_MEASUREITEM", 0x002C},
{"WM_DELETEITEM", 0x002D},
{"WM_VKEYTOITEM", 0x002E},
{"WM_CHARTOITEM", 0x002F},
{"WM_SETFONT", 0x0030},
{"WM_GETFONT", 0x0031},
{"WM_SETHOTKEY", 0x0032},
{"WM_GETHOTKEY", 0x0033},
{"WM_QUERYDRAGICON", 0x0037},
{"WM_COMPAREITEM", 0x0039},
{"WM_GETOBJECT", 0x003D},
{"WM_COMPACTING", 0x0041},
{"WM_COMMNOTIFY", 0x0044},
{"WM_WINDOWPOSCHANGING", 0x0046},
{"WM_WINDOWPOSCHANGED", 0x0047},
{"WM_POWER", 0x0048},
{"WM_COPYDATA", 0x004A},
{"WM_CANCELJOURNAL", 0x004B},
{"WM_NOTIFY", 0x004E},
{"WM_INPUTLANGCHANGEREQUEST", 0x0050},
{"WM_INPUTLANGCHANGE", 0x0051},
{"WM_TCARD", 0x0052},
{"WM_HELP", 0x0053},
{"WM_USERCHANGED", 0x0054},
{"WM_NOTIFYFORMAT", 0x0055},
{"WM_CONTEXTMENU", 0x007B},
{"WM_STYLECHANGING", 0x007C},
{"WM_STYLECHANGED", 0x007D},
{"WM_DISPLAYCHANGE", 0x007E},
{"WM_GETICON", 0x007F},
{"WM_SETICON", 0x0080},
{"WM_NCCREATE", 0x0081},
{"WM_NCDESTROY", 0x0082},
{"WM_NCCALCSIZE", 0x0083},
{"WM_NCHITTEST", 0x0084},
{"WM_NCPAINT", 0x0085},
{"WM_NCACTIVATE", 0x0086},
{"WM_GETDLGCODE", 0x0087},
{"WM_SYNCPAINT", 0x0088},
{"WM_NCMOUSEMOVE", 0x00A0},
{"WM_NCLBUTTONDOWN", 0x00A1},
{"WM_NCLBUTTONUP", 0x00A2},
{"WM_NCLBUTTONDBLCLK", 0x00A3},
{"WM_NCRBUTTONDOWN", 0x00A4},
{"WM_NCRBUTTONUP", 0x00A5},
{"WM_NCRBUTTONDBLCLK", 0x00A6},
{"WM_NCMBUTTONDOWN", 0x00A7},
{"WM_NCMBUTTONUP", 0x00A8},
{"WM_NCMBUTTONDBLCLK", 0x00A9},
{"EM_GETSEL", 0x00B0},
{"EM_SETSEL", 0x00B1},
{"EM_GETRECT", 0x00B2},
{"EM_SETRECT", 0x00B3},
{"EM_SETRECTNP", 0x00B4},
{"EM_SCROLL", 0x00B5},
{"EM_LINESCROLL", 0x00B6},
{"EM_SCROLLCARET", 0x00B7},
{"EM_GETMODIFY", 0x00B8},
{"EM_SETMODIFY", 0x00B9},
{"EM_GETLINECOUNT", 0x00BA},
{"EM_LINEINDEX", 0x00BB},
{"EM_SETHANDLE", 0x00BC},
{"EM_GETHANDLE", 0x00BD},
{"EM_GETTHUMB", 0x00BE},
{"EM_LINELENGTH", 0x00C1},
{"EM_REPLACESEL", 0x00C2},
{"EM_GETLINE", 0x00C4},
{"EM_LIMITTEXT", 0x00C5},
{"EM_CANUNDO", 0x00C6},
{"EM_UNDO", 0x00C7},
{"EM_FMTLINES", 0x00C8},
{"EM_LINEFROMCHAR", 0x00C9},
{"EM_SETTABSTOPS", 0x00CB},
{"EM_SETPASSWORDCHAR", 0x00CC},
{"EM_EMPTYUNDOBUFFER", 0x00CD},
{"EM_GETFIRSTVISIBLELINE", 0x00CE},
{"EM_SETREADONLY", 0x00CF},
{"EM_SETWORDBREAKPROC", 0x00D0},
{"EM_GETWORDBREAKPROC", 0x00D1},
{"EM_GETPASSWORDCHAR", 0x00D2},
{"EM_SETMARGINS", 0x00D3},
{"EM_GETMARGINS", 0x00D4},
{"EM_GETLIMITTEXT", 0x00D5},
{"EM_POSFROMCHAR", 0x00D6},
{"EM_CHARFROMPOS", 0x00D7},
{"EM_SETIMESTATUS", 0x00D8},
{"EM_GETIMESTATUS", 0x00D9},
{"SBM_SETPOS", 0x00E0},
{"SBM_GETPOS", 0x00E1},
{"SBM_SETRANGE", 0x00E2},
{"SBM_SETRANGEREDRAW", 0x00E6},
{"SBM_GETRANGE", 0x00E3},
{"SBM_ENABLE_ARROWS", 0x00E4},
{"SBM_SETSCROLLINFO", 0x00E9},
{"SBM_GETSCROLLINFO", 0x00EA},
{"WM_KEYDOWN", 0x0100},
{"WM_KEYUP", 0x0101},
{"WM_CHAR", 0x0102},
{"WM_DEADCHAR", 0x0103},
{"WM_SYSKEYDOWN", 0x0104},
{"WM_SYSKEYUP", 0x0105},
{"WM_SYSCHAR", 0x0106},
{"WM_SYSDEADCHAR", 0x0107},
{"WM_KEYLAST", 0x0108},
{"WM_IME_STARTCOMPOSITION", 0x010D},
{"WM_IME_ENDCOMPOSITION", 0x010E},
{"WM_IME_COMPOSITION", 0x010F},
{"WM_INITDIALOG", 0x0110},
{"WM_COMMAND", 0x0111},
{"WM_SYSCOMMAND", 0x0112},
{"WM_TIMER", 0x0113},
{"WM_HSCROLL", 0x0114},
{"WM_VSCROLL", 0x0115},
{"WM_INITMENU", 0x0116},
{"WM_INITMENUPOPUP", 0x0117},
{"WM_MENUSELECT", 0x011F},
{"WM_MENUCHAR", 0x0120},
{"WM_ENTERIDLE", 0x0121},
{"WM_MENURBUTTONUP", 0x0122},
{"WM_MENUDRAG", 0x0123},
{"WM_MENUGETOBJECT", 0x0124},
{"WM_UNINITMENUPOPUP", 0x0125},
{"WM_MENUCOMMAND", 0x0126},
{"WM_CTLCOLORMSGBOX", 0x0132},
{"WM_CTLCOLOREDIT", 0x0133},
{"WM_CTLCOLORLISTBOX", 0x0134},
{"WM_CTLCOLORBTN", 0x0135},
{"WM_CTLCOLORDLG", 0x0136},
{"WM_CTLCOLORSCROLLBAR", 0x0137},
{"WM_CTLCOLORSTATIC", 0x0138},
{"CB_GETEDITSEL", 0x0140},
{"CB_LIMITTEXT", 0x0141},
{"CB_SETEDITSEL", 0x0142},
{"CB_ADDSTRING", 0x0143},
{"CB_DELETESTRING", 0x0144},
{"CB_DIR", 0x0145},
{"CB_GETCOUNT", 0x0146},
{"CB_GETCURSEL", 0x0147},
{"CB_GETLBTEXT", 0x0148},
{"CB_GETLBTEXTLEN", 0x0149},
{"CB_INSERTSTRING", 0x014A},
{"CB_RESETCONTENT", 0x014B},
{"CB_FINDSTRING", 0x014C},
{"CB_SELECTSTRING", 0x014D},
{"CB_SETCURSEL", 0x014E},
{"CB_SHOWDROPDOWN", 0x014F},
{"CB_GETITEMDATA", 0x0150},
{"CB_SETITEMDATA", 0x0151},
{"CB_GETDROPPEDCONTROLRECT", 0x0152},
{"CB_SETITEMHEIGHT", 0x0153},
{"CB_GETITEMHEIGHT", 0x0154},
{"CB_SETEXTENDEDUI", 0x0155},
{"CB_GETEXTENDEDUI", 0x0156},
{"CB_GETDROPPEDSTATE", 0x0157},
{"CB_FINDSTRINGEXACT", 0x0158},
{"CB_SETLOCALE", 0x0159},
{"CB_GETLOCALE", 0x015A},
{"CB_GETTOPINDEX", 0x015b},
{"CB_SETTOPINDEX", 0x015c},
{"CB_GETHORIZONTALEXTENT", 0x015d},
{"CB_SETHORIZONTALEXTENT", 0x015e},
{"CB_GETDROPPEDWIDTH", 0x015f},
{"CB_SETDROPPEDWIDTH", 0x0160},
{"CB_INITSTORAGE", 0x0161},
{"CB_MSGMAX", 0x0162},
{"LB_ADDSTRING", 0x0180},
{"LB_INSERTSTRING", 0x0181},
{"LB_DELETESTRING", 0x0182},
{"LB_SELITEMRANGEEX", 0x0183},
{"LB_RESETCONTENT", 0x0184},
{"LB_SETSEL", 0x0185},
{"LB_SETCURSEL", 0x0186},
{"LB_GETSEL", 0x0187},
{"LB_GETCURSEL", 0x0188},
{"LB_GETTEXT", 0x0189},
{"LB_GETTEXTLEN", 0x018A},
{"LB_GETCOUNT", 0x018B},
{"LB_SELECTSTRING", 0x018C},
{"LB_DIR", 0x018D},
{"LB_GETTOPINDEX", 0x018E},
{"LB_FINDSTRING", 0x018F},
{"LB_GETSELCOUNT", 0x0190},
{"LB_GETSELITEMS", 0x0191},
{"LB_SETTABSTOPS", 0x0192},
{"LB_GETHORIZONTALEXTENT", 0x0193},
{"LB_SETHORIZONTALEXTENT", 0x0194},
{"LB_SETCOLUMNWIDTH", 0x0195},
{"LB_ADDFILE", 0x0196},
{"LB_SETTOPINDEX", 0x0197},
{"LB_GETITEMRECT", 0x0198},
{"LB_GETITEMDATA", 0x0199},
{"LB_SETITEMDATA", 0x019A},
{"LB_SELITEMRANGE", 0x019B},
{"LB_SETANCHORINDEX", 0x019C},
{"LB_GETANCHORINDEX", 0x019D},
{"LB_SETCARETINDEX", 0x019E},
{"LB_GETCARETINDEX", 0x019F},
{"LB_SETITEMHEIGHT", 0x01A0},
{"LB_GETITEMHEIGHT", 0x01A1},
{"LB_FINDSTRINGEXACT", 0x01A2},
{"LB_SETLOCALE", 0x01A5},
{"LB_GETLOCALE", 0x01A6},
{"LB_SETCOUNT", 0x01A7},
{"LB_INITSTORAGE", 0x01A8},
{"LB_ITEMFROMPOINT", 0x01A9},
{"LB_MSGMAX", 0x01B0},
{"WM_MOUSEMOVE", 0x0200},
{"WM_LBUTTONDOWN", 0x0201},
{"WM_LBUTTONUP", 0x0202},
{"WM_LBUTTONDBLCLK", 0x0203},
{"WM_RBUTTONDOWN", 0x0204},
{"WM_RBUTTONUP", 0x0205},
{"WM_RBUTTONDBLCLK", 0x0206},
{"WM_MBUTTONDOWN", 0x0207},
{"WM_MBUTTONUP", 0x0208},
{"WM_MBUTTONDBLCLK", 0x0209},
{"WM_MOUSEWHEEL", 0x020A},
{"WM_MOUSEHWHEEL", 0x020E},
{"WM_PARENTNOTIFY", 0x0210},
{"WM_ENTERMENULOOP", 0x0211},
{"WM_EXITMENULOOP", 0x0212},
{"WM_NEXTMENU", 0x0213},
{"WM_SIZING", 0x0214},
{"WM_CAPTURECHANGED", 0x0215},
{"WM_MOVING", 0x0216},
{"WM_POWERBROADCAST", 0x0218},
{"WM_DEVICECHANGE", 0x0219},
{"WM_MDICREATE", 0x0220},
{"WM_MDIDESTROY", 0x0221},
{"WM_MDIACTIVATE", 0x0222},
{"WM_MDIRESTORE", 0x0223},
{"WM_MDINEXT", 0x0224},
{"WM_MDIMAXIMIZE", 0x0225},
{"WM_MDITILE", 0x0226},
{"WM_MDICASCADE", 0x0227},
{"WM_MDIICONARRANGE", 0x0228},
{"WM_MDIGETACTIVE", 0x0229},
{"WM_MDISETMENU", 0x0230},
{"WM_ENTERSIZEMOVE", 0x0231},
{"WM_EXITSIZEMOVE", 0x0232},
{"WM_DROPFILES", 0x0233},
{"WM_MDIREFRESHMENU", 0x0234},
{"WM_IME_SETCONTEXT", 0x0281},
{"WM_IME_NOTIFY", 0x0282},
{"WM_IME_CONTROL", 0x0283},
{"WM_IME_COMPOSITIONFULL", 0x0284},
{"WM_IME_SELECT", 0x0285},
{"WM_IME_CHAR", 0x0286},
{"WM_IME_REQUEST", 0x0288},
{"WM_IME_KEYDOWN", 0x0290},
{"WM_IME_KEYUP", 0x0291},
{"WM_NCMOUSEHOVER", 0x02A0},
{"WM_MOUSEHOVER", 0x02A1},
{"WM_MOUSELEAVE", 0x02A3},
{"WM_CUT", 0x0300},
{"WM_COPY", 0x0301},
{"WM_PASTE", 0x0302},
{"WM_CLEAR", 0x0303},
{"WM_UNDO", 0x0304},
{"WM_RENDERFORMAT", 0x0305},
{"WM_RENDERALLFORMATS", 0x0306},
{"WM_DESTROYCLIPBOARD", 0x0307},
{"WM_DRAWCLIPBOARD", 0x0308},
{"WM_PAINTCLIPBOARD", 0x0309},
{"WM_VSCROLLCLIPBOARD", 0x030A},
{"WM_SIZECLIPBOARD", 0x030B},
{"WM_ASKCBFORMATNAME", 0x030C},
{"WM_CHANGECBCHAIN", 0x030D},
{"WM_HSCROLLCLIPBOARD", 0x030E},
{"WM_QUERYNEWPALETTE", 0x030F},
{"WM_PALETTEISCHANGING", 0x0310},
{"WM_PALETTECHANGED", 0x0311},
{"WM_HOTKEY", 0x0312},
{"WM_PRINT", 0x0317},
{"WM_PRINTCLIENT", 0x0318},
{"WM_THEMECHANGED", 0x031A},
{"WM_HANDHELDFIRST", 0x0358},
{"WM_HANDHELDLAST", 0x035F},
{"WM_AFXFIRST", 0x0360},
{"WM_AFXLAST", 0x037F},
{"WM_PENWINFIRST", 0x0380},
{"WM_PENWINLAST", 0x038F},
{"WM_APP", 0x8000},
{"WM_DWMCOMPOSITIONCHANGED", 0x031E},
{"WM_DWMNCRENDERINGCHANGED", 0x031F},
{"WM_DWMCOLORIZATIONCOLORCHANGED", 0x0320},
{"WM_DWMWINDOWMAXIMIZEDCHANGE", 0x0321},
{"WM_NULL", 0x0000},
{"WM_CREATE", 0x0001},
{"WM_DESTROY", 0x0002},
{"WM_MOVE", 0x0003},
{"WM_SIZE", 0x0005},
{"WM_ACTIVATE", 0x0006},
{"WM_SETFOCUS", 0x0007},
{"WM_KILLFOCUS", 0x0008},
{"WM_ENABLE", 0x000A},
{"WM_SETREDRAW", 0x000B},
{"WM_SETTEXT", 0x000C},
{"WM_GETTEXT", 0x000D},
{"WM_GETTEXTLENGTH", 0x000E},
{"WM_PAINT", 0x000F},
{"WM_CLOSE", 0x0010},
{"WM_QUERYENDSESSION", 0x0011},
{"WM_QUIT", 0x0012},
{"WM_QUERYOPEN", 0x0013},
{"WM_ERASEBKGND", 0x0014},
{"WM_SYSCOLORCHANGE", 0x0015},
{"WM_ENDSESSION", 0x0016},
{"WM_SHOWWINDOW", 0x0018},
{"WM_SETTINGCHANGE", 0x001A},
{"WM_DEVMODECHANGE", 0x001B},
{"WM_ACTIVATEAPP", 0x001C},
{"WM_FONTCHANGE", 0x001D},
{"WM_TIMECHANGE", 0x001E},
{"WM_CANCELMODE", 0x001F},
{"WM_SETCURSOR", 0x0020},
{"WM_MOUSEACTIVATE", 0x0021},
{"WM_CHILDACTIVATE", 0x0022},
{"WM_QUEUESYNC", 0x0023},
{"WM_GETMINMAXINFO", 0x0024},
{"WM_PAINTICON", 0x0026},
{"WM_ICONERASEBKGND", 0x0027},
{"WM_NEXTDLGCTL", 0x0028},
{"WM_SPOOLERSTATUS", 0x002A},
{"WM_DRAWITEM", 0x002B},
{"WM_MEASUREITEM", 0x002C},
{"WM_DELETEITEM", 0x002D},
{"WM_VKEYTOITEM", 0x002E},
{"WM_CHARTOITEM", 0x002F},
{"WM_SETFONT", 0x0030},
{"WM_GETFONT", 0x0031},
{"WM_SETHOTKEY", 0x0032},
{"WM_GETHOTKEY", 0x0033},
{"WM_QUERYDRAGICON", 0x0037},
{"WM_COMPAREITEM", 0x0039},
{"WM_GETOBJECT", 0x003D},
{"WM_COMPACTING", 0x0041},
{"WM_COMMNOTIFY", 0x0044},
{"WM_WINDOWPOSCHANGING", 0x0046},
{"WM_WINDOWPOSCHANGED", 0x0047},
{"WM_POWER", 0x0048},
{"WM_COPYDATA", 0x004A},
{"WM_CANCELJOURNAL", 0x004B},
{"WM_NOTIFY", 0x004E},
{"WM_INPUTLANGCHANGEREQUEST", 0x0050},
{"WM_INPUTLANGCHANGE", 0x0051},
{"WM_TCARD", 0x0052},
{"WM_HELP", 0x0053},
{"WM_USERCHANGED", 0x0054},
{"WM_NOTIFYFORMAT", 0x0055},
{"WM_CONTEXTMENU", 0x007B},
{"WM_STYLECHANGING", 0x007C},
{"WM_STYLECHANGED", 0x007D},
{"WM_DISPLAYCHANGE", 0x007E},
{"WM_GETICON", 0x007F},
{"WM_SETICON", 0x0080},
{"WM_NCCREATE", 0x0081},
{"WM_NCDESTROY", 0x0082},
{"WM_NCCALCSIZE", 0x0083},
{"WM_NCHITTEST", 0x0084},
{"WM_NCPAINT", 0x0085},
{"WM_NCACTIVATE", 0x0086},
{"WM_GETDLGCODE", 0x0087},
{"WM_SYNCPAINT", 0x0088},
{"WM_NCMOUSEMOVE", 0x00A0},
{"WM_NCLBUTTONDOWN", 0x00A1},
{"WM_NCLBUTTONUP", 0x00A2},
{"WM_NCLBUTTONDBLCLK", 0x00A3},
{"WM_NCRBUTTONDOWN", 0x00A4},
{"WM_NCRBUTTONUP", 0x00A5},
{"WM_NCRBUTTONDBLCLK", 0x00A6},
{"WM_NCMBUTTONDOWN", 0x00A7},
{"WM_NCMBUTTONUP", 0x00A8},
{"WM_NCMBUTTONDBLCLK", 0x00A9},
{"EM_GETSEL", 0x00B0},
{"EM_SETSEL", 0x00B1},
{"EM_GETRECT", 0x00B2},
{"EM_SETRECT", 0x00B3},
{"EM_SETRECTNP", 0x00B4},
{"EM_SCROLL", 0x00B5},
{"EM_LINESCROLL", 0x00B6},
{"EM_SCROLLCARET", 0x00B7},
{"EM_GETMODIFY", 0x00B8},
{"EM_SETMODIFY", 0x00B9},
{"EM_GETLINECOUNT", 0x00BA},
{"EM_LINEINDEX", 0x00BB},
{"EM_SETHANDLE", 0x00BC},
{"EM_GETHANDLE", 0x00BD},
{"EM_GETTHUMB", 0x00BE},
{"EM_LINELENGTH", 0x00C1},
{"EM_REPLACESEL", 0x00C2},
{"EM_GETLINE", 0x00C4},
{"EM_LIMITTEXT", 0x00C5},
{"EM_CANUNDO", 0x00C6},
{"EM_UNDO", 0x00C7},
{"EM_FMTLINES", 0x00C8},
{"EM_LINEFROMCHAR", 0x00C9},
{"EM_SETTABSTOPS", 0x00CB},
{"EM_SETPASSWORDCHAR", 0x00CC},
{"EM_EMPTYUNDOBUFFER", 0x00CD},
{"EM_GETFIRSTVISIBLELINE", 0x00CE},
{"EM_SETREADONLY", 0x00CF},
{"EM_SETWORDBREAKPROC", 0x00D0},
{"EM_GETWORDBREAKPROC", 0x00D1},
{"EM_GETPASSWORDCHAR", 0x00D2},
{"EM_SETMARGINS", 0x00D3},
{"EM_GETMARGINS", 0x00D4},
{"EM_GETLIMITTEXT", 0x00D5},
{"EM_POSFROMCHAR", 0x00D6},
{"EM_CHARFROMPOS", 0x00D7},
{"EM_SETIMESTATUS", 0x00D8},
{"EM_GETIMESTATUS", 0x00D9},
{"SBM_SETPOS", 0x00E0},
{"SBM_GETPOS", 0x00E1},
{"SBM_SETRANGE", 0x00E2},
{"SBM_SETRANGEREDRAW", 0x00E6},
{"SBM_GETRANGE", 0x00E3},
{"SBM_ENABLE_ARROWS", 0x00E4},
{"SBM_SETSCROLLINFO", 0x00E9},
{"SBM_GETSCROLLINFO", 0x00EA},
{"WM_KEYDOWN", 0x0100},
{"WM_KEYUP", 0x0101},
{"WM_CHAR", 0x0102},
{"WM_DEADCHAR", 0x0103},
{"WM_SYSKEYDOWN", 0x0104},
{"WM_SYSKEYUP", 0x0105},
{"WM_SYSCHAR", 0x0106},
{"WM_SYSDEADCHAR", 0x0107},
{"WM_KEYLAST", 0x0108},
{"WM_IME_STARTCOMPOSITION", 0x010D},
{"WM_IME_ENDCOMPOSITION", 0x010E},
{"WM_IME_COMPOSITION", 0x010F},
{"WM_INITDIALOG", 0x0110},
{"WM_COMMAND", 0x0111},
{"WM_SYSCOMMAND", 0x0112},
{"WM_TIMER", 0x0113},
{"WM_HSCROLL", 0x0114},
{"WM_VSCROLL", 0x0115},
{"WM_INITMENU", 0x0116},
{"WM_INITMENUPOPUP", 0x0117},
{"WM_MENUSELECT", 0x011F},
{"WM_MENUCHAR", 0x0120},
{"WM_ENTERIDLE", 0x0121},
{"WM_MENURBUTTONUP", 0x0122},
{"WM_MENUDRAG", 0x0123},
{"WM_MENUGETOBJECT", 0x0124},
{"WM_UNINITMENUPOPUP", 0x0125},
{"WM_MENUCOMMAND", 0x0126},
{"WM_CTLCOLORMSGBOX", 0x0132},
{"WM_CTLCOLOREDIT", 0x0133},
{"WM_CTLCOLORLISTBOX", 0x0134},
{"WM_CTLCOLORBTN", 0x0135},
{"WM_CTLCOLORDLG", 0x0136},
{"WM_CTLCOLORSCROLLBAR", 0x0137},
{"WM_CTLCOLORSTATIC", 0x0138},
{"CB_GETEDITSEL", 0x0140},
{"CB_LIMITTEXT", 0x0141},
{"CB_SETEDITSEL", 0x0142},
{"CB_ADDSTRING", 0x0143},
{"CB_DELETESTRING", 0x0144},
{"CB_DIR", 0x0145},
{"CB_GETCOUNT", 0x0146},
{"CB_GETCURSEL", 0x0147},
{"CB_GETLBTEXT", 0x0148},
{"CB_GETLBTEXTLEN", 0x0149},
{"CB_INSERTSTRING", 0x014A},
{"CB_RESETCONTENT", 0x014B},
{"CB_FINDSTRING", 0x014C},
{"CB_SELECTSTRING", 0x014D},
{"CB_SETCURSEL", 0x014E},
{"CB_SHOWDROPDOWN", 0x014F},
{"CB_GETITEMDATA", 0x0150},
{"CB_SETITEMDATA", 0x0151},
{"CB_GETDROPPEDCONTROLRECT", 0x0152},
{"CB_SETITEMHEIGHT", 0x0153},
{"CB_GETITEMHEIGHT", 0x0154},
{"CB_SETEXTENDEDUI", 0x0155},
{"CB_GETEXTENDEDUI", 0x0156},
{"CB_GETDROPPEDSTATE", 0x0157},
{"CB_FINDSTRINGEXACT", 0x0158},
{"CB_SETLOCALE", 0x0159},
{"CB_GETLOCALE", 0x015A},
{"CB_GETTOPINDEX", 0x015b},
{"CB_SETTOPINDEX", 0x015c},
{"CB_GETHORIZONTALEXTENT", 0x015d},
{"CB_SETHORIZONTALEXTENT", 0x015e},
{"CB_GETDROPPEDWIDTH", 0x015f},
{"CB_SETDROPPEDWIDTH", 0x0160},
{"CB_INITSTORAGE", 0x0161},
{"CB_MSGMAX", 0x0162},
{"LB_ADDSTRING", 0x0180},
{"LB_INSERTSTRING", 0x0181},
{"LB_DELETESTRING", 0x0182},
{"LB_SELITEMRANGEEX", 0x0183},
{"LB_RESETCONTENT", 0x0184},
{"LB_SETSEL", 0x0185},
{"LB_SETCURSEL", 0x0186},
{"LB_GETSEL", 0x0187},
{"LB_GETCURSEL", 0x0188},
{"LB_GETTEXT", 0x0189},
{"LB_GETTEXTLEN", 0x018A},
{"LB_GETCOUNT", 0x018B},
{"LB_SELECTSTRING", 0x018C},
{"LB_DIR", 0x018D},
{"LB_GETTOPINDEX", 0x018E},
{"LB_FINDSTRING", 0x018F},
{"LB_GETSELCOUNT", 0x0190},
{"LB_GETSELITEMS", 0x0191},
{"LB_SETTABSTOPS", 0x0192},
{"LB_GETHORIZONTALEXTENT", 0x0193},
{"LB_SETHORIZONTALEXTENT", 0x0194},
{"LB_SETCOLUMNWIDTH", 0x0195},
{"LB_ADDFILE", 0x0196},
{"LB_SETTOPINDEX", 0x0197},
{"LB_GETITEMRECT", 0x0198},
{"LB_GETITEMDATA", 0x0199},
{"LB_SETITEMDATA", 0x019A},
{"LB_SELITEMRANGE", 0x019B},
{"LB_SETANCHORINDEX", 0x019C},
{"LB_GETANCHORINDEX", 0x019D},
{"LB_SETCARETINDEX", 0x019E},
{"LB_GETCARETINDEX", 0x019F},
{"LB_SETITEMHEIGHT", 0x01A0},
{"LB_GETITEMHEIGHT", 0x01A1},
{"LB_FINDSTRINGEXACT", 0x01A2},
{"LB_SETLOCALE", 0x01A5},
{"LB_GETLOCALE", 0x01A6},
{"LB_SETCOUNT", 0x01A7},
{"LB_INITSTORAGE", 0x01A8},
{"LB_ITEMFROMPOINT", 0x01A9},
{"LB_MSGMAX", 0x01B0},
{"WM_MOUSEMOVE", 0x0200},
{"WM_LBUTTONDOWN", 0x0201},
{"WM_LBUTTONUP", 0x0202},
{"WM_LBUTTONDBLCLK", 0x0203},
{"WM_RBUTTONDOWN", 0x0204},
{"WM_RBUTTONUP", 0x0205},
{"WM_RBUTTONDBLCLK", 0x0206},
{"WM_MBUTTONDOWN", 0x0207},
{"WM_MBUTTONUP", 0x0208},
{"WM_MBUTTONDBLCLK", 0x0209},
{"WM_MOUSEWHEEL", 0x020A},
{"WM_MOUSEHWHEEL", 0x020E},
{"WM_PARENTNOTIFY", 0x0210},
{"WM_ENTERMENULOOP", 0x0211},
{"WM_EXITMENULOOP", 0x0212},
{"WM_NEXTMENU", 0x0213},
{"WM_SIZING", 0x0214},
{"WM_CAPTURECHANGED", 0x0215},
{"WM_MOVING", 0x0216},
{"WM_POWERBROADCAST", 0x0218},
{"WM_DEVICECHANGE", 0x0219},
{"WM_MDICREATE", 0x0220},
{"WM_MDIDESTROY", 0x0221},
{"WM_MDIACTIVATE", 0x0222},
{"WM_MDIRESTORE", 0x0223},
{"WM_MDINEXT", 0x0224},
{"WM_MDIMAXIMIZE", 0x0225},
{"WM_MDITILE", 0x0226},
{"WM_MDICASCADE", 0x0227},
{"WM_MDIICONARRANGE", 0x0228},
{"WM_MDIGETACTIVE", 0x0229},
{"WM_MDISETMENU", 0x0230},
{"WM_ENTERSIZEMOVE", 0x0231},
{"WM_EXITSIZEMOVE", 0x0232},
{"WM_DROPFILES", 0x0233},
{"WM_MDIREFRESHMENU", 0x0234},
{"WM_IME_SETCONTEXT", 0x0281},
{"WM_IME_NOTIFY", 0x0282},
{"WM_IME_CONTROL", 0x0283},
{"WM_IME_COMPOSITIONFULL", 0x0284},
{"WM_IME_SELECT", 0x0285},
{"WM_IME_CHAR", 0x0286},
{"WM_IME_REQUEST", 0x0288},
{"WM_IME_KEYDOWN", 0x0290},
{"WM_IME_KEYUP", 0x0291},
{"WM_NCMOUSEHOVER", 0x02A0},
{"WM_MOUSEHOVER", 0x02A1},
{"WM_MOUSELEAVE", 0x02A3},
{"WM_CUT", 0x0300},
{"WM_COPY", 0x0301},
{"WM_PASTE", 0x0302},
{"WM_CLEAR", 0x0303},
{"WM_UNDO", 0x0304},
{"WM_RENDERFORMAT", 0x0305},
{"WM_RENDERALLFORMATS", 0x0306},
{"WM_DESTROYCLIPBOARD", 0x0307},
{"WM_DRAWCLIPBOARD", 0x0308},
{"WM_PAINTCLIPBOARD", 0x0309},
{"WM_VSCROLLCLIPBOARD", 0x030A},
{"WM_SIZECLIPBOARD", 0x030B},
{"WM_ASKCBFORMATNAME", 0x030C},
{"WM_CHANGECBCHAIN", 0x030D},
{"WM_HSCROLLCLIPBOARD", 0x030E},
{"WM_QUERYNEWPALETTE", 0x030F},
{"WM_PALETTEISCHANGING", 0x0310},
{"WM_PALETTECHANGED", 0x0311},
{"WM_HOTKEY", 0x0312},
{"WM_PRINT", 0x0317},
{"WM_PRINTCLIENT", 0x0318},
{"WM_THEMECHANGED", 0x031A},
{"WM_HANDHELDFIRST", 0x0358},
{"WM_HANDHELDLAST", 0x035F},
{"WM_AFXFIRST", 0x0360},
{"WM_AFXLAST", 0x037F},
{"WM_PENWINFIRST", 0x0380},
{"WM_PENWINLAST", 0x038F},
{"WM_APP", 0x8000},
{"WM_DWMCOMPOSITIONCHANGED", 0x031E},
{"WM_DWMNCRENDERINGCHANGED", 0x031F},
{"WM_DWMCOLORIZATIONCOLORCHANGED", 0x0320},
{"WM_DWMWINDOWMAXIMIZEDCHANGE", 0x0321},
{"WM_TABLET_QUERYSYSTEMGESTURESTATUS", 0x02CC},
{"WM_GESTURE", 0x0119},
{"WM_GESTURENOTIFY", 0x011A},
{NULL, 0x0}
};
@ -5294,6 +5309,19 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
Invalidate(PR_FALSE);
break;
#endif
/* Gesture support events */
case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
// According to MS samples, this must be handled to enable
// rotational support in multi-touch drivers.
result = PR_TRUE;
*aRetValue = TABLET_ROTATE_GESTURE_ENABLE;
break;
case WM_GESTURE:
result = ProcessGestureMessage(wParam, lParam);
break;
}
//*aRetValue = result;
@ -5307,6 +5335,62 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
}
}
PRBool nsWindow::ProcessGestureMessage(WPARAM wParam, LPARAM lParam)
{
// Treatment for pan events which translate into scroll events:
if (mGesture.IsPanEvent(lParam)) {
nsMouseScrollEvent event(PR_TRUE, NS_MOUSE_PIXEL_SCROLL, this);
if ( !mGesture.ProcessPanMessage(mWnd, wParam, lParam) )
return PR_FALSE; // ignore
nsEventStatus status;
event.isShift = IS_VK_DOWN(NS_VK_SHIFT);
event.isControl = IS_VK_DOWN(NS_VK_CONTROL);
event.isMeta = PR_FALSE;
event.isAlt = IS_VK_DOWN(NS_VK_ALT);
event.button = 0;
event.time = ::GetMessageTime();
if (mGesture.PanDeltaToPixelScrollX(event)) {
DispatchEvent(&event, status);
}
if (mGesture.PanDeltaToPixelScrollY(event)) {
DispatchEvent(&event, status);
}
mGesture.CloseGestureInfoHandle((HGESTUREINFO)lParam);
return PR_TRUE;
}
// Other gestures translate into simple gesture events:
nsSimpleGestureEvent event(PR_TRUE, 0, this, 0, 0.0);
if ( !mGesture.ProcessGestureMessage(mWnd, wParam, lParam, event) ) {
return PR_FALSE; // fall through to DefWndProc
}
// Polish up and send off the new event
event.isShift = IS_VK_DOWN(NS_VK_SHIFT);
event.isControl = IS_VK_DOWN(NS_VK_CONTROL);
event.isMeta = PR_FALSE;
event.isAlt = IS_VK_DOWN(NS_VK_ALT);
event.button = 0;
event.time = ::GetMessageTime();
nsEventStatus status;
DispatchEvent(&event, status);
if (status == nsEventStatus_eIgnore) {
return PR_FALSE; // Ignored, fall through
}
// Only close this if we process and return true.
mGesture.CloseGestureInfoHandle((HGESTUREINFO)lParam);
return PR_TRUE; // Handled
}
LRESULT nsWindow::ProcessCharMessage(const MSG &aMsg, PRBool *aEventDispatched)
{
NS_PRECONDITION(aMsg.message == WM_CHAR || aMsg.message == WM_SYSCHAR,

View File

@ -71,6 +71,8 @@ struct nsFakeCharMessage;
#include "gfxWindowsSurface.h"
#include "nsWinGesture.h"
// Text Services Framework support
#ifndef WINCE
#define NS_ENABLE_TSF
@ -297,6 +299,7 @@ protected:
void DispatchPendingEvents();
virtual PRBool ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue);
virtual PRBool ProcessGestureMessage(WPARAM wParam, LPARAM lParam);
/**
* The result means whether this method processed the native event for
@ -312,7 +315,6 @@ protected:
LRESULT ProcessKeyDownMessage(const MSG &aMsg,
PRBool *aEventDispatched);
// Allow Derived classes to modify the height that is passed
// when the window is created or resized.
virtual PRInt32 GetHeight(PRInt32 aProposedHeight);
@ -537,6 +539,9 @@ protected:
// Drag & Drop
nsNativeDragTarget * mNativeDragTarget;
// Win7 Gesture processing and management
nsWinGesture mGesture;
// Enumeration of the methods which are accessible on the "main GUI thread"
// via the CallMethod(...) mechanism...
// see nsSwitchToUIThread