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