Bug 1196494 - part 2: only update nsWindow client offset when _NET_FRAME_EXTENTS property actually changes. r=eihrul
authorLee Salzman <lsalzman@mozilla.com>
Fri, 09 Oct 2015 09:24:48 -0400
changeset 267147 651b3818a85116ed41d967af9fc0c5ec9b57f95a
parent 267146 29e5d93f022c179607668604e19cb643eb9df3a0
child 267148 2e9ee2819de4a8b12372cd249419120bc4cfb668
push id66402
push userarchaeopteryx@coole-files.de
push dateSun, 11 Oct 2015 16:15:00 +0000
treeherdermozilla-inbound@ee4cb52e6b15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseihrul
bugs1196494
milestone44.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 1196494 - part 2: only update nsWindow client offset when _NET_FRAME_EXTENTS property actually changes. r=eihrul
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1485,24 +1485,25 @@ nsWindow::GetClientBounds(nsIntRect &aRe
     // outer bounds, but whose width/height represent the size of the inner
     // bounds (which is messed up).
     GetBounds(aRect);
     aRect.MoveBy(GetClientOffset());
 
     return NS_OK;
 }
 
-nsIntPoint
-nsWindow::GetClientOffset()
-{
-    PROFILER_LABEL("nsWindow", "GetClientOffset", js::ProfileEntry::Category::GRAPHICS);
+void
+nsWindow::UpdateClientOffset()
+{
+    PROFILER_LABEL("nsWindow", "UpdateClientOffset", js::ProfileEntry::Category::GRAPHICS);
 
     if (!mIsTopLevel || !mShell || !mGdkWindow ||
         gtk_window_get_window_type(GTK_WINDOW(mShell)) == GTK_WINDOW_POPUP) {
-        return nsIntPoint(0, 0);
+        mClientOffset = nsIntPoint(0, 0);
+        return;
     }
 
     GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
 
     GdkAtom type_returned;
     int format_returned;
     int length_returned;
     long *frame_extents;
@@ -1513,27 +1514,49 @@ nsWindow::GetClientOffset()
                           0, // offset
                           4*4, // length
                           FALSE, // delete
                           &type_returned,
                           &format_returned,
                           &length_returned,
                           (guchar **) &frame_extents) ||
         length_returned/sizeof(glong) != 4) {
-
-        return nsIntPoint(0, 0);
+        mClientOffset = nsIntPoint(0, 0);
+        return;
     }
 
     // data returned is in the order left, right, top, bottom
     int32_t left = int32_t(frame_extents[0]);
     int32_t top = int32_t(frame_extents[2]);
 
     g_free(frame_extents);
 
-    return nsIntPoint(left, top);
+    mClientOffset = nsIntPoint(left, top);
+}
+
+nsIntPoint
+nsWindow::GetClientOffset()
+{
+    return mClientOffset;
+}
+
+gboolean
+nsWindow::OnPropertyNotifyEvent(GtkWidget* aWidget, GdkEventProperty* aEvent)
+
+{
+  if (aEvent->atom == gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE)) {
+    UpdateClientOffset();
+    return FALSE;
+  }
+
+  if (GetCurrentTimeGetter()->PropertyNotifyHandler(aWidget, aEvent)) {
+    return TRUE;
+  }
+
+  return FALSE;
 }
 
 NS_IMETHODIMP
 nsWindow::SetCursor(nsCursor aCursor)
 {
     // if we're not the toplevel window pass up the cursor request to
     // the toplevel window to handle it.
     if (!mContainer && mGdkWindow) {
@@ -5742,18 +5765,17 @@ key_release_event_cb(GtkWidget *widget, 
 
 static gboolean
 property_notify_event_cb(GtkWidget* aWidget, GdkEventProperty* aEvent)
 {
     nsRefPtr<nsWindow> window = get_window_for_gdk_window(aEvent->window);
     if (!window)
         return FALSE;
 
-    CurrentX11TimeGetter* currentTimeGetter = window->GetCurrentTimeGetter();
-    return currentTimeGetter->PropertyNotifyHandler(aWidget, aEvent);
+    return window->OnPropertyNotifyEvent(aWidget, aEvent);
 }
 
 static gboolean
 scroll_event_cb(GtkWidget *widget, GdkEventScroll *event)
 {
     nsWindow *window = GetFirstNSWindowForGDKWindow(event->window);
     if (!window)
         return FALSE;
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -200,16 +200,18 @@ public:
     void               OnDragDataReceivedEvent(GtkWidget       *aWidget,
                                                GdkDragContext  *aDragContext,
                                                gint             aX,
                                                gint             aY,
                                                GtkSelectionData*aSelectionData,
                                                guint            aInfo,
                                                guint            aTime,
                                                gpointer         aData);
+    gboolean           OnPropertyNotifyEvent(GtkWidget *aWidget,
+                                             GdkEventProperty *aEvent);
 
     virtual already_AddRefed<mozilla::gfx::DrawTarget>
                        StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) override;
     virtual void       EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget,
                                                 nsIntRegion& aInvalidRegion) override;
 
 private:
     void               UpdateAlpha(gfxPattern* aPattern, nsIntRect aBoundsRect);
@@ -221,16 +223,18 @@ private:
     void               NativeShow  (bool    aAction);
     void               SetHasMappedToplevel(bool aState);
     mozilla::LayoutDeviceIntSize GetSafeWindowSize(mozilla::LayoutDeviceIntSize aSize);
 
     void               EnsureGrabs  (void);
     void               GrabPointer  (guint32 aTime);
     void               ReleaseGrabs (void);
 
+    void               UpdateClientOffset();
+
 public:
     enum PluginType {
         PluginType_NONE = 0,   /* do not have any plugin */
         PluginType_XEMBED,     /* the plugin support xembed */
         PluginType_NONXEMBED   /* the plugin does not support xembed */
     };
 
     void               SetPluginType(PluginType aPluginType);
@@ -385,16 +389,18 @@ private:
                         mIsFullyObscured : 1,
                         mRetryPointerGrab : 1;
     nsSizeMode          mSizeState;
     PluginType          mPluginType;
 
     int32_t             mTransparencyBitmapWidth;
     int32_t             mTransparencyBitmapHeight;
 
+    nsIntPoint          mClientOffset;
+
 #if GTK_CHECK_VERSION(3,4,0)
     // This field omits duplicate scroll events caused by GNOME bug 726878.
     guint32             mLastScrollEventTime;
 #endif
 
 #ifdef MOZ_X11
     Display*            mXDisplay;
     Drawable            mXWindow;