Bug 1775017 - Don't use gdk_window_get_root_origin on popups, as those get the wrong coordinates on X11+HiDPI. r=stransky

See the linked GTK MR (which also affects GTK3). This can be reproduced
when running tests like
browser/components/extensions/test/browser/browser_ext_popup_select_in_oopif.js

In an X11 session with a HiDPI screen.

Differential Revision: https://phabricator.services.mozilla.com/D149721
This commit is contained in:
Emilio Cobos Álvarez 2022-06-20 11:20:06 +00:00
Родитель ba3d6a6ff9
Коммит 64b85c546a
1 изменённых файлов: 18 добавлений и 11 удалений

Просмотреть файл

@ -2996,21 +2996,28 @@ void nsWindow::SetFocus(Raise aRaise, mozilla::dom::CallerType aCallerType) {
} }
LayoutDeviceIntRect nsWindow::GetScreenBounds() { LayoutDeviceIntRect nsWindow::GetScreenBounds() {
LayoutDeviceIntRect rect; const LayoutDeviceIntPoint origin = [&] {
if (mContainer) { // XXX Can't we use mGdkWindow here?
// use the point including window decorations //
gint x, y; // Use the point including window decorations. Don't do this for popups,
gdk_window_get_root_origin(gtk_widget_get_window(GTK_WIDGET(mContainer)), // because we get wrong coordinates for gtk for override-redirect windows in
&x, &y); // HiDPI screens, and those don't have window decorations anyways.
rect.MoveTo(GdkPointToDevicePixels({x, y})); //
} else { // See https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4820
rect.MoveTo(WidgetToScreenOffset()); if (mContainer && mWindowType != eWindowType_popup) {
} gint x, y;
gdk_window_get_root_origin(gtk_widget_get_window(GTK_WIDGET(mContainer)),
&x, &y);
return GdkPointToDevicePixels({x, y});
}
return WidgetToScreenOffset();
}();
// mBounds.Size() is the window bounds, not the window-manager frame // mBounds.Size() is the window bounds, not the window-manager frame
// bounds (bug 581863). gdk_window_get_frame_extents would give the // bounds (bug 581863). gdk_window_get_frame_extents would give the
// frame bounds, but mBounds.Size() is returned here for consistency // frame bounds, but mBounds.Size() is returned here for consistency
// with Resize. // with Resize.
rect.SizeTo(mBounds.Size()); const LayoutDeviceIntRect rect(origin, mBounds.Size());
#if MOZ_LOGGING #if MOZ_LOGGING
gint scale = GdkCeiledScaleFactor(); gint scale = GdkCeiledScaleFactor();
LOG("GetScreenBounds %d,%d -> %d x %d, unscaled %d,%d -> %d x %d\n", rect.x, LOG("GetScreenBounds %d,%d -> %d x %d, unscaled %d,%d -> %d x %d\n", rect.x,