Bug 1489463 - [Linux/Gtk] Call OnSizeAllocate() explicitly also from OnConfigureEvent(), r=jhorak

Usually we update mBounds from OnSizeAllocate() which is called
by Gtk when mContainer changes its actual size.

However we need to set mBounds in advance at Resize() as JS
code expect immediate window size change. When Resize() is called between
SetSizeMode() calls (which maximize/unmaximize the window) we can miss
OnSizeAllocate() Gtk call as actual mContainer size may not change
from Gtk perspective and we end up with incorrect mBounds.

To compensate it call OnSizeAllocate() explicitly also
from OnConfigureEvent().

Differential Revision: https://phabricator.services.mozilla.com/D55941

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Martin Stransky 2019-12-16 09:52:27 +00:00
Родитель 5e9f6e4cc2
Коммит 2df2f216c3
2 изменённых файлов: 23 добавлений и 5 удалений

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

@ -101,6 +101,7 @@ STUB(gdk_window_get_parent)
STUB(gdk_window_get_position)
STUB(gdk_window_get_root_origin)
STUB(gdk_window_get_screen)
STUB(gtk_window_get_size)
STUB(gdk_window_get_state)
STUB(gdk_window_get_toplevel)
STUB(gdk_window_get_update_area)

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

@ -2537,9 +2537,6 @@ gboolean nsWindow::OnConfigureEvent(GtkWidget* aWidget,
}
}
// This event indicates that the window position may have changed.
// mBounds.Size() is updated in OnSizeAllocate().
NS_ASSERTION(GTK_IS_WINDOW(aWidget),
"Configure event on widget that is not a GtkWindow");
if (gtk_window_get_window_type(GTK_WINDOW(aWidget)) == GTK_WINDOW_POPUP) {
@ -2564,6 +2561,24 @@ gboolean nsWindow::OnConfigureEvent(GtkWidget* aWidget,
// complete. wtf?
NotifyWindowMoved(mBounds.x, mBounds.y);
// A GTK app would usually update its client area size in response to
// a "size-allocate" signal.
// However, we need to set mBounds in advance at Resize()
// as JS code expects immediate window size change.
// If Gecko requests a resize from GTK, but subsequently,
// before a corresponding "size-allocate" signal is emitted, the window is
// resized to its former size via other means, such as maximizing,
// then there is no "size-allocate" signal from which to update
// the value of mBounds. Similarly, if Gecko's resize request is refused
// by the window manager, then there will be no "size-allocate" signal.
// In the refused request case, the window manager is required to dispatch
// a ConfigureNotify event. mBounds can then be updated here.
// This seems to also be sufficient to update mBounds when Gecko resizes
// the window from maximized size and then immediately maximizes again.
GtkAllocation allocation = {-1, -1, 0, 0};
gtk_window_get_size(GTK_WINDOW(mShell), &allocation.width,
&allocation.height);
OnSizeAllocate(&allocation);
return FALSE;
}
@ -2586,8 +2601,10 @@ void nsWindow::OnSizeAllocate(GtkAllocation* aAllocation) {
aAllocation->height));
LayoutDeviceIntSize size = GdkRectToDevicePixels(*aAllocation).Size();
if (mBounds.Size() == size) return;
if (mBounds.Size() == size) {
// We were already resized at nsWindow::OnConfigureEvent() so skip it.
return;
}
// Invalidate the new part of the window now for the pending paint to
// minimize background flashes (GDK does not do this for external resizes