mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1209774 - Transform from GDK coords to layout device pixels before calling DispatchEvent. r=karlt
This commit is contained in:
parent
6ce16febf1
commit
f075b1baf6
@ -531,10 +531,6 @@ nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
|
||||
debug_DumpEvent(stdout, aEvent->widget, aEvent,
|
||||
nsAutoCString("something"), 0);
|
||||
#endif
|
||||
// Translate the mouse event into device pixels.
|
||||
aEvent->refPoint.x = GdkCoordToDevicePixels(aEvent->refPoint.x);
|
||||
aEvent->refPoint.y = GdkCoordToDevicePixels(aEvent->refPoint.y);
|
||||
|
||||
aStatus = nsEventStatus_eIgnore;
|
||||
nsIWidgetListener* listener =
|
||||
mAttachedWidgetListener ? mAttachedWidgetListener : mWidgetListener;
|
||||
@ -2462,9 +2458,7 @@ nsWindow::OnEnterNotifyEvent(GdkEventCrossing *aEvent)
|
||||
WidgetMouseEvent event(true, eMouseEnterIntoWidget, this,
|
||||
WidgetMouseEvent::eReal);
|
||||
|
||||
event.refPoint.x = nscoord(aEvent->x);
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
|
||||
event.refPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
|
||||
@ -2505,9 +2499,7 @@ nsWindow::OnLeaveNotifyEvent(GdkEventCrossing *aEvent)
|
||||
WidgetMouseEvent event(true, eMouseExitFromWidget, this,
|
||||
WidgetMouseEvent::eReal);
|
||||
|
||||
event.refPoint.x = nscoord(aEvent->x);
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
|
||||
event.refPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
|
||||
@ -2572,8 +2564,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
event.time = xevent.xmotion.time;
|
||||
event.timeStamp = GetEventTimeStamp(xevent.xmotion.time);
|
||||
#else
|
||||
event.refPoint.x = nscoord(aEvent->x);
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
event.refPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
|
||||
modifierState = aEvent->state;
|
||||
|
||||
@ -2584,11 +2575,10 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
else {
|
||||
// XXX see OnScrollEvent()
|
||||
if (aEvent->window == mGdkWindow) {
|
||||
event.refPoint.x = nscoord(aEvent->x);
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
event.refPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y);
|
||||
} else {
|
||||
LayoutDeviceIntPoint point(NSToIntFloor(aEvent->x_root),
|
||||
NSToIntFloor(aEvent->y_root));
|
||||
LayoutDeviceIntPoint point = GdkEventCoordsToDevicePixels(
|
||||
aEvent->x_root, aEvent->y_root);
|
||||
event.refPoint = point - WidgetToScreenOffset();
|
||||
}
|
||||
|
||||
@ -2661,11 +2651,10 @@ nsWindow::InitButtonEvent(WidgetMouseEvent& aEvent,
|
||||
{
|
||||
// XXX see OnScrollEvent()
|
||||
if (aGdkEvent->window == mGdkWindow) {
|
||||
aEvent.refPoint.x = nscoord(aGdkEvent->x);
|
||||
aEvent.refPoint.y = nscoord(aGdkEvent->y);
|
||||
aEvent.refPoint = GdkEventCoordsToDevicePixels(aGdkEvent->x, aGdkEvent->y);
|
||||
} else {
|
||||
LayoutDeviceIntPoint point(NSToIntFloor(aGdkEvent->x_root),
|
||||
NSToIntFloor(aGdkEvent->y_root));
|
||||
LayoutDeviceIntPoint point = GdkEventCoordsToDevicePixels(
|
||||
aGdkEvent->x_root, aGdkEvent->y_root);
|
||||
aEvent.refPoint = point - WidgetToScreenOffset();
|
||||
}
|
||||
|
||||
@ -3184,14 +3173,13 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent)
|
||||
|
||||
if (aEvent->window == mGdkWindow) {
|
||||
// we are the window that the event happened on so no need for expensive WidgetToScreenOffset
|
||||
wheelEvent.refPoint.x = nscoord(aEvent->x);
|
||||
wheelEvent.refPoint.y = nscoord(aEvent->y);
|
||||
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(NSToIntFloor(aEvent->x_root),
|
||||
NSToIntFloor(aEvent->y_root));
|
||||
LayoutDeviceIntPoint point = GdkEventCoordsToDevicePixels(
|
||||
aEvent->x_root, aEvent->y_root);
|
||||
wheelEvent.refPoint = point - WidgetToScreenOffset();
|
||||
}
|
||||
|
||||
@ -6603,6 +6591,13 @@ nsWindow::GdkCoordToDevicePixels(gint coord) {
|
||||
return coord * GdkScaleFactor();
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint
|
||||
nsWindow::GdkEventCoordsToDevicePixels(gdouble x, gdouble y)
|
||||
{
|
||||
gint scale = GdkScaleFactor();
|
||||
return LayoutDeviceIntPoint(floor(x * scale + 0.5), floor(y * scale + 0.5));
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint
|
||||
nsWindow::GdkPointToDevicePixels(GdkPoint point) {
|
||||
gint scale = GdkScaleFactor();
|
||||
|
@ -527,6 +527,7 @@ private:
|
||||
// From GDK
|
||||
int GdkCoordToDevicePixels(gint coord);
|
||||
mozilla::LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
|
||||
mozilla::LayoutDeviceIntPoint GdkEventCoordsToDevicePixels(gdouble x, gdouble y);
|
||||
nsIntRect GdkRectToDevicePixels(GdkRectangle rect);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user