mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 839342. Make metro widget listen for EdgeGestureStarted and EdgeGestureCanceled, in addition to EdgeGestureCompleted. Show the edge UI on EdgeGestureStarted and EdgeGestureCompleted, hide it on EdgeGestureCanceled. This time without bustage! r=bbondy
This commit is contained in:
parent
d20b4ce4b4
commit
4a868b408f
@ -162,8 +162,10 @@ function test_TestEventListeners()
|
||||
test_clicks("MozTapGesture", 3);
|
||||
test_clicks("MozPressTapGesture", 1);
|
||||
|
||||
// simple delivery test for edgeui gesture
|
||||
e("MozEdgeUIGesture", 0, 0, 0);
|
||||
// simple delivery test for edgeui gestures
|
||||
e("MozEdgeUIStarted", 0, 0, 0);
|
||||
e("MozEdgeUICanceled", 0, 0, 0);
|
||||
e("MozEdgeUICompleted", 0, 0, 0);
|
||||
|
||||
// event.shiftKey
|
||||
let modifier = Components.interfaces.nsIDOMEvent.SHIFT_MASK;
|
||||
|
@ -46,7 +46,7 @@ const BrowserTouchHandler = {
|
||||
// Send the MozEdgeUIGesture to input.js to
|
||||
// toggle the context ui.
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("MozEdgeUIGesture", true, false);
|
||||
event.initEvent("MozEdgeUICompleted", true, false);
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
},
|
||||
|
@ -1090,7 +1090,9 @@ var ContextUI = {
|
||||
Elements.browsers.addEventListener("mousedown", this, true);
|
||||
Elements.browsers.addEventListener("touchstart", this, true);
|
||||
Elements.browsers.addEventListener("AlertActive", this, true);
|
||||
window.addEventListener("MozEdgeUIGesture", this, true);
|
||||
window.addEventListener("MozEdgeUIStarted", this, true);
|
||||
window.addEventListener("MozEdgeUICanceled", this, true);
|
||||
window.addEventListener("MozEdgeUICompleted", this, true);
|
||||
window.addEventListener("keypress", this, true);
|
||||
window.addEventListener("KeyboardChanged", this, false);
|
||||
|
||||
@ -1283,7 +1285,29 @@ var ContextUI = {
|
||||
* Events
|
||||
*/
|
||||
|
||||
_onEdgeUIEvent: function _onEdgeUIEvent(aEvent) {
|
||||
_onEdgeUIStarted: function(aEvent) {
|
||||
this._hasEdgeSwipeStarted = true;
|
||||
this._clearDelayedTimeout();
|
||||
|
||||
if (StartUI.hide()) {
|
||||
this.dismiss();
|
||||
return;
|
||||
}
|
||||
this.toggle();
|
||||
},
|
||||
|
||||
_onEdgeUICanceled: function(aEvent) {
|
||||
this._hasEdgeSwipeStarted = false;
|
||||
StartUI.hide();
|
||||
this.dismiss();
|
||||
},
|
||||
|
||||
_onEdgeUICompleted: function(aEvent) {
|
||||
if (this._hasEdgeSwipeStarted) {
|
||||
this._hasEdgeSwipeStarted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this._clearDelayedTimeout();
|
||||
if (StartUI.hide()) {
|
||||
this.dismiss();
|
||||
@ -1294,8 +1318,14 @@ var ContextUI = {
|
||||
|
||||
handleEvent: function handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "MozEdgeUIGesture":
|
||||
this._onEdgeUIEvent(aEvent);
|
||||
case "MozEdgeUIStarted":
|
||||
this._onEdgeUIStarted(aEvent);
|
||||
break;
|
||||
case "MozEdgeUICanceled":
|
||||
this._onEdgeUICanceled(aEvent);
|
||||
break;
|
||||
case "MozEdgeUICompleted":
|
||||
this._onEdgeUICompleted(aEvent);
|
||||
break;
|
||||
case "mousedown":
|
||||
if (aEvent.button == 0 && this.isVisible)
|
||||
@ -1441,7 +1471,7 @@ var StartUI = {
|
||||
break;
|
||||
case "contextmenu":
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("MozEdgeUIGesture", true, false);
|
||||
event.initEvent("MozEdgeUICompleted", true, false);
|
||||
window.dispatchEvent(event);
|
||||
break;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ var TouchModule = {
|
||||
// a edge ui event when we get the contextmenu event.
|
||||
if (this._treatMouseAsTouch) {
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("MozEdgeUIGesture", true, false);
|
||||
event.initEvent("MozEdgeUICompleted", true, false);
|
||||
window.dispatchEvent(event);
|
||||
return;
|
||||
}
|
||||
|
@ -88,6 +88,6 @@ gTests.push({
|
||||
|
||||
function doEdgeUIGesture() {
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("MozEdgeUIGesture", true, false);
|
||||
event.initEvent("MozEdgeUICompleted", true, false);
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ function fireAppBarDisplayEvent()
|
||||
{
|
||||
let promise = waitForEvent(Elements.tray, "transitionend");
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("MozEdgeUIGesture", true, false);
|
||||
event.initEvent("MozEdgeUICompleted", true, false);
|
||||
gWindow.dispatchEvent(event);
|
||||
purgeEventQueue();
|
||||
return promise;
|
||||
@ -735,4 +735,4 @@ function stubMethod(aObj, aMethod) {
|
||||
};
|
||||
aObj[aMethod] = func;
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
@ -1737,7 +1737,9 @@ GK_ATOM(onMozRotateGestureUpdate, "onMozRotateGestureUpdate")
|
||||
GK_ATOM(onMozRotateGesture, "onMozRotateGesture")
|
||||
GK_ATOM(onMozTapGesture, "onMozTapGesture")
|
||||
GK_ATOM(onMozPressTapGesture, "onMozPressTapGesture")
|
||||
GK_ATOM(onMozEdgeUIGesture, "onMozEdgeUIGesture")
|
||||
GK_ATOM(onMozEdgeUIStarted, "onMozEdgeUIStarted")
|
||||
GK_ATOM(onMozEdgeUICanceled, "onMozEdgeUICanceled")
|
||||
GK_ATOM(onMozEdgeUICompleted, "onMozEdgeUICompleted")
|
||||
|
||||
// orientation support
|
||||
GK_ATOM(ondevicemotion, "ondevicemotion")
|
||||
|
@ -826,8 +826,16 @@ NON_IDL_EVENT(MozPressTapGesture,
|
||||
NS_SIMPLE_GESTURE_PRESSTAP,
|
||||
EventNameType_None,
|
||||
NS_SIMPLE_GESTURE_EVENT)
|
||||
NON_IDL_EVENT(MozEdgeUIGesture,
|
||||
NS_SIMPLE_GESTURE_EDGEUI,
|
||||
NON_IDL_EVENT(MozEdgeUIStarted,
|
||||
NS_SIMPLE_GESTURE_EDGE_STARTED,
|
||||
EventNameType_None,
|
||||
NS_SIMPLE_GESTURE_EVENT)
|
||||
NON_IDL_EVENT(MozEdgeUICanceled,
|
||||
NS_SIMPLE_GESTURE_EDGE_CANCELED,
|
||||
EventNameType_None,
|
||||
NS_SIMPLE_GESTURE_EVENT)
|
||||
NON_IDL_EVENT(MozEdgeUICompleted,
|
||||
NS_SIMPLE_GESTURE_EDGE_COMPLETED,
|
||||
EventNameType_None,
|
||||
NS_SIMPLE_GESTURE_EVENT)
|
||||
|
||||
|
@ -1220,8 +1220,12 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
|
||||
msg = NS_SIMPLE_GESTURE_TAP;
|
||||
else if (aType.EqualsLiteral("MozPressTapGesture"))
|
||||
msg = NS_SIMPLE_GESTURE_PRESSTAP;
|
||||
else if (aType.EqualsLiteral("MozEdgeUIGesture"))
|
||||
msg = NS_SIMPLE_GESTURE_EDGEUI;
|
||||
else if (aType.EqualsLiteral("MozEdgeUIStarted"))
|
||||
msg = NS_SIMPLE_GESTURE_EDGE_STARTED;
|
||||
else if (aType.EqualsLiteral("MozEdgeUICanceled"))
|
||||
msg = NS_SIMPLE_GESTURE_EDGE_CANCELED;
|
||||
else if (aType.EqualsLiteral("MozEdgeUICompleted"))
|
||||
msg = NS_SIMPLE_GESTURE_EDGE_COMPLETED;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -349,7 +349,9 @@ enum nsEventStructType {
|
||||
#define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+9)
|
||||
#define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+10)
|
||||
#define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+11)
|
||||
#define NS_SIMPLE_GESTURE_EDGEUI (NS_SIMPLE_GESTURE_EVENT_START+12)
|
||||
#define NS_SIMPLE_GESTURE_EDGE_STARTED (NS_SIMPLE_GESTURE_EVENT_START+12)
|
||||
#define NS_SIMPLE_GESTURE_EDGE_CANCELED (NS_SIMPLE_GESTURE_EVENT_START+13)
|
||||
#define NS_SIMPLE_GESTURE_EDGE_COMPLETED (NS_SIMPLE_GESTURE_EVENT_START+14)
|
||||
|
||||
// These are used to send native events to plugins.
|
||||
#define NS_PLUGIN_EVENT_START 3600
|
||||
|
@ -291,7 +291,9 @@ MetroInput::MetroInput(MetroWidget* aWidget,
|
||||
mTokenPointerExited.value = 0;
|
||||
mTokenPointerWheelChanged.value = 0;
|
||||
mTokenAcceleratorKeyActivated.value = 0;
|
||||
mTokenEdgeGesture.value = 0;
|
||||
mTokenEdgeStarted.value = 0;
|
||||
mTokenEdgeCanceled.value = 0;
|
||||
mTokenEdgeCompleted.value = 0;
|
||||
mTokenManipulationStarted.value = 0;
|
||||
mTokenManipulationUpdated.value = 0;
|
||||
mTokenManipulationCompleted.value = 0;
|
||||
@ -365,11 +367,75 @@ MetroInput::OnAcceleratorKeyActivated(UI::Core::ICoreDispatcher* sender,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// "Edge Gesture" event. This indicates that the user has swiped in from the
|
||||
// top or bottom of the screen and means we should show our context UI. This
|
||||
// event can also be triggered through keyboard input.
|
||||
// According to MSDN, this event will only be received through touch
|
||||
// (user swipes in from edge) or from keyboard (user presses Win+Z)
|
||||
/**
|
||||
* When the user swipes her/his finger in from the top of the screen,
|
||||
* we receive this event.
|
||||
*
|
||||
* @param sender the CoreDispatcher that fired this event
|
||||
* @param aArgs the event-specific args we use when processing this event
|
||||
* @returns S_OK
|
||||
*/
|
||||
HRESULT
|
||||
MetroInput::OnEdgeGestureStarted(UI::Input::IEdgeGesture* sender,
|
||||
UI::Input::IEdgeGestureEventArgs* aArgs)
|
||||
{
|
||||
#ifdef DEBUG_INPUT
|
||||
LogFunction();
|
||||
#endif
|
||||
nsSimpleGestureEvent geckoEvent(true,
|
||||
NS_SIMPLE_GESTURE_EDGE_STARTED,
|
||||
mWidget.Get(),
|
||||
0,
|
||||
0.0);
|
||||
mModifierKeyState.Update();
|
||||
mModifierKeyState.InitInputEvent(geckoEvent);
|
||||
geckoEvent.time = ::GetMessageTime();
|
||||
|
||||
geckoEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
|
||||
|
||||
DispatchEventIgnoreStatus(&geckoEvent);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event can be received if the user swipes her/his finger back to
|
||||
* the top of the screen, or continues moving her/his finger such that
|
||||
* the movement is interpreted as a "grab this window" gesture
|
||||
*
|
||||
* @param sender the CoreDispatcher that fired this event
|
||||
* @param aArgs the event-specific args we use when processing this event
|
||||
* @returns S_OK
|
||||
*/
|
||||
HRESULT
|
||||
MetroInput::OnEdgeGestureCanceled(UI::Input::IEdgeGesture* sender,
|
||||
UI::Input::IEdgeGestureEventArgs* aArgs)
|
||||
{
|
||||
#ifdef DEBUG_INPUT
|
||||
LogFunction();
|
||||
#endif
|
||||
nsSimpleGestureEvent geckoEvent(true,
|
||||
NS_SIMPLE_GESTURE_EDGE_CANCELED,
|
||||
mWidget.Get(),
|
||||
0,
|
||||
0.0);
|
||||
mModifierKeyState.Update();
|
||||
mModifierKeyState.InitInputEvent(geckoEvent);
|
||||
geckoEvent.time = ::GetMessageTime();
|
||||
|
||||
geckoEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
|
||||
|
||||
DispatchEventIgnoreStatus(&geckoEvent);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is received if the user presses ctrl+Z or lifts her/his
|
||||
* finger after causing an EdgeGestureStarting event to fire.
|
||||
*
|
||||
* @param sender the CoreDispatcher that fired this event
|
||||
* @param aArgs the event-specific args we use when processing this event
|
||||
* @returns S_OK
|
||||
*/
|
||||
HRESULT
|
||||
MetroInput::OnEdgeGestureCompleted(UI::Input::IEdgeGesture* sender,
|
||||
UI::Input::IEdgeGestureEventArgs* aArgs)
|
||||
@ -378,7 +444,7 @@ MetroInput::OnEdgeGestureCompleted(UI::Input::IEdgeGesture* sender,
|
||||
LogFunction();
|
||||
#endif
|
||||
nsSimpleGestureEvent geckoEvent(true,
|
||||
NS_SIMPLE_GESTURE_EDGEUI,
|
||||
NS_SIMPLE_GESTURE_EDGE_COMPLETED,
|
||||
mWidget.Get(),
|
||||
0,
|
||||
0.0);
|
||||
@ -1367,7 +1433,9 @@ MetroInput::UnregisterInputEvents() {
|
||||
edgeStatics.GetAddressOf()))) {
|
||||
WRL::ComPtr<UI::Input::IEdgeGesture> edge;
|
||||
if (SUCCEEDED(edgeStatics->GetForCurrentView(edge.GetAddressOf()))) {
|
||||
edge->remove_Completed(mTokenEdgeGesture);
|
||||
edge->remove_Starting(mTokenEdgeStarted);
|
||||
edge->remove_Canceled(mTokenEdgeCanceled);
|
||||
edge->remove_Completed(mTokenEdgeCompleted);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1694,11 +1762,23 @@ MetroInput::RegisterInputEvents()
|
||||
WRL::ComPtr<UI::Input::IEdgeGesture> edge;
|
||||
edgeStatics->GetForCurrentView(edge.GetAddressOf());
|
||||
|
||||
edge->add_Starting(
|
||||
WRL::Callback<EdgeGestureHandler>(
|
||||
this,
|
||||
&MetroInput::OnEdgeGestureStarted).Get(),
|
||||
&mTokenEdgeStarted);
|
||||
|
||||
edge->add_Canceled(
|
||||
WRL::Callback<EdgeGestureHandler>(
|
||||
this,
|
||||
&MetroInput::OnEdgeGestureCanceled).Get(),
|
||||
&mTokenEdgeCanceled);
|
||||
|
||||
edge->add_Completed(
|
||||
WRL::Callback<EdgeGestureHandler>(
|
||||
this,
|
||||
&MetroInput::OnEdgeGestureCompleted).Get(),
|
||||
&mTokenEdgeGesture);
|
||||
&mTokenEdgeCompleted);
|
||||
|
||||
// Set up our Gesture Recognizer to raise events for the gestures we
|
||||
// care about
|
||||
|
@ -132,6 +132,10 @@ public:
|
||||
|
||||
// The Edge gesture event is special. It does not come from our window
|
||||
// or from our GestureRecognizer.
|
||||
HRESULT OnEdgeGestureStarted(IEdgeGesture* aSender,
|
||||
IEdgeGestureEventArgs* aArgs);
|
||||
HRESULT OnEdgeGestureCanceled(IEdgeGesture* aSender,
|
||||
IEdgeGestureEventArgs* aArgs);
|
||||
HRESULT OnEdgeGestureCompleted(IEdgeGesture* aSender,
|
||||
IEdgeGestureEventArgs* aArgs);
|
||||
|
||||
@ -263,9 +267,11 @@ private:
|
||||
// using this token.
|
||||
EventRegistrationToken mTokenAcceleratorKeyActivated;
|
||||
|
||||
// When we register ourselves to handle the edge gesture, we receive a
|
||||
// token. When we unregister ourselves, we must use the token we received.
|
||||
EventRegistrationToken mTokenEdgeGesture;
|
||||
// When we register ourselves to handle edge gestures, we receive a
|
||||
// token. To we unregister ourselves, we must use the token we received.
|
||||
EventRegistrationToken mTokenEdgeStarted;
|
||||
EventRegistrationToken mTokenEdgeCanceled;
|
||||
EventRegistrationToken mTokenEdgeCompleted;
|
||||
|
||||
// These registration tokens are set when we register ourselves to receive
|
||||
// events from our GestureRecognizer. It's probably not a huge deal if we
|
||||
|
Loading…
Reference in New Issue
Block a user