1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-17 22:35:02 -05:00

cleaning (Moz Bug 760802, our patch accepted into mainline 9dcd7470dc0b)

This commit is contained in:
foudfou 2012-07-27 02:12:20 +02:00
parent 3bb6d15fbc
commit 2fe1c2b687
4 changed files with 49 additions and 251 deletions

View File

@ -3,8 +3,6 @@ skin firetray classic/1.0 chrome/skin/
locale firetray en-US chrome/locale/en-US/ locale firetray en-US chrome/locale/en-US/
resource firetray modules/ resource firetray modules/
resource firetray modules/ resource firetray modules/
resource firetray-lib lib/linux/firetray_i686-gcc4.so abi=Linux_x86-gcc3
#resource firetray-lib lib/win32/addon.dll abi=WINNT_x86-msvc
overlay chrome://browser/content/browser.xul chrome://firetray/content/overlay.xul overlay chrome://browser/content/browser.xul chrome://firetray/content/overlay.xul
overlay chrome://messenger/content/messenger.xul chrome://firetray/content/overlay.xul overlay chrome://messenger/content/messenger.xul chrome://firetray/content/overlay.xul

View File

@ -12,6 +12,16 @@ LIBS += $(shell pkg-config --libs $(deps))
libs = firetray_$(platform)-gcc$(GCCVERSION).so libs = firetray_$(platform)-gcc$(GCCVERSION).so
all: $(libs) all: $(libs)
@echo
@echo add this line to chrome.manifest:
@echo -e "resource\tfiretray-lib\t\t\tlib/linux/$(libs)"
@echo
@echo and use
@echo 'Cu.import("resource://firetray/ctypes/libfiretray.jsm");'
@echo 'libfiretray.init();'
@echo '//...'
@echo 'libfiretray.shutdown();'
@echo
$(libs): firetray.o $(libs): firetray.o
$(CC) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ $(CC) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@

View File

@ -73,7 +73,7 @@ firetray.Window = {
* @param window nsIDOMWindow from Services.wm * @param window nsIDOMWindow from Services.wm
* @return a gtk.GtkWindow.ptr * @return a gtk.GtkWindow.ptr
*/ */
getGtkWindowHandle: function(window) { getGtkWindowFromChromeWindow: function(window) {
let baseWindow = window let baseWindow = window
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
@ -154,13 +154,44 @@ firetray.Window = {
return null; return null;
}, },
addrPointedByInHex: function(ptr) {
return "0x"+ctypes.cast(ptr, ctypes.uintptr_t.ptr).contents.toString(16);
},
getGdkWindowFromNativeHandle: function(nativeHandle) {
let gdkw = new gdk.GdkWindow.ptr(ctypes.UInt64(nativeHandle)); // a new pointer to the GdkWindow
F.LOG("gdkw="+gdkw+" *gdkw="+this.addrPointedByInHex(gdkw));
return gdkw;
},
getGtkWindowFromGdkWindow: function(gdkWin) {
let gptr = new gobject.gpointer;
gdk.gdk_window_get_user_data(gdkWin, gptr.address());
F.LOG("gptr="+gptr+" *gptr="+this.addrPointedByInHex(gptr));
let gtkw = ctypes.cast(gptr, gtk.GtkWindow.ptr);
let gtkw_voidp = ctypes.cast(gtkw, ctypes.void_t.ptr);
let gtkwid_top = gtk.gtk_widget_get_toplevel(ctypes.cast(gtkw, gtk.GtkWidget.ptr));
gtkw = ctypes.cast(gtkwid_top, gtk.GtkWindow.ptr);
F.LOG("gtkw="+gtkw+" *gtkw="+this.addrPointedByInHex(gtkw));
return gtkw;
},
/* consider using getXIDFromChromeWindow() if you only need the XID */ /* consider using getXIDFromChromeWindow() if you only need the XID */
getWindowsFromChromeWindow: function(win) { getWindowsFromChromeWindow: function(win) {
let gtkWin = firetray.Window.getGtkWindowHandle(win); let baseWin = firetray.Handler.getWindowInterface(win, "nsIBaseWindow");
let gdkWin = firetray.Window.getGdkWindowFromGtkWindow(gtkWin); let nativeHandle = baseWin.nativeHandle; // Moz' private pointer to the GdkWindow
F.LOG("nativeHandle="+nativeHandle);
let gtkWin, gdkWin;
if (nativeHandle) { // Gecko 17+
gdkWin = firetray.Window.getGdkWindowFromNativeHandle(nativeHandle);
gtkWin = firetray.Window.getGtkWindowFromGdkWindow(gdkWin);
} else {
gtkWin = firetray.Window.getGtkWindowFromChromeWindow(win);
gdkWin = firetray.Window.getGdkWindowFromGtkWindow(gtkWin);
}
let xid = firetray.Window.getXIDFromGdkWindow(gdkWin); let xid = firetray.Window.getXIDFromGdkWindow(gdkWin);
F.LOG("XID="+xid); F.LOG("XID="+xid);
return [gtkWin, gdkWin, xid]; return [baseWin, gtkWin, gdkWin, xid];
}, },
getXIDFromChromeWindow: function(win) { getXIDFromChromeWindow: function(win) {
@ -435,7 +466,7 @@ firetray.Window = {
getWindowTitle: function(xid) { getWindowTitle: function(xid) {
let title = firetray.Handler.windows[xid].baseWin.title; let title = firetray.Handler.windows[xid].baseWin.title;
F.LOG("baseWin.title="+title); F.LOG("|baseWin.title="+title+"|");
let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appName); let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appName);
if (tailIndex !== -1) if (tailIndex !== -1)
return title.substring(0, tailIndex); return title.substring(0, tailIndex);
@ -522,99 +553,11 @@ firetray.Handler.registerWindow = function(win) {
F.LOG("register window"); F.LOG("register window");
// register // register
let [gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win); let [baseWin, gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win);
firetray.Window.checkSubscribedEventMasks(xid);
this.windows[xid] = {}; this.windows[xid] = {};
this.windows[xid].chromeWin = win; this.windows[xid].chromeWin = win;
this.windows[xid].baseWin = firetray.Handler.getWindowInterface(win, "nsIBaseWindow"); this.windows[xid].baseWin = baseWin;
firetray.Window.checkSubscribedEventMasks(xid);
try { // TESTing nativeHandle
Cu.import("resource://firetray/ctypes/libfiretray.jsm");
libfiretray.init();
F.WARN("libfiretray available");
function addrPointedBy(ptr) {
return ctypes.cast(ptr, ctypes.uintptr_t.ptr).contents.toString(16);
}
F.WARN("TEST gdkWin="+gdkWin+" gdkWin is actually a pointer to a GdkWindow");
F.WARN("TEST *gdkWin=0x"+addrPointedBy(gdkWin));
let nativeHandle = this.windows[xid].baseWin.nativeHandle;
if ("undefined" === typeof(nativeHandle)) {
F.WARN("nativeHandle undefined");
} else {
F.WARN("TEST nativeHandle="+nativeHandle+" this is Moz' private pointer to the GdkWindow !");
// construct GdkWindow.ptr from nativeHandle
let gdkw = new gdk.GdkWindow.ptr(ctypes.UInt64(nativeHandle));
F.WARN("TEST gdkw="+gdkw+" a new pointer to a GdkWindow");
F.WARN("gdkw isGdkWin="+libfiretray.gdk_is_window(ctypes.cast(gdkw, ctypes.void_t.ptr)));
// check
if (firetray.js.strEquals(addrPointedBy(gdkWin), addrPointedBy(gdkw)))
F.WARN("OK: check");
else
F.WARN("NOT OK: check");
F.WARN("gdkWin="+gdkWin+" gdkw="+gdkw+" *gdkWin=0x"+addrPointedBy(gdkWin).toString(16)+" *gdkw=0x"+addrPointedBy(gdkw).toString(16));
// gdk.gdk_window_set_title(gdkw, "FOUDIL WAS HERE");
// getting the GtkWin from GdkWindow user_data
F.WARN("TEST *gtkWin=0x"+addrPointedBy(gtkWin)+" = REFERENCE");
let gptr = new gobject.gpointer;
gdk.gdk_window_get_user_data(gdkWin, gptr.address());
F.WARN("\nTEST gptr-gdkWin="+gptr);
F.WARN("TEST *gptr-gdkWin=0x"+addrPointedBy(gptr));
gdk.gdk_window_get_user_data(gdkw, gptr.address());
F.WARN("\nTEST gptr-gdkw="+gptr);
F.WARN("TEST *gptr-gdkw=0x"+addrPointedBy(gptr));
let gtkw = ctypes.cast(gptr, gtk.GtkWindow.ptr);
let gtkw_voidp = ctypes.cast(gtkw, ctypes.void_t.ptr);
F.WARN("gtkw isGtkWin="+libfiretray.gtk_is_window(gtkw_voidp));
F.WARN("gtkw isGtkWid="+libfiretray.gtk_is_widget(gtkw_voidp));
let gtkwid_top = gtk.gtk_widget_get_toplevel(ctypes.cast(gtkw, gtk.GtkWidget.ptr));
F.WARN("gtkwid_top="+gtkwid_top);
gtkw = ctypes.cast(gtkwid_top, gtk.GtkWindow.ptr);
F.WARN("gtkw isGtkWin="+libfiretray.gtk_is_window(ctypes.cast(gtkw, ctypes.void_t.ptr)));
if (firetray.js.strEquals(addrPointedBy(gtkWin), addrPointedBy(gtkw)))
F.WARN("OK: gtk");
else
F.WARN("NOT OK: gtk");
gtk.gtk_window_set_decorated(gtkw, false);
libfiretray.shutdown();
F.WARN("OK");
}
} catch (x) {F.ERROR(x);}
// *** WARN firetray: libfiretray available
// *** WARN firetray: TEST gdkWin=GdkWindow.ptr(ctypes.UInt64("0xa1d2830")) gdkWin is actually a pointer to a GdkWindow
// *** WARN firetray: TEST *gdkWin=0x9f5df00
// *** WARN firetray: TEST nativeHandle=0x9f63440 this is Moz' private pointer to the GdkWindow !
// *** WARN firetray: TEST gdkw=GdkWindow.ptr(ctypes.UInt64("0x9f63440")) a new pointer to a GdkWindow
// *** WARN firetray: gdkw isGdkWin=1
// *** WARN firetray: OK: check
// *** WARN firetray: gdkWin=GdkWindow.ptr(ctypes.UInt64("0xa1d2830")) gdkw=GdkWindow.ptr(ctypes.UInt64("0x9f63440")) *gdkW
// in=0x9f5df00 *gdkw=0x9f5df00
// *** WARN firetray: TEST *gtkWin=0xa17bd18 = REFERENCE
// *** WARN firetray:
// TEST gptr-gdkWin=ctypes.voidptr_t(ctypes.UInt64("0xa1d28e0"))
// *** WARN firetray: TEST *gptr-gdkWin=0xa17bd18
// *** WARN firetray:
// TEST gptr-gdkw=ctypes.voidptr_t(ctypes.UInt64("0x9f5d168"))
// *** WARN firetray: TEST *gptr-gdkw=0xabe8b00
// *** WARN firetray: gtkw isGtkWin=0
// *** WARN firetray: gtkw isGtkWid=1
// *** WARN firetray: gtkwid_top=GtkWidget.ptr(ctypes.UInt64("0xa1d28e0"))
// *** WARN firetray: gtkw isGtkWin=1
// *** WARN firetray: OK
try { try {
this.gtkWindows.insert(xid, gtkWin); this.gtkWindows.insert(xid, gtkWin);
this.gdkWindows.insert(xid, gdkWin); this.gdkWindows.insert(xid, gdkWin);

View File

@ -1,153 +0,0 @@
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4860,6 +4860,13 @@
}
NS_IMETHODIMP
+nsDocShell::GetNativeHandle(JSContext *cx, jsval *ret)
+{
+ NS_ASSERTION(false, "Not Yet Implemented: nsDocShell");
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
nsDocShell::GetVisibility(bool * aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -584,6 +584,14 @@
}
NS_IMETHODIMP
+nsDocShellTreeOwner::GetNativeHandle(JSContext *cx, jsval *ret)
+{
+ //XXX First Check In
+ NS_ASSERTION(false, "You can't call this: nsDocShellTreeOwner");
+ return NS_ERROR_NULL_POINTER;
+}
+
+NS_IMETHODIMP
nsDocShellTreeOwner::GetVisibility(bool* aVisibility)
{
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -7,6 +7,7 @@
#include "nsWebBrowser.h"
// Helper Classes
+#include "nsDOMJSUtils.h" //XXX for jsval
#include "nsGfxCIID.h"
#include "nsWidgetsCID.h"
@@ -1380,6 +1381,13 @@
return NS_OK;
}
+NS_IMETHODIMP nsWebBrowser::GetNativeHandle(JSContext *cx, jsval *ret)
+{
+ //XXX First Check In
+ NS_ASSERTION(false, "Not Yet Implemented");
+ return NS_OK;
+}
+
NS_IMETHODIMP nsWebBrowser::GetVisibility(bool* visibility)
{
NS_ENSURE_ARG_POINTER(visibility);
diff --git a/widget/nsIBaseWindow.idl b/widget/nsIBaseWindow.idl
--- a/widget/nsIBaseWindow.idl
+++ b/widget/nsIBaseWindow.idl
@@ -153,6 +153,14 @@
attribute nativeWindow parentNativeWindow;
/*
+ TODO:
+ https://bugzilla.mozilla.org/show_bug.cgi?id=760802
+ https://groups.google.com/d/msg/mozilla.dev.extensions/JXgOCHSK0ZU/bR5A2ZCZV3sJ
+ */
+ // readonly attribute jsval nativeHandle;
+ [implicit_jscontext] readonly attribute jsval nativeHandle;
+
+ /*
Attribute controls the visibility of the object behind this interface.
Setting this attribute to false will hide the control. Setting it to
true will show it.
diff --git a/xpfe/appshell/src/nsChromeTreeOwner.cpp b/xpfe/appshell/src/nsChromeTreeOwner.cpp
--- a/xpfe/appshell/src/nsChromeTreeOwner.cpp
+++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp
@@ -9,6 +9,7 @@
#include "nsXULWindow.h"
// Helper Classes
+#include "nsDOMJSUtils.h" //XXX for jsval
#include "nsString.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIEmbeddingSiteWindow2.h"
@@ -423,6 +424,12 @@
return NS_ERROR_NOT_IMPLEMENTED;
}
+NS_IMETHODIMP nsChromeTreeOwner::GetNativeHandle(JSContext *cx, jsval *ret)
+{
+ NS_ENSURE_STATE(mXULWindow);
+ return mXULWindow->GetNativeHandle(cx, ret);
+}
+
NS_IMETHODIMP nsChromeTreeOwner::GetVisibility(bool* aVisibility)
{
NS_ENSURE_STATE(mXULWindow);
diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp
--- a/xpfe/appshell/src/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/src/nsContentTreeOwner.cpp
@@ -10,6 +10,7 @@
#include "nsXULWindow.h"
// Helper Classes
+#include "nsDOMJSUtils.h" //XXX for jsval
#include "nsIServiceManager.h"
#include "nsAutoPtr.h"
@@ -637,6 +638,12 @@
return NS_ERROR_NOT_IMPLEMENTED;
}
+NS_IMETHODIMP nsContentTreeOwner::GetNativeHandle(JSContext *cx, jsval *ret)
+{
+ NS_ENSURE_STATE(mXULWindow);
+ return mXULWindow->GetNativeHandle(cx, ret);
+}
+
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(bool* aVisibility)
{
NS_ENSURE_STATE(mXULWindow);
diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp
--- a/xpfe/appshell/src/nsXULWindow.cpp
+++ b/xpfe/appshell/src/nsXULWindow.cpp
@@ -748,6 +748,23 @@
return NS_OK;
}
+NS_IMETHODIMP nsXULWindow::GetNativeHandle(JSContext *cx, jsval *ret)
+{
+ nsCOMPtr<nsIWidget> mainWidget;
+ NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(mainWidget)), NS_ERROR_FAILURE);
+
+ if (mainWidget) {
+ // this will return the actual address of the native window obj (not a
+ // pointer to it)
+ nativeWindow nativeWindowPtr = mainWidget->GetNativeData(NS_NATIVE_WINDOW);
+ uintptr_t ptr = *static_cast<uintptr_t*>(nativeWindowPtr);
+ if (!JS_NewNumberValue(cx, (double)ptr, ret)) // JSBool
+ return NS_ERROR_UNEXPECTED;
+ }
+
+ return NS_OK;
+}
+
NS_IMETHODIMP nsXULWindow::GetVisibility(bool* aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);