From f62f28531bce0f500ad2efba20513003fbc04f53 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Thu, 1 Dec 2011 13:56:42 -0600 Subject: [PATCH] Bug 668437. Part 6. Implement nsIWidget::GetClientOffset on GTK2. r=karlt --- widget/src/gtk2/nsWindow.cpp | 39 ++++++++++++++++++++++++++++++++++++ widget/src/gtk2/nsWindow.h | 1 + 2 files changed, 40 insertions(+) diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index d51de863e24e..f665075cf583 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -1579,6 +1579,45 @@ nsWindow::GetScreenBounds(nsIntRect &aRect) return NS_OK; } +nsIntPoint +nsWindow::GetClientOffset() +{ + if (!mIsTopLevel) { + return nsIntPoint(0, 0); + } + + GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL); + + GdkAtom type_returned; + int format_returned; + int length_returned; + long *frame_extents; + + if (!mShell || !mShell->window || + !gdk_property_get(mShell->window, + gdk_atom_intern ("_NET_FRAME_EXTENTS", FALSE), + cardinal_atom, + 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); + } + + // data returned is in the order left, right, top, bottom + PRInt32 left = PRInt32(frame_extents[0]); + PRInt32 top = PRInt32(frame_extents[2]); + + g_free(frame_extents); + + return nsIntPoint(left, top); +} + NS_IMETHODIMP nsWindow::SetForegroundColor(const nscolor &aColor) { diff --git a/widget/src/gtk2/nsWindow.h b/widget/src/gtk2/nsWindow.h index 11d75f213abf..c808488bc0ba 100644 --- a/widget/src/gtk2/nsWindow.h +++ b/widget/src/gtk2/nsWindow.h @@ -170,6 +170,7 @@ public: NS_IMETHOD Enable(bool aState); NS_IMETHOD SetFocus(bool aRaise = false); NS_IMETHOD GetScreenBounds(nsIntRect &aRect); + virtual nsIntPoint GetClientOffset(); NS_IMETHOD SetForegroundColor(const nscolor &aColor); NS_IMETHOD SetBackgroundColor(const nscolor &aColor); NS_IMETHOD SetCursor(nsCursor aCursor);