[Pkg-mozext-commits] [firetray] 07/84: fix NOTIFYICONDATAW, NOTIFYICONDATAW_Vx_SIZE definitions
David Prévot
taffit at moszumanska.debian.org
Sun Jul 20 01:42:41 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository firetray.
commit d3584164146a916a3a6236fc3de1f6672a8d365e
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Tue Nov 19 00:35:34 2013 +0100
fix NOTIFYICONDATAW, NOTIFYICONDATAW_Vx_SIZE definitions
---
src/modules/ctypes/winnt/shell32.jsm | 28 ++++++++++++++++++++++++----
src/modules/winnt/FiretrayWindow.jsm | 17 +++++++++++++----
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/src/modules/ctypes/winnt/shell32.jsm b/src/modules/ctypes/winnt/shell32.jsm
index ed7118f..861d86c 100644
--- a/src/modules/ctypes/winnt/shell32.jsm
+++ b/src/modules/ctypes/winnt/shell32.jsm
@@ -18,7 +18,7 @@ function shell32_defines(lib) {
{ "uFlags": win32.UINT },
{ "uCallbackMessage": win32.UINT },
{ "hIcon": win32.HICON },
- { "szTip": ctypes.ArrayType(win32.TCHAR, 64) }, // 128 on win2k+
+ { "szTip": ctypes.ArrayType(win32.TCHAR, 128) },
{ "dwState": win32.DWORD },
{ "dwStateMask": win32.DWORD },
{ "szInfo": ctypes.ArrayType(win32.TCHAR, 256) },
@@ -30,9 +30,29 @@ function shell32_defines(lib) {
]);
this.NOTIFY_VERSION = 3; // 2K+
this.NOTIFYICON_VERSION_4 = 4; // Vista+
- this.NOTIFYICONDATA_V1_SIZE = 88;
- this.NOTIFYICONDATA_V2_SIZE = 488; // 2K
- this.NOTIFYICONDATA_V3_SIZE = 504; // XP
+
+ // #define FIELD_OFFSET(t,f) ((LONG)&(((t*)0)->f))
+ function FIELD_OFFSET(aType, aField, aPos) {
+ function addr2nb(a) {
+ return ctypes.cast(a, ctypes.unsigned_long).value;
+ }
+
+ // 'would be nice to use aType.ptr(1) (0 raises null pointer error) but we
+ // can't access fields (or their size) from a StructType.
+ let s = new aType();
+ let addr_base = addr2nb(s.address());
+ let addr_field;
+ if (typeof(aPos) == "undefined") {
+ addr_field = addr2nb(s.addressOfField(aField)); // s[aField].address() also fine
+ } else {
+ addr_field = addr2nb(s[aField].addressOfElement(aPos)); // pfew! nice feature!
+ }
+ return addr_field - addr_base;
+ }
+
+ this.NOTIFYICONDATAW_V1_SIZE = FIELD_OFFSET(this.NOTIFYICONDATAW, 'szTip', 64); // FIELD_OFFSET(NOTIFYICONDATAW, szTip[64])
+ this.NOTIFYICONDATAW_V2_SIZE = FIELD_OFFSET(this.NOTIFYICONDATAW, 'guidItem'); // 2K
+ this.NOTIFYICONDATAW_V3_SIZE = FIELD_OFFSET(this.NOTIFYICONDATAW, 'hBalloonIcon'); // XP
lib.lazy_bind("Shell_NotifyIconW", win32.BOOL, win32.DWORD, this.NOTIFYICONDATAW.ptr);
diff --git a/src/modules/winnt/FiretrayWindow.jsm b/src/modules/winnt/FiretrayWindow.jsm
index 70d6075..09dcfc0 100644
--- a/src/modules/winnt/FiretrayWindow.jsm
+++ b/src/modules/winnt/FiretrayWindow.jsm
@@ -118,11 +118,20 @@ firetray.Handler.registerWindow = function(win) {
}
let nid = new shell32.NOTIFYICONDATAW();
- // FIXME: We should check WINVER for NOTIFYICONDATA_*_SIZE
- nid.cbSize = shell32.NOTIFYICONDATAW.size;
- /* string is truncate to size of buffer and null-terminated. nid.szTip is
- initialized automatically by ctypes */
+ if (win32.WINVER >= win32.WIN_VERSIONS["Vista"]) {
+ nid.cbSize = shell32.NOTIFYICONDATAW.size;
+ } else if (win32.WINVER >= win32.WIN_VERSIONS["XP"]) {
+ nid.cbSize = shell32.NOTIFYICONDATAW_V3_SIZE;
+ } else if (win32.WINVER >= win32.WIN_VERSIONS["2K"]) {
+ nid.cbSize = shell32.NOTIFYICONDATAW_V2_SIZE;
+ } else {
+ nid.cbSize = shell32.NOTIFYICONDATAW_V1_SIZE;
+ }
+ log.debug("SIZE="+nid.cbSize);
+
+ // string is truncate to size of buffer and null-terminated. nid.szTip is
+ // initialized automatically by ctypes
let nMaxCount = 127;
let len = user32.GetWindowTextW(hwnd, nid.szTip, nMaxCount);
log.error("errno="+ctypes.errno+" winLastError="+ctypes.winLastError);
--
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