mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 978679. Convert GDK touch event coordinates properly. r=karlt
This commit is contained in:
parent
0d434edd71
commit
48f9cfaff3
@ -2533,6 +2533,20 @@ nsWindow::OnLeaveNotifyEvent(GdkEventCrossing *aEvent)
|
||||
DispatchInputEvent(&event);
|
||||
}
|
||||
|
||||
template <typename Event> static LayoutDeviceIntPoint
|
||||
GetRefPoint(nsWindow* aWindow, Event* aEvent)
|
||||
{
|
||||
if (aEvent->window == aWindow->GetGdkWindow()) {
|
||||
// we are the window that the event happened on so no need for expensive WidgetToScreenOffset
|
||||
return aWindow->GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
}
|
||||
// XXX we're never quite sure which GdkWindow the event came from due to our custom bubbling
|
||||
// in scroll_event_cb(), so use ScreenToWidget to translate the screen root coordinates into
|
||||
// coordinates relative to this widget.
|
||||
return aWindow->GdkEventCoordsToDevicePixels(
|
||||
aEvent->x_root, aEvent->y_root) - aWindow->WidgetToScreenOffset();
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
{
|
||||
@ -2593,16 +2607,8 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
#endif /* MOZ_X11 */
|
||||
}
|
||||
else {
|
||||
// XXX see OnScrollEvent()
|
||||
if (aEvent->window == mGdkWindow) {
|
||||
event.refPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
} else {
|
||||
LayoutDeviceIntPoint point = GdkEventCoordsToDevicePixels(
|
||||
aEvent->x_root, aEvent->y_root);
|
||||
event.refPoint = point - WidgetToScreenOffset();
|
||||
}
|
||||
} else {
|
||||
event.refPoint = GetRefPoint(this, aEvent);
|
||||
|
||||
modifierState = aEvent->state;
|
||||
|
||||
@ -2671,14 +2677,7 @@ void
|
||||
nsWindow::InitButtonEvent(WidgetMouseEvent& aEvent,
|
||||
GdkEventButton* aGdkEvent)
|
||||
{
|
||||
// XXX see OnScrollEvent()
|
||||
if (aGdkEvent->window == mGdkWindow) {
|
||||
aEvent.refPoint = GdkEventCoordsToDevicePixels(aGdkEvent->x, aGdkEvent->y);
|
||||
} else {
|
||||
LayoutDeviceIntPoint point = GdkEventCoordsToDevicePixels(
|
||||
aGdkEvent->x_root, aGdkEvent->y_root);
|
||||
aEvent.refPoint = point - WidgetToScreenOffset();
|
||||
}
|
||||
aEvent.refPoint = GetRefPoint(this, aGdkEvent);
|
||||
|
||||
guint modifierState = aGdkEvent->state;
|
||||
// aEvent's state doesn't include this event's information. Therefore,
|
||||
@ -3193,17 +3192,7 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent)
|
||||
break;
|
||||
}
|
||||
|
||||
if (aEvent->window == mGdkWindow) {
|
||||
// we are the window that the event happened on so no need for expensive WidgetToScreenOffset
|
||||
wheelEvent.refPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
} else {
|
||||
// XXX we're never quite sure which GdkWindow the event came from due to our custom bubbling
|
||||
// in scroll_event_cb(), so use ScreenToWidget to translate the screen root coordinates into
|
||||
// coordinates relative to this widget.
|
||||
LayoutDeviceIntPoint point = GdkEventCoordsToDevicePixels(
|
||||
aEvent->x_root, aEvent->y_root);
|
||||
wheelEvent.refPoint = point - WidgetToScreenOffset();
|
||||
}
|
||||
wheelEvent.refPoint = GetRefPoint(this, aEvent);
|
||||
|
||||
KeymapWrapper::InitInputEvent(wheelEvent, aEvent->state);
|
||||
|
||||
@ -3411,13 +3400,7 @@ nsWindow::OnTouchEvent(GdkEventTouch* aEvent)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint touchPoint;
|
||||
if (aEvent->window == mGdkWindow) {
|
||||
touchPoint = LayoutDeviceIntPoint(aEvent->x, aEvent->y);
|
||||
} else {
|
||||
touchPoint = LayoutDeviceIntPoint(aEvent->x_root, aEvent->y_root) -
|
||||
WidgetToScreenOffset();
|
||||
}
|
||||
LayoutDeviceIntPoint touchPoint = GetRefPoint(this, aEvent);
|
||||
|
||||
int32_t id;
|
||||
RefPtr<dom::Touch> touch;
|
||||
|
@ -335,6 +335,21 @@ public:
|
||||
uint32_t aAdditionalFlags,
|
||||
nsIObserver* aObserver) override;
|
||||
|
||||
// HiDPI scale conversion
|
||||
gint GdkScaleFactor();
|
||||
|
||||
// To GDK
|
||||
gint DevicePixelsToGdkCoordRoundUp(int pixels);
|
||||
gint DevicePixelsToGdkCoordRoundDown(int pixels);
|
||||
GdkPoint DevicePixelsToGdkPointRoundDown(nsIntPoint point);
|
||||
GdkRectangle DevicePixelsToGdkSizeRoundUp(nsIntSize pixelSize);
|
||||
|
||||
// From GDK
|
||||
int GdkCoordToDevicePixels(gint coord);
|
||||
mozilla::LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
|
||||
mozilla::LayoutDeviceIntPoint GdkEventCoordsToDevicePixels(gdouble x, gdouble y);
|
||||
nsIntRect GdkRectToDevicePixels(GdkRectangle rect);
|
||||
|
||||
protected:
|
||||
virtual ~nsWindow();
|
||||
|
||||
@ -528,21 +543,6 @@ private:
|
||||
RefPtr<mozilla::widget::IMContextWrapper> mIMContext;
|
||||
|
||||
nsAutoPtr<mozilla::CurrentX11TimeGetter> mCurrentTimeGetter;
|
||||
|
||||
// HiDPI scale conversion
|
||||
gint GdkScaleFactor();
|
||||
|
||||
// To GDK
|
||||
gint DevicePixelsToGdkCoordRoundUp(int pixels);
|
||||
gint DevicePixelsToGdkCoordRoundDown(int pixels);
|
||||
GdkPoint DevicePixelsToGdkPointRoundDown(nsIntPoint point);
|
||||
GdkRectangle DevicePixelsToGdkSizeRoundUp(nsIntSize pixelSize);
|
||||
|
||||
// From GDK
|
||||
int GdkCoordToDevicePixels(gint coord);
|
||||
mozilla::LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
|
||||
mozilla::LayoutDeviceIntPoint GdkEventCoordsToDevicePixels(gdouble x, gdouble y);
|
||||
nsIntRect GdkRectToDevicePixels(GdkRectangle rect);
|
||||
};
|
||||
|
||||
class nsChildWindow : public nsWindow {
|
||||
|
Loading…
Reference in New Issue
Block a user