Bug 1756241 - Fix drag coordinates on X11 after D139243. r=stransky

This gives proper window-relative, CSS-scaled window coordinates on X11.

Before D139243 the coordinates were only correct in non-HiDPI
environments.

Differential Revision: https://phabricator.services.mozilla.com/D139245
This commit is contained in:
Emilio Cobos Álvarez 2022-02-22 19:06:59 +00:00
parent 92ca1990a3
commit 6491cf7f27

View File

@ -1337,10 +1337,12 @@ void nsDragService::SourceEndDragSession(GdkDragContext* aContext,
gint x, y;
GdkDisplay* display = gdk_display_get_default();
GdkScreen* screen = gdk_display_get_default_screen(display);
GdkWindow* window = gdk_screen_get_root_window(screen);
gdk_window_get_device_position(window, widget::GdkGetPointer(), &x, &y,
GtkWindow* window = GetGtkWindow(mSourceDocument);
GdkWindow* gdkWindow = window ? gtk_widget_get_window(GTK_WIDGET(window))
: gdk_screen_get_root_window(screen);
gdk_window_get_device_position(gdkWindow, widget::GdkGetPointer(), &x, &y,
nullptr);
gint scale = mozilla::widget::ScreenHelperGTK::GetGTKMonitorScaleFactor();
gint scale = gdk_window_get_scale_factor(gdkWindow);
SetDragEndPoint(LayoutDeviceIntPoint(x * scale, y * scale));
LOGDRAGSERVICE(("guess drag end point %d %d\n", x * scale, y * scale));
}
@ -2107,7 +2109,7 @@ gboolean nsDragService::ScheduleDropEvent(nsWindow* aWindow,
return FALSE;
}
SetDragEndPoint(aWindowPoint + aWindow->WidgetToScreenOffset());
SetDragEndPoint(aWindowPoint);
// We'll reply with gtk_drag_finish().
return TRUE;