[Pkg-mozext-commits] [firetray] 228/399: check window's event-masks with XGetWindowAttributes.

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:48 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch dfsg-clean
in repository firetray.

commit a1f0980b2aab0269a2654c1721018250af9d3fce
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sat Apr 21 15:27:36 2012 +0200

    check window's event-masks with XGetWindowAttributes.
    
    NOTE: if we'd need to *set* event-masks, it should be safer to do it with
    gdk.gdk_window_set_events() to preserve the gdkWindow's state.
---
 src/modules/ctypes/linux/x11.jsm     |   53 ++++++++++++++++++++++++++++++++++
 src/modules/linux/FiretrayWindow.jsm |   22 +++++++++-----
 2 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/src/modules/ctypes/linux/x11.jsm b/src/modules/ctypes/linux/x11.jsm
index c706151..d907e3f 100644
--- a/src/modules/ctypes/linux/x11.jsm
+++ b/src/modules/ctypes/linux/x11.jsm
@@ -125,6 +125,13 @@ function x11_defines(lib) {
 
   this.Bool = ctypes.int;
   this.Status = ctypes.int;
+  this.Pixmap = this.XID;
+  this.Cursor = this.XID;
+  this.Colormap = this.XID;
+  this.GContext = this.XID;
+  this.KeySym = this.XID;
+  this.Visual = ctypes.StructType("Visual");
+  this.Screen = ctypes.StructType("Screen");
   this.Display = ctypes.StructType("Display");
   // union not supported by js-ctypes
   // https://bugzilla.mozilla.org/show_bug.cgi?id=535378 "You can always
@@ -158,6 +165,50 @@ function x11_defines(lib) {
     { "state": ctypes.int }     /* NewValue or Deleted */
   ]);
 
+  this.XWindowAttributes = ctypes.StructType("XWindowAttributes", [
+    { "x": ctypes.int },
+    { "y": ctypes.int },                        /* location of window */
+    { "width": ctypes.int },
+    { "height": ctypes.int },                   /* width and height of window */
+    { "border_width": ctypes.int },             /* border width of window */
+    { "depth": ctypes.int },                    /* depth of window */
+    { "visual": this.Visual.ptr },              /* the associated visual structure */
+    { "root": this.Window },                    /* root of screen containing window */
+    { "class": ctypes.int },                    /* InputOutput, InputOnly*/
+    { "bit_gravity": ctypes.int },              /* one of bit gravity values */
+    { "win_gravity": ctypes.int },              /* one of the window gravity values */
+    { "backing_store": ctypes.int },            /* NotUseful, WhenMapped, Always */
+    { "backing_planes": ctypes.unsigned_long }, /* planes to be preserved if possible */
+    { "backing_pixel": ctypes.unsigned_long },  /* value to be used when restoring planes */
+    { "save_under": this.Bool },                /* boolean, should bits under be saved? */
+    { "colormap": this.Colormap },              /* color map to be associated with window */
+    { "map_installed": this.Bool },             /* boolean, is color map currently installed*/
+    { "map_state": ctypes.int },                /* IsUnmapped, IsUnviewable, IsViewable */
+    { "all_event_masks": ctypes.long },         /* set of events all people have interest in*/
+    { "your_event_mask": ctypes.long },         /* my event mask */
+    { "do_not_propagate_mask": ctypes.long },   /* set of events that should not propagate */
+    { "override_redirect": this.Bool },         /* boolean value for override-redirect */
+    { "screen": this.Screen.ptr }               /* back pointer to correct screen */
+  ]);
+
+  this.XSetWindowAttributes = ctypes.StructType("XSetWindowAttributes", [
+    { "background_pixmap": this.Pixmap },         /* background or None or ParentRelative */
+    { "background_pixel": ctypes.unsigned_long },	/* background pixel */
+    { "border_pixmap": this.Pixmap },             /* border of the window */
+    { "border_pixel": ctypes.unsigned_long },     /* border pixel value */
+    { "bit_gravity": ctypes.int },                /* one of bit gravity values */
+    { "win_gravity": ctypes.int },                /* one of the window gravity values */
+    { "backing_store": ctypes.int },              /* NotUseful, WhenMapped, Always */
+    { "backing_planes": ctypes.unsigned_long },   /* planes to be preseved if possible */
+    { "backing_pixel": ctypes.unsigned_long },    /* value to use in restoring planes */
+    { "save_under": this.Bool },                  /* should bits under be saved? (popups) */
+    { "event_mask": ctypes.long },                /* set of events that should be saved */
+    { "do_not_propagate_mask": ctypes.long },     /* set of events that should not propagate */
+    { "override_redirect": this.Bool },           /* boolean value for override-redirect */
+    { "colormap": this.Colormap },                /* color map to be associated with window */
+    { "cursor": this.Cursor }                     /* cursor to be displayed (or None) */
+  ]);
+
   lib.lazy_bind("XFree", ctypes.int, ctypes.void_t.ptr);
   lib.lazy_bind("XInternAtom", this.Atom, this.Display.ptr, ctypes.char.ptr, this.Bool); // only_if_exsits
   lib.lazy_bind("XGetWindowProperty", ctypes.int, this.Display.ptr, this.Window, this.Atom, ctypes.long, ctypes.long, this.Bool, this.Atom, this.Atom.ptr, ctypes.int.ptr, ctypes.unsigned_long.ptr, ctypes.unsigned_long.ptr, ctypes.unsigned_char.ptr.ptr);
@@ -165,6 +216,8 @@ function x11_defines(lib) {
   lib.lazy_bind("XDefaultRootWindow", this.Window, this.Display.ptr);
   lib.lazy_bind("XSendEvent", this.Status, this.Display.ptr, this.Window, this.Bool, ctypes.long, this.XEvent.ptr);
   lib.lazy_bind("XRaiseWindow", ctypes.int, this.Display.ptr, this.Window);
+  lib.lazy_bind("XGetWindowAttributes", this.Status, this.Display.ptr, this.Window, this.XWindowAttributes.ptr);
+  lib.lazy_bind("XChangeWindowAttributes", ctypes.int, this.Display.ptr, this.Window, ctypes.unsigned_long, this.XSetWindowAttributes.ptr);
 }
 
 new ctypes_library(X11_LIBNAME, X11_ABIS, x11_defines, this);
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index ab91f3a..1bfd942 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -466,6 +466,19 @@ firetray.Window = {
       return null;
   },
 
+  checkSubscribedEventMasks: function(xid) {
+    let xWindowAttributes = new x11.XWindowAttributes;
+    let status = x11.XGetWindowAttributes(x11.current.Display, xid, xWindowAttributes.address());
+    F.LOG("xWindowAttributes: "+xWindowAttributes);
+    let xEventMask = xWindowAttributes.your_event_mask;
+    let xEventMaskNeeded = x11.VisibilityChangeMask|x11.StructureNotifyMask|x11.PropertyChangeMask;
+    F.LOG("xEventMask="+xEventMask+" xEventMaskNeeded="+xEventMaskNeeded);
+    if ((xEventMask & xEventMaskNeeded) !== xEventMaskNeeded) {
+      F.WARN("missing mandatory event-masks");
+      // could try to subscribe here with XChangeWindowAttributes()
+    }
+  },
+
   filterWindow: function(xev, gdkEv, data) {
     if (!xev)
       return gdk.GDK_FILTER_CONTINUE;
@@ -538,14 +551,7 @@ firetray.Handler.registerWindow = function(win) {
 
   // register
   let [gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win);
-  let eventMask = gdk.gdk_window_get_events(gdkWin);
-  F.LOG(eventMask);
-  let eventMaskNeeded = gdk.GDK_STRUCTURE_MASK|gdk.GDK_PROPERTY_CHANGE_MASK|gdk.GDK_VISIBILITY_NOTIFY_MASK;
-  F.LOG(eventMaskNeeded);
-  if ((eventMask & eventMaskNeeded) !== eventMaskNeeded) {
-    F.WARN("subscribing window to missing mandatory event-masks");
-    gdk.gdk_window_set_events(gdkWin, eventMask|eventMaskNeeded);
-  }
+  firetray.Window.checkSubscribedEventMasks(xid);
   this.windows[xid] = {};
   this.windows[xid].chromeWin = win;
   this.windows[xid].baseWin = firetray.Handler.getWindowInterface(win, "nsIBaseWindow");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git



More information about the Pkg-mozext-commits mailing list