42 #include <nsComponentManagerUtils.h>
43 #include <nsIInterfaceRequestor.h>
44 #include <nsIInterfaceRequestorUtils.h>
45 #include <nsIWebNavigation.h>
46 #include <nsIDocShellTreeItem.h>
47 #include <nsIDocShellTreeOwner.h>
48 #include <nsIXULWindow.h>
49 #include <nsIWindowUtil.h>
50 #include <nsIDocShell.h>
51 #include <nsIBaseWindow.h>
60 nsWindowUtil::~nsWindowUtil()
68 NS_IMETHODIMP nsWindowUtil::GetHidden(PRBool *aHidden)
70 NS_ENSURE_ARG(aHidden);
71 if (!
mGDKWindow)
return NS_ERROR_NOT_INITIALIZED;
74 *aHidden = isVisible ? PR_FALSE : PR_TRUE;
82 NS_WARNING(
"nsWindowUtil::Init()");
83 printf(
"nsWindowUtil::Init: %08x\n",
84 reinterpret_cast<PRUint32>(aDOMWindow) );
86 NS_ENSURE_ARG(aDOMWindow);
88 return NS_ERROR_ALREADY_INITIALIZED;
95 rv = GetDocShell(getter_AddRefs(docShell));
96 NS_ENSURE_SUCCESS(rv, rv);
97 nsCOMPtr<nsIBaseWindow> baseWindow( do_QueryInterface(docShell, &rv) );
98 NS_ENSURE_SUCCESS(rv, rv);
99 nativeWindow theNativeWindow;
100 rv = baseWindow->GetParentNativeWindow( &theNativeWindow );
101 NS_ENSURE_SUCCESS(rv, rv);
103 GdkWindow *gdkWindow = nsnull;
104 gdkWindow =
reinterpret_cast<GdkWindow*
>(theNativeWindow);
105 NS_ENSURE_TRUE(gdkWindow, NS_ERROR_UNEXPECTED);
106 NS_ENSURE_TRUE(GDK_IS_WINDOW(gdkWindow), NS_ERROR_INVALID_ARG);
110 mGDKWindow = gdk_window_get_toplevel(gdkWindow);
111 NS_ENSURE_TRUE(
mGDKWindow, NS_ERROR_UNEXPECTED);
118 nsWindowUtil::GetXulWindow(nsIXULWindow **_retval)
123 nsCOMPtr<nsIInterfaceRequestor>
124 requestor(do_QueryInterface(
mDOMWindow, &rv));
125 NS_ENSURE_SUCCESS(rv, rv);
127 nsCOMPtr<nsIWebNavigation> nav;
129 getter_AddRefs(nav));
130 NS_ENSURE_SUCCESS(rv, rv);
132 nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(nav, &rv));
133 NS_ENSURE_SUCCESS(rv, rv);
135 nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
136 rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
137 NS_ENSURE_SUCCESS(rv, rv);
139 requestor = do_QueryInterface(treeOwner, &rv);
140 NS_ENSURE_SUCCESS(rv, rv);
142 return requestor->GetInterface(NS_GET_IID(nsIXULWindow), (
void **) _retval);
147 nsWindowUtil::GetDocShell(nsIDocShell **_retval)
151 rv = GetXulWindow(getter_AddRefs(xulWindow));
152 NS_ENSURE_SUCCESS(rv, rv);
154 return xulWindow->GetDocShell(_retval);
158 NS_IMETHODIMP nsWindowUtil::Minimize()
161 NS_WARNING(
"nsWindowUtil::Minimize:: not initialized");
162 return NS_ERROR_NOT_INITIALIZED;
165 printf(
"nsWindowUtil::Minimize(%08x)\n",
168 NS_ENSURE_TRUE(GDK_IS_WINDOW(
mGDKWindow), NS_ERROR_UNEXPECTED);
170 printf(
" -> hiding\n");
177 NS_IMETHODIMP nsWindowUtil::Watch()
180 NS_WARNING(
"nsWindowUtil::Watch() not implemented");
181 printf(
"this=%08x cast=%08x\n",
182 reinterpret_cast<PRUint32>(
this),
183 reinterpret_cast<PRUint32>(dynamic_cast<nsIWindowUtil*>(
this)) );
185 return NS_ERROR_NOT_IMPLEMENTED;
189 NS_IMETHODIMP nsWindowUtil::Unwatch()
192 NS_WARNING(
"nsWindowUtil::Unwatch() not implemented");
194 return NS_ERROR_NOT_IMPLEMENTED;
readonly attribute nsIXULWindow xulWindow
function isVisible(element)
readonly attribute nsIDocShell docShell
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
nsCOMPtr< nsIDOMWindow > mDOMWindow