[Pkg-mozext-commits] [firetray] 110/399: successful interception of _NET_WM_STATE_HIDDEN for minimize event interception (WORK IN PROGRESS)

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:23 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 0ade38b267a354fcd93dd9873459259878e2a381
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Wed Dec 14 16:29:24 2011 +0100

    successful interception of _NET_WM_STATE_HIDDEN
    for minimize event interception (WORK IN PROGRESS)
---
 src/modules/FiretrayIconLinux.jsm |   42 +++++++++++++++++--------------------
 src/modules/x11.jsm               |   14 +------------
 2 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/src/modules/FiretrayIconLinux.jsm b/src/modules/FiretrayIconLinux.jsm
index c954266..163807a 100644
--- a/src/modules/FiretrayIconLinux.jsm
+++ b/src/modules/FiretrayIconLinux.jsm
@@ -273,12 +273,11 @@ firetray.IconLinux = {
         let actual_format = new ctypes.int;
         let nitems = new ctypes.unsigned_long;
         let bytes_after = new ctypes.unsigned_long;
-        let prop_value = new x11.xpropArray_t;
+        let prop_value = new ctypes.unsigned_char.ptr;
 
-        // look for _NET_WM_STATE_HIDDEN (408)
-        let bufSize = ctypes.long(XPROP_MAX_COUNT*XPROP_BASE_TYPE_LONG_PROPORTION*XPROP_BASE_TYPE.size); // cast not necessary
-        let offset = ctypes.long(0);
-        let res = x11.XGetWindowProperty( // FIXME: needs to be XFree'd
+        let bufSize = XATOMS_EWMH_WM_STATES.length*ctypes.unsigned_long.size;
+        let offset = 0;
+        let res = x11.XGetWindowProperty(
           x11.current.Display, xwin, prop, offset, bufSize, 0, x11.AnyPropertyType,
           actual_type.address(), actual_format.address(), nitems.address(), bytes_after.address(), prop_value.address());
         LOG("XGetWindowProperty res="+res+", actual_type="+actual_type.value+", actual_format="+actual_format.value+", bytes_after="+bytes_after.value+", nitems="+nitems.value);
@@ -293,26 +292,23 @@ firetray.IconLinux = {
         }
 
         LOG("prop_value="+prop_value+", size="+prop_value.constructor.size);
-        // LOG("prop_value.str="+prop_value.readString());
         /* If the returned format is 32, the property data will be stored as an
          array of longs (which in a 64-bit application will be 64-bit values
          that are padded in the upper 4 bytes). [man XGetWindowProperty] */
-        if (actual_format.value == 32) {
-          var props = ctypes.cast(prop_value, ctypes.unsigned_long.array(nitems.value));
+        if (actual_format.value === 32) {
+          LOG("format OK");
+          var props = ctypes.cast(prop_value, ctypes.unsigned_long.array(nitems.value).ptr);
         } else
           ERROR("unsupported format: "+actual_format.value);
         LOG("props="+props+", size="+props.constructor.size);
-        LOG("props.length="+props.length);
-        // LOG("props.source="+props[0].toSource());
-        // LOG("props.hi="+ctypes.UInt64.hi(props[0]));
-        // LOG("props.lo="+ctypes.UInt64.lo(props[0]));
-
-        // for (let i=0; i<nitems.value; ++i) {
-        //   // LOG(props[i]);
-        //   // let p = props[i];
-        //   // let p_ulong = ctypes.cast(p, ctypes.unsigned_long);
-        //   // LOG(p_ulong);
-        // }
+
+        for (let i=0; i<nitems.value; ++i) {
+          LOG(props.contents[i]);
+          if (strEquals(props.contents[i], x11.current.Atoms._NET_WM_STATE_HIDDEN))
+            LOG("window hidden");
+        }
+
+        x11.XFree(prop_value);
 
         break;
 
@@ -320,10 +316,10 @@ firetray.IconLinux = {
         LOG("ClientMessage");
         let xclient = ctypes.cast(xev, x11.XClientMessageEvent.ptr);
         LOG("xclient.contents.data="+xclient.contents.data);
-        if (strEquals(xclient.contents.data[0], x11.current.Atoms.WM_DELETE_WINDOW)) {
-          LOG("Delete Window prevented");
-          return gdk.GDK_FILTER_REMOVE;
-        }
+        // if (strEquals(xclient.contents.data[0], x11.current.Atoms.WM_DELETE_WINDOW)) {
+        //   LOG("Delete Window prevented");
+        //   return gdk.GDK_FILTER_REMOVE;
+        // }
         LOG("xclient.contents.send_event="+xclient.contents.send_event);
         if (strEquals(xclient.contents.send_event, x11.current.Atoms.WM_CHANGE_STATE))
           LOG("FOUDIL");
diff --git a/src/modules/x11.jsm b/src/modules/x11.jsm
index 2283d0b..7198c15 100644
--- a/src/modules/x11.jsm
+++ b/src/modules/x11.jsm
@@ -35,12 +35,6 @@ const XATOMS_EWMH_WM_STATES =  [
 ];
 const XATOMS = XATOMS_ICCCM.concat(XATOMS_EWMH_WM_STATES).concat(XATOMS_EWMH_GENERAL);
 
-/* needed for XGetWindowProperty: we need to use a fixed sized array for ctypes
-   casting */
-const XPROP_MAX_COUNT = XATOMS_EWMH_WM_STATES.length;
-const XPROP_BASE_TYPE = ctypes.unsigned_char;
-const XPROP_BASE_TYPE_LONG_PROPORTION = ctypes.unsigned_long.size / XPROP_BASE_TYPE.size;
-
 
 function x11_defines(lib) {
   /* fundamental types need to be guessed :-( */
@@ -114,15 +108,9 @@ function x11_defines(lib) {
     { "state": ctypes.int }     /* NewValue or Deleted */
   ]);
 
-  // custom type needed for XGetWindowProperty
-  this.xpropArray_t = XPROP_BASE_TYPE.array(XPROP_MAX_COUNT*XPROP_BASE_TYPE_LONG_PROPORTION);
-
   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
-  // int XGetWindowProperty(
-  //  Display *display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type,
-  //  Atom *actual_type_return, int *actual_format_return, unsigned long *nitems_return, unsigned long *bytes_after_return, unsigned char **prop_return);
-  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, XPROP_BASE_TYPE.array(XPROP_MAX_COUNT*XPROP_BASE_TYPE_LONG_PROPORTION).ptr);
+  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);
   lib.lazy_bind("XChangeProperty", ctypes.int, this.Display.ptr, this.Window, this.Atom, this.Atom, ctypes.int, ctypes.int, ctypes.unsigned_char.ptr, ctypes.int);
 }
 

-- 
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