Bug 668437. Part 6. Implement nsIWidget::GetClientOffset on GTK2. r=karlt

This commit is contained in:
Timothy Nikkel 2011-12-01 13:56:42 -06:00
parent 8ce4c15a30
commit f62f28531b
2 changed files with 40 additions and 0 deletions

View File

@ -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)
{

View File

@ -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);