mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-10 13:08:01 -05:00
added _getGdkWindowFromGtkWindow() and illustration code
This commit is contained in:
parent
ee9a0b6089
commit
fcab487297
@ -40,7 +40,7 @@ var mozt_findGtkWindowByTitleCb;
|
||||
*/
|
||||
var _find_data_t = ctypes.StructType("_find_data_t", [
|
||||
{ inTitle: ctypes.char.ptr },
|
||||
{ outWindow: ctypes.void_t.ptr }
|
||||
{ outWindow: gtk.GtkWindow.ptr }
|
||||
]);
|
||||
|
||||
|
||||
@ -86,11 +86,6 @@ mozt.IconLinux = {
|
||||
return false;
|
||||
}
|
||||
|
||||
// // TEST
|
||||
// let win = Services.wm.getMostRecentWindow(null);
|
||||
// let gtkWin = ctypes.cast(this._getGtkWindowHandle(win), gtk.GtkWindow.ptr);
|
||||
// gtk.gtk_window_set_decorated(gtkWin, false);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
@ -138,7 +133,6 @@ mozt.IconLinux = {
|
||||
LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
|
||||
|
||||
try {
|
||||
// TODO: move to MoztIconLinux
|
||||
var gtkMenuPtr = ctypes.cast(menu, gtk.GtkMenu.ptr);
|
||||
var iconGpointer = ctypes.cast(icon, gobject.gpointer);
|
||||
gtk.gtk_menu_popup(
|
||||
@ -147,6 +141,7 @@ mozt.IconLinux = {
|
||||
} catch (x) {
|
||||
LOG(x);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setImage: function(filename) {
|
||||
@ -305,7 +300,7 @@ mozt.IconLinux = {
|
||||
*
|
||||
* @author Nils Maier (stolen from MiniTrayR)
|
||||
* @param window nsIDOMWindow from Services.wm
|
||||
* @return a ctypes.void_t.ptr to a GtkWindow
|
||||
* @return a gtk.GtkWindow.ptr
|
||||
*/
|
||||
_getGtkWindowHandle: function(window) {
|
||||
let baseWindow = window
|
||||
@ -319,7 +314,7 @@ mozt.IconLinux = {
|
||||
|
||||
try {
|
||||
// Search the window by the *temporary* title
|
||||
let tl = gtk.gtk_window_list_toplevels();
|
||||
let widgets = gtk.gtk_window_list_toplevels();
|
||||
let that = this;
|
||||
mozt_findGtkWindowByTitleCb = gobject.GFunc_t(that._findGtkWindowByTitle);
|
||||
var userData = new _find_data_t(
|
||||
@ -327,8 +322,8 @@ mozt.IconLinux = {
|
||||
null
|
||||
).address();
|
||||
LOG("userData="+userData);
|
||||
gobject.g_list_foreach(tl, mozt_findGtkWindowByTitleCb, userData);
|
||||
gobject.g_list_free(tl);
|
||||
gobject.g_list_foreach(widgets, mozt_findGtkWindowByTitleCb, userData);
|
||||
gobject.g_list_free(widgets);
|
||||
|
||||
if (userData.contents.outWindow.isNull()) {
|
||||
throw new Error("Window not found!");
|
||||
@ -368,6 +363,36 @@ mozt.IconLinux = {
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
}
|
||||
},
|
||||
|
||||
_getGdkWindowFromGtkWindow: function(gtkWin) {
|
||||
try {
|
||||
let gtkWid = ctypes.cast(gtkWin, gtk.GtkWidget.ptr);
|
||||
var gdkWin = gtk.gtk_widget_get_window(gtkWid);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
}
|
||||
return gdkWin;
|
||||
},
|
||||
|
||||
// NOTE: doesn't work during initialization probably since windows aren't
|
||||
// fully realized (?)
|
||||
testWindowHandle: function() {
|
||||
try {
|
||||
let win = Services.wm.getMostRecentWindow(null);
|
||||
let gtkWin = mozt.IconLinux._getGtkWindowHandle(win);
|
||||
LOG("FOUND: "+gtk.gtk_window_get_title(gtkWin).readString());
|
||||
gtk.gtk_window_set_decorated(gtkWin, false);
|
||||
|
||||
let gdkWin = this._getGdkWindowFromGtkWindow(gtkWin);
|
||||
if (!gdkWin.isNull()) {
|
||||
LOG("has window");
|
||||
LOG(gdk.gdk_window_get_width(gdkWin));
|
||||
gdk.gdk_window_iconify(gdkWin);
|
||||
}
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
}
|
||||
}
|
||||
|
||||
}; // mozt.IconLinux
|
||||
|
@ -142,6 +142,12 @@ function gdk_defines(lib) {
|
||||
lib.lazy_bind("gdk_pixbuf_add_alpha", this.GdkPixbuf.ptr, this.GdkPixbuf.ptr, gobject.gboolean, gobject.guchar, gobject.guchar, gobject.guchar);
|
||||
lib.lazy_bind("gdk_pixbuf_composite", ctypes.void_t, this.GdkPixbuf.ptr, this.GdkPixbuf.ptr, ctypes.int, ctypes.int, ctypes.int, ctypes.int, ctypes.double, ctypes.double, ctypes.double, ctypes.double, this.GdkInterpType, ctypes.int);
|
||||
|
||||
lib.lazy_bind("gdk_window_stick", ctypes.void_t, this.GdkWindow.ptr);
|
||||
lib.lazy_bind("gdk_window_iconify", ctypes.void_t, this.GdkWindow.ptr);
|
||||
lib.lazy_bind("gdk_window_set_title", ctypes.void_t, this.GdkWindow.ptr, gobject.gchar.ptr);
|
||||
lib.lazy_bind("gdk_window_beep", ctypes.void_t, this.GdkWindow.ptr);
|
||||
lib.lazy_bind("gdk_window_get_width", ctypes.int, this.GdkWindow.ptr);
|
||||
|
||||
}
|
||||
|
||||
if (!gdk) {
|
||||
|
@ -82,13 +82,21 @@ function gtk_defines(lib) {
|
||||
gobject.gboolean.ptr, gobject.gpointer);
|
||||
|
||||
lib.lazy_bind("gtk_window_new", this.GtkWidget.ptr, this.GtkWindowType);
|
||||
lib.lazy_bind("gtk_widget_create_pango_layout", pango.PangoLayout.ptr, this.GtkWidget.ptr, gobject.gchar.ptr);
|
||||
lib.lazy_bind("gtk_widget_create_pango_layout", pango.PangoLayout.ptr,
|
||||
this.GtkWidget.ptr, gobject.gchar.ptr);
|
||||
lib.lazy_bind("gtk_widget_destroy", ctypes.void_t, this.GtkWidget.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_from_pixbuf", ctypes.void_t, this.GtkStatusIcon.ptr, gdk.GdkPixbuf.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_from_pixbuf", ctypes.void_t,
|
||||
this.GtkStatusIcon.ptr, gdk.GdkPixbuf.ptr);
|
||||
lib.lazy_bind("gtk_window_list_toplevels", gobject.GList.ptr);
|
||||
lib.lazy_bind("gtk_window_get_title", gobject.gchar.ptr, this.GtkWindow.ptr);
|
||||
|
||||
lib.lazy_bind("gtk_window_set_decorated", ctypes.void_t, this.GtkWindow.ptr, gobject.gboolean);
|
||||
lib.lazy_bind("gtk_widget_get_has_window", gobject.gboolean,
|
||||
this.GtkWidget.ptr);
|
||||
lib.lazy_bind("gtk_widget_get_window", gdk.GdkWindow.ptr, this.GtkWidget.ptr);
|
||||
lib.lazy_bind("gtk_widget_get_parent_window", gdk.GdkWindow.ptr, this.GtkWidget.ptr);
|
||||
lib.lazy_bind("gtk_window_set_decorated", ctypes.void_t, this.GtkWindow.ptr,
|
||||
gobject.gboolean);
|
||||
|
||||
}
|
||||
|
||||
if (!gtk) {
|
||||
|
Loading…
Reference in New Issue
Block a user