Bug 1552128 [Linux] Update client offset in on-size-allocate event, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Wed, 27 May 2020 08:42:17 +0000
changeset 532341 988b01864d5a42a12fcf62bffbb06fcf3f1d8f6f
parent 532340 47d145c1130d318087d1a4d8438cbc1bc51d6b71
child 532342 db9a979064b76dc219f1f8cfb48fb5085b3cbcd9
push id37454
push userccoroiu@mozilla.com
push dateWed, 27 May 2020 16:14:31 +0000
treeherdermozilla-central@a1dd9afbfdf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1552128
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1552128 [Linux] Update client offset in on-size-allocate event, r=jhorak Differential Revision: https://phabricator.services.mozilla.com/D76999
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2080,16 +2080,20 @@ LayoutDeviceIntRect nsWindow::GetClientB
   LayoutDeviceIntRect rect = GetBounds();
   rect.MoveBy(GetClientOffset());
   return rect;
 }
 
 void nsWindow::UpdateClientOffsetFromFrameExtents() {
   AUTO_PROFILER_LABEL("nsWindow::UpdateClientOffsetFromFrameExtents", OTHER);
 
+  if (mCSDSupportLevel == CSD_SUPPORT_CLIENT) {
+    return;
+  }
+
   if (!mIsTopLevel || !mShell ||
       gtk_window_get_window_type(GTK_WINDOW(mShell)) == GTK_WINDOW_POPUP) {
     mClientOffset = nsIntPoint(0, 0);
     return;
   }
 
   GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
 
@@ -2960,26 +2964,16 @@ gboolean nsWindow::OnConfigureEvent(GtkW
   // the window from maximized size and then immediately maximizes again.
   if (!mBoundsAreValid) {
     GtkAllocation allocation = {-1, -1, 0, 0};
     gtk_window_get_size(GTK_WINDOW(mShell), &allocation.width,
                         &allocation.height);
     OnSizeAllocate(&allocation);
   }
 
-  // Client offset are updated by _NET_FRAME_EXTENTS on X11 when system titlebar
-  // is enabled. In ither cases (Wayland or system titlebar is off on X11)
-  // we don't get _NET_FRAME_EXTENTS X11 property notification so we derive
-  // it from mContainer position.
-  if (mCSDSupportLevel == CSD_SUPPORT_CLIENT) {
-    if (!mIsX11Display || (mIsX11Display && mDrawInTitlebar)) {
-      UpdateClientOffsetFromCSDWindow();
-    }
-  }
-
   return FALSE;
 }
 
 void nsWindow::OnContainerUnrealize() {
   // The GdkWindows are about to be destroyed (but not deleted), so remove
   // their references back to their container widget while the GdkWindow
   // hierarchy is still available.
 
@@ -2991,16 +2985,26 @@ void nsWindow::OnContainerUnrealize() {
   }
 }
 
 void nsWindow::OnSizeAllocate(GtkAllocation* aAllocation) {
   LOG(("nsWindow::OnSizeAllocate [%p] %d,%d -> %d x %d\n", (void*)this,
        aAllocation->x, aAllocation->y, aAllocation->width,
        aAllocation->height));
 
+  // Client offset are updated by _NET_FRAME_EXTENTS on X11 when system titlebar
+  // is enabled. In either cases (Wayland or system titlebar is off on X11)
+  // we don't get _NET_FRAME_EXTENTS X11 property notification so we derive
+  // it from mContainer position.
+  if (mCSDSupportLevel == CSD_SUPPORT_CLIENT) {
+    if (!mIsX11Display || (mIsX11Display && mDrawInTitlebar)) {
+      UpdateClientOffsetFromCSDWindow();
+    }
+  }
+
   mBoundsAreValid = true;
 
   LayoutDeviceIntSize size = GdkRectToDevicePixels(*aAllocation).Size();
   if (mBounds.Size() == size) {
     LOG(("  Already the same size"));
     // We were already resized at nsWindow::OnConfigureEvent() so skip it.
     return;
   }