From 18fb980d49439d192f4b1252d95c9557d46864d9 Mon Sep 17 00:00:00 2001 From: foudfou Date: Mon, 15 Oct 2012 13:25:28 +0200 Subject: [PATCH] add gtk version check + revert to gdk_window_get_toplevel() --- src/modules/FiretrayHandler.jsm | 1 + src/modules/ctypes/linux/gdk.jsm | 1 + src/modules/ctypes/linux/gtk.jsm | 5 +++++ src/modules/linux/FiretrayWindow.jsm | 10 +++++++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index d579b13..ac53029 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -89,6 +89,7 @@ firetray.Handler = { VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailServerTypes); VersionChange.applyHooksAndWatchUninstall(); + firetray.Window.init(); firetray.StatusIcon.init(); firetray.Handler.showHideIcon(); log.debug('StatusIcon initialized'); diff --git a/src/modules/ctypes/linux/gdk.jsm b/src/modules/ctypes/linux/gdk.jsm index 073df19..95febfb 100644 --- a/src/modules/ctypes/linux/gdk.jsm +++ b/src/modules/ctypes/linux/gdk.jsm @@ -302,6 +302,7 @@ function gdk_defines(lib) { lib.lazy_bind("gdk_window_get_user_data", ctypes.void_t, this.GdkWindow.ptr, gobject.gpointer.ptr); lib.lazy_bind("gdk_atom_intern", this.GdkAtom, gobject.gchar.ptr, gobject.gboolean); lib.lazy_bind("gdk_property_change", ctypes.void_t, this.GdkWindow.ptr, this.GdkAtom, this.GdkAtom, gobject.gint, this.GdkPropMode, gobject.guchar.ptr, gobject.gint); + lib.lazy_bind("gdk_window_get_toplevel", this.GdkWindow.ptr, this.GdkWindow.ptr); lib.lazy_bind("gdk_window_get_effective_toplevel", this.GdkWindow.ptr, this.GdkWindow.ptr); lib.lazy_bind("gdk_display_get_n_screens", gobject.gint, this.GdkDisplay.ptr); diff --git a/src/modules/ctypes/linux/gtk.jsm b/src/modules/ctypes/linux/gtk.jsm index 0329d39..6aa3c1b 100644 --- a/src/modules/ctypes/linux/gtk.jsm +++ b/src/modules/ctypes/linux/gtk.jsm @@ -17,6 +17,10 @@ Cu.import("resource://firetray/ctypes/linux/gobject.jsm"); Cu.import("resource://firetray/ctypes/linux/pango.jsm"); function gtk_defines(lib) { + this.FIRETRAY_REQUIRED_GTK_MAJOR_VERSION = 2; + this.FIRETRAY_REQUIRED_GTK_MINOR_VERSION = 20; + this.FIRETRAY_REQUIRED_GTK_MICRO_VERSION = 0; + this.GTK_ICON_SIZE_MENU = 1; // enum GtkIconSize this.GTK_WINDOW_TOPLEVEL = 0; // enum GtkWindowType @@ -78,6 +82,7 @@ function gtk_defines(lib) { ctypes.default_abi, gobject.gboolean, [this.GtkWidget.ptr, gdk.GdkEventFocus.ptr, gobject.gpointer]).ptr; + lib.lazy_bind("gtk_check_version", gobject.gchar.ptr, gobject.guint, gobject.guint, gobject.guint); lib.lazy_bind("gtk_icon_theme_get_default", this.GtkIconTheme.ptr); lib.lazy_bind("gtk_icon_theme_get_for_screen", this.GtkIconTheme.ptr, gdk.GdkScreen.ptr); diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index 067af89..6028c52 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -60,6 +60,14 @@ firetray.Handler.gtkPopupMenuWindowItems = new ctypesMap(gtk.GtkImageMenuItem.pt firetray.Window = { init: function() { + let gtkVersionCheck = gtk.gtk_check_version( + gtk.FIRETRAY_REQUIRED_GTK_MAJOR_VERSION, + gtk.FIRETRAY_REQUIRED_GTK_MINOR_VERSION, + gtk.FIRETRAY_REQUIRED_GTK_MICRO_VERSION + ); + if (!gtkVersionCheck.isNull()) + log.error("gtk_check_version="+gtkVersionCheck.readString()); + this.initialized = true; }, @@ -157,7 +165,7 @@ firetray.Window = { getGdkWindowFromNativeHandle: function(nativeHandle) { let gdkw = new gdk.GdkWindow.ptr(ctypes.UInt64(nativeHandle)); // a new pointer to the GdkWindow - gdkw = gdk.gdk_window_get_effective_toplevel(gdkw); + gdkw = gdk.gdk_window_get_toplevel(gdkw); log.debug("gdkw="+gdkw+" *gdkw="+this.addrPointedByInHex(gdkw)); return gdkw; },