From c00d69b1ad752e20ea238cd4794a4262b66ab4ee Mon Sep 17 00:00:00 2001 From: foudfou Date: Wed, 14 Dec 2011 17:07:22 +0100 Subject: [PATCH] refactoring --- src/modules/FiretrayIconLinux.jsm | 113 +++++++++++++++--------------- src/modules/x11.jsm | 1 + 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/src/modules/FiretrayIconLinux.jsm b/src/modules/FiretrayIconLinux.jsm index 163807a..88ced89 100644 --- a/src/modules/FiretrayIconLinux.jsm +++ b/src/modules/FiretrayIconLinux.jsm @@ -248,6 +248,54 @@ firetray.IconLinux = { return null; }, + checkXWindowEWMState: function(xwin, prop) { + LOG("prop="+prop); + + // infos returned by XGetWindowProperty() + let actual_type = new x11.Atom; + let actual_format = new ctypes.int; + let nitems = new ctypes.unsigned_long; + let bytes_after = new ctypes.unsigned_long; + let prop_value = new ctypes.unsigned_char.ptr; + + let bufSize = XATOMS_EWMH_WM_STATES.length*ctypes.unsigned_long.size; + let offset = 0; + let res = x11.XGetWindowProperty( + x11.current.Display, xwin, x11.current.Atoms._NET_WM_STATE, 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); + + if (!strEquals(res, x11.Success)) { + ERROR("XGetWindowProperty failed"); + return false; + } + if (strEquals(actual_type.value, x11.None)) { + WARN("property does not exist"); + return false; + } + + LOG("prop_value="+prop_value+", size="+prop_value.constructor.size); + /* 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) { + 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); + + for (let i=0; i