Bug 1864382 [Linux] Use gdk_window_get_root_origin() to get origin for popup windows too and apply workaround for Gtk3 < 3.24.35 r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D193497
This commit is contained in:
stransky 2023-11-25 10:41:46 +00:00
Родитель 4dadfcf0ce
Коммит da7fb65f85
1 изменённых файлов: 13 добавлений и 13 удалений

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

@ -3187,20 +3187,20 @@ void nsWindow::SetFocus(Raise aRaise, mozilla::dom::CallerType aCallerType) {
LayoutDeviceIntRect nsWindow::GetScreenBounds() {
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 != WindowType::Popup) {
gint x, y;
gdk_window_get_root_origin(gtk_widget_get_window(GTK_WIDGET(mContainer)),
&x, &y);
return GdkPointToDevicePixels({x, y});
if (mIsDestroyed || !mGdkWindow) {
return LayoutDeviceIntPoint(0, 0);
}
return WidgetToScreenOffset();
gint x, y;
gdk_window_get_root_origin(mGdkWindow, &x, &y);
// Workaround for https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4820
// Bug 1775017 Gtk < 3.24.35 returns scaled values for
// override redirected window on X11.
if (gtk_check_version(3, 24, 35) != nullptr && GdkIsX11Display() &&
gdk_window_get_window_type(mGdkWindow) == GDK_WINDOW_TEMP) {
return LayoutDeviceIntPoint(x, y);
}
return GdkPointToDevicePixels({x, y});
}();
// mBounds.Size() is the window bounds, not the window-manager frame