Backed out changeset 5dfed78115dc (bug 1836886) for causing bc failures @ browser_disableSwipeGestures.js CLOSED TREE

This commit is contained in:
Sandor Molnar 2024-09-30 11:40:08 +03:00
parent dd7013748f
commit c50ec22447
4 changed files with 22 additions and 225 deletions

View File

@ -139,6 +139,10 @@ static inline void wl_surface_damage_buffer(struct wl_surface* wl_surface,
}
#endif
#ifndef WL_POINTER_RELEASE_SINCE_VERSION
# define WL_POINTER_RELEASE_SINCE_VERSION 3
#endif
#ifndef WL_POINTER_AXIS_ENUM
# define WL_POINTER_AXIS_ENUM
/**
@ -228,54 +232,6 @@ enum wl_pointer_axis_relative_direction {
};
#endif /* WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM */
#ifndef WL_POINTER_AXIS_SOURCE_ENUM
# define WL_POINTER_AXIS_SOURCE_ENUM
/**
* @ingroup iface_wl_pointer
* axis source types
*
* Describes the source types for axis events. This indicates to the
* client how an axis event was physically generated; a client may
* adjust the user interface accordingly. For example, scroll events
* from a "finger" source may be in a smooth coordinate space with
* kinetic scrolling whereas a "wheel" source may be in discrete steps
* of a number of lines.
*
* The "continuous" axis source is a device generating events in a
* continuous coordinate space, but using something other than a
* finger. One example for this source is button-based scrolling where
* the vertical motion of a device is converted to scroll events while
* a button is held down.
*
* The "wheel tilt" axis source indicates that the actual device is a
* wheel but the scroll event is not caused by a rotation but a
* (usually sideways) tilt of the wheel.
*/
enum wl_pointer_axis_source {
/**
* a physical wheel rotation
*/
WL_POINTER_AXIS_SOURCE_WHEEL = 0,
/**
* finger on a touch surface
*/
WL_POINTER_AXIS_SOURCE_FINGER = 1,
/**
* continuous coordinate space
*/
WL_POINTER_AXIS_SOURCE_CONTINUOUS = 2,
/**
* a physical wheel tilt
* @since 6
*/
WL_POINTER_AXIS_SOURCE_WHEEL_TILT = 3,
};
/**
* @ingroup iface_wl_pointer
*/
# define WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION 6
#endif /* WL_POINTER_AXIS_SOURCE_ENUM */
/**
* @ingroup iface_wl_pointer
* @struct wl_pointer_listener
@ -584,14 +540,6 @@ struct moz_wl_pointer_listener {
uint32_t axis, uint32_t direction);
};
#ifndef WL_POINTER_RELEASE_SINCE_VERSION
# define WL_POINTER_RELEASE_SINCE_VERSION 3
#endif
#ifndef WL_POINTER_AXIS_VALUE120_SINCE_VERSION
# define WL_POINTER_AXIS_VALUE120_SINCE_VERSION 8
#endif
#ifdef __cplusplus
}
#endif

View File

@ -58,8 +58,9 @@ nsWaylandDisplay* WaylandDisplayGet() {
void nsWaylandDisplay::SetShm(wl_shm* aShm) { mShm = aShm; }
class WaylandPointerEvent {
class TouchWindow {
public:
already_AddRefed<nsWindow> GetAndClearWindow() { return mWindow.forget(); }
RefPtr<nsWindow> TakeWindow(wl_surface* aSurface) {
if (!aSurface) {
mWindow = nullptr;
@ -72,70 +73,18 @@ class WaylandPointerEvent {
}
return mWindow;
}
already_AddRefed<nsWindow> GetAndClearWindow() { return mWindow.forget(); }
RefPtr<nsWindow> GetWindow() { return mWindow; }
void SetSource(int32_t aSource) { mSource = aSource; }
void SetDelta120(uint32_t aAxis, int32_t aDelta) {
switch (aAxis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
mDeltaY = aDelta / 120.0f;
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
mDeltaX = aDelta / 120.0f;
break;
default:
NS_WARNING("WaylandPointerEvent::SetDelta120(): wrong axis!");
break;
}
}
void SetTime(uint32_t aTime) { mTime = aTime; }
void SendScrollEvent() {
if (!mWindow) {
return;
}
// nsWindow::OnSmoothScrollEvent() may spin event loop so
// mWindow/mSource/delta may be replaced.
int32_t source = mSource;
float deltaX = mDeltaX;
float deltaY = mDeltaY;
mSource = -1;
mDeltaX = mDeltaY = 0.0f;
// We process wheel events only now.
if (source != WL_POINTER_AXIS_SOURCE_WHEEL) {
return;
}
RefPtr<nsWindow> win = mWindow;
uint32_t eventTime = mTime;
win->OnSmoothScrollEvent(eventTime, deltaX, deltaY);
}
void Clear() { mWindow = nullptr; }
WaylandPointerEvent() { Clear(); }
private:
StaticRefPtr<nsWindow> mWindow;
uint32_t mTime = 0;
int32_t mSource = 0;
float mDeltaX = 0;
float mDeltaY = 0;
};
static WaylandPointerEvent sHoldGesture;
static TouchWindow sTouchWindow;
static void gesture_hold_begin(void* data,
struct zwp_pointer_gesture_hold_v1* hold,
uint32_t serial, uint32_t time,
struct wl_surface* surface, uint32_t fingers) {
RefPtr<nsWindow> window = sHoldGesture.TakeWindow(surface);
RefPtr<nsWindow> window = sTouchWindow.TakeWindow(surface);
if (!window) {
return;
}
@ -146,7 +95,7 @@ static void gesture_hold_end(void* data,
struct zwp_pointer_gesture_hold_v1* hold,
uint32_t serial, uint32_t time,
int32_t cancelled) {
RefPtr<nsWindow> window = sHoldGesture.GetAndClearWindow();
RefPtr<nsWindow> window = sTouchWindow.GetAndClearWindow();
if (!window) {
return;
}
@ -158,18 +107,12 @@ static void gesture_hold_end(void* data,
static const struct zwp_pointer_gesture_hold_v1_listener gesture_hold_listener =
{gesture_hold_begin, gesture_hold_end};
static WaylandPointerEvent sScrollEvent;
static void pointer_handle_enter(void* data, struct wl_pointer* pointer,
uint32_t serial, struct wl_surface* surface,
wl_fixed_t sx, wl_fixed_t sy) {
sScrollEvent.TakeWindow(surface);
}
wl_fixed_t sx, wl_fixed_t sy) {}
static void pointer_handle_leave(void* data, struct wl_pointer* pointer,
uint32_t serial, struct wl_surface* surface) {
sScrollEvent.Clear();
}
uint32_t serial, struct wl_surface* surface) {}
static void pointer_handle_motion(void* data, struct wl_pointer* pointer,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy) {
@ -181,19 +124,13 @@ static void pointer_handle_button(void* data, struct wl_pointer* pointer,
static void pointer_handle_axis(void* data, struct wl_pointer* pointer,
uint32_t time, uint32_t axis,
wl_fixed_t value) {
sScrollEvent.SetTime(time);
}
wl_fixed_t value) {}
static void pointer_handle_frame(void* data, struct wl_pointer* pointer) {
sScrollEvent.SendScrollEvent();
}
static void pointer_handle_frame(void* data, struct wl_pointer* pointer) {}
static void pointer_handle_axis_source(
void* data, struct wl_pointer* pointer,
/*enum wl_pointer_axis_source */ uint32_t source) {
sScrollEvent.SetSource(source);
}
/*enum wl_pointer_axis_source */ uint32_t source) {}
static void pointer_handle_axis_stop(void* data, struct wl_pointer* pointer,
uint32_t time, uint32_t axis) {}
@ -202,35 +139,7 @@ static void pointer_handle_axis_discrete(void* data, struct wl_pointer* pointer,
uint32_t axis, int32_t value) {}
static void pointer_handle_axis_value120(void* data, struct wl_pointer* pointer,
uint32_t axis, int32_t value) {
sScrollEvent.SetDelta120(axis, value);
}
/*
* Example of scroll events we get for various devices. Note that
* even three different devices has the same wl_pointer.
*
* Standard mouse wheel:
*
* pointer_handle_axis_source pointer 0x7fd14fd4bac0 source 0
* pointer_handle_axis_value120 pointer 0x7fd14fd4bac0 value 120
* pointer_handle_axis pointer 0x7fd14fd4bac0 time 9470441 value 10.000000
* pointer_handle_frame
*
* Hi-res mouse wheel:
*
* pointer_handle_axis_source pointer 0x7fd14fd4bac0 source 0
* pointer_handle_axis_value120 pointer 0x7fd14fd4bac0 value -24
* pointer_handle_axis pointer 0x7fd14fd4bac0 time 9593205 value -1.992188
* pointer_handle_frame
*
* Touchpad:
*
* pointer_handle_axis_source pointer 0x7fd14fd4bac0 source 1
* pointer_handle_axis pointer 0x7fd14fd4bac0 time 9431830 value 0.312500
* pointer_handle_axis pointer 0x7fd14fd4bac0 time 9431830 value -1.015625
* pointer_handle_frame
*/
uint32_t axis, int32_t value) {}
static const struct moz_wl_pointer_listener pointer_listener = {
pointer_handle_enter, pointer_handle_leave,
@ -456,9 +365,8 @@ static void global_registry_handler(void* data, wl_registry* registry,
display->SetXdgDbusAnnotationManager(annotationManager);
} else if (iface.EqualsLiteral("wl_seat") &&
version >= WL_POINTER_RELEASE_SINCE_VERSION) {
auto* seat = WaylandRegistryBind<wl_seat>(
registry, id, &wl_seat_interface,
MIN(version, WL_POINTER_AXIS_VALUE120_SINCE_VERSION));
auto* seat = WaylandRegistryBind<wl_seat>(registry, id, &wl_seat_interface,
WL_POINTER_RELEASE_SINCE_VERSION);
display->SetSeat(seat, id);
} else if (iface.EqualsLiteral("wp_fractional_scale_manager_v1")) {
auto* manager = WaylandRegistryBind<wp_fractional_scale_manager_v1>(

View File

@ -4130,7 +4130,6 @@ void nsWindow::OnEnterNotifyEvent(GdkEventCrossing* aEvent) {
// Check before checking for ungrab as the button state may have
// changed while a non-Gecko ancestor window had a pointer grab.
DispatchMissedButtonReleases(aEvent);
mLastMouseCoordinates.Set(aEvent);
WidgetMouseEvent event(true, eMouseEnterIntoWidget, this,
WidgetMouseEvent::eReal);
@ -4352,8 +4351,6 @@ void nsWindow::EmulateResizeDrag(GdkEventMotion* aEvent) {
}
void nsWindow::OnMotionNotifyEvent(GdkEventMotion* aEvent) {
mLastMouseCoordinates.Set(aEvent);
if (!mGdkWindow) {
return;
}
@ -4606,7 +4603,6 @@ void nsWindow::OnButtonPressEvent(GdkEventButton* aEvent) {
LOG("Button %u press\n", aEvent->button);
SetLastMousePressEvent((GdkEvent*)aEvent);
mLastMouseCoordinates.Set(aEvent);
// If you double click in GDK, it will actually generate a second
// GDK_BUTTON_PRESS before sending the GDK_2BUTTON_PRESS, and this is
@ -4744,7 +4740,6 @@ void nsWindow::OnButtonReleaseEvent(GdkEventButton* aEvent) {
LOG("Button %u release\n", aEvent->button);
SetLastMousePressEvent(nullptr);
mLastMouseCoordinates.Set(aEvent);
if (!mGdkWindow) {
return;
@ -4980,14 +4975,7 @@ gboolean nsWindow::OnKeyReleaseEvent(GdkEventKey* aEvent) {
}
void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
LOG("OnScrollEvent time %d", aEvent->time);
mLastMouseCoordinates.Set(aEvent);
// This event was already handled by OnSmoothScrollEvent().
if (mLastSmoothScrollEventTime == aEvent->time) {
return;
}
LOG("OnScrollEvent");
// check to see if we should rollup
if (CheckForRollup(aEvent->x_root, aEvent->y_root, true, false)) {
@ -5138,35 +5126,6 @@ void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
DispatchInputEvent(&wheelEvent);
}
void nsWindow::OnSmoothScrollEvent(uint32_t aTime, float aDeltaX,
float aDeltaY) {
LOG("OnSmoothScrollEvent time %d dX %f dY %f", aTime, aDeltaX, aDeltaY);
// This event was already handled by OnSmoothScrollEvent().
mLastSmoothScrollEventTime = aTime;
if (CheckForRollup(mLastMouseCoordinates.mRootX, mLastMouseCoordinates.mRootY,
true, false)) {
return;
}
WidgetWheelEvent wheelEvent(true, eWheel, this);
wheelEvent.mDeltaMode = dom::WheelEvent_Binding::DOM_DELTA_LINE;
// Use the same constant as nsWindow::OnScrollEvent().
wheelEvent.mDeltaX = aDeltaX * 3;
wheelEvent.mDeltaY = aDeltaY * 3;
wheelEvent.mWheelTicksX = aDeltaX;
wheelEvent.mWheelTicksY = aDeltaY;
wheelEvent.mIsNoLineOrPageDelta = true;
wheelEvent.mRefPoint = GdkEventCoordsToDevicePixels(mLastMouseCoordinates.mX,
mLastMouseCoordinates.mY);
KeymapWrapper::InitInputEvent(wheelEvent,
KeymapWrapper::GetCurrentModifierState());
wheelEvent.AssignEventTime(GetWidgetEventTime(aTime));
DispatchInputEvent(&wheelEvent);
}
void nsWindow::DispatchPanGesture(PanGestureInput& aPanInput) {
MOZ_ASSERT(NS_IsMainThread());

View File

@ -257,7 +257,6 @@ class nsWindow final : public nsBaseWidget {
gboolean OnKeyReleaseEvent(GdkEventKey* aEvent);
void OnScrollEvent(GdkEventScroll* aEvent);
void OnSmoothScrollEvent(uint32_t aTime, float aDeltaX, float aDeltaY);
void OnVisibilityNotifyEvent(GdkVisibilityState aState);
void OnWindowStateEvent(GtkWidget* aWidget, GdkEventWindowState* aEvent);
@ -902,31 +901,14 @@ class nsWindow final : public nsBaseWidget {
RefPtr<nsWindow> mWaylandPopupNext;
RefPtr<nsWindow> mWaylandPopupPrev;
// When popup is resized by Gtk by move-to-rect callback,
// we store final popup size here. Then we use mMoveToRectPopupSize size
// in following popup operations unless mLayoutPopupSizeCleared is set.
LayoutDeviceIntSize mMoveToRectPopupSize;
#ifdef MOZ_ENABLE_DBUS
RefPtr<mozilla::widget::DBusMenuBar> mDBusMenuBar;
#endif
struct LastMouseCoordinates {
template <typename Event>
void Set(Event* aEvent) {
mX = aEvent->x;
mY = aEvent->y;
mRootX = aEvent->x_root;
mRootY = aEvent->y_root;
}
float mX = 0.0f, mY = 0.0f;
float mRootX = 0.0f, mRootY = 0.0f;
} mLastMouseCoordinates;
// We don't want to fire scroll event with the same timestamp as
// smooth scroll event.
guint32 mLastSmoothScrollEventTime = GDK_CURRENT_TIME;
// When popup is resized by Gtk by move-to-rect callback,
// we store final popup size here. Then we use mMoveToRectPopupSize size
// in following popup operations unless mLayoutPopupSizeCleared is set.
LayoutDeviceIntSize mMoveToRectPopupSize;
/**
* |mIMContext| takes all IME related stuff.