[Pkg-mozext-commits] [firetray] 380/399: set urgency hint on all windows for new messages
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:24:18 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 419ac2d0f03ec6f7000614c9af4099343717d8ea
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Mon Jul 22 17:23:33 2013 +0200
set urgency hint on all windows for new messages
---
src/modules/FiretrayChat.jsm | 11 +++++----
src/modules/FiretrayHandler.jsm | 2 +-
src/modules/FiretrayMessaging.jsm | 13 ++++++----
src/modules/ctypes/linux/gdk.jsm | 1 +
src/modules/linux/FiretrayChatStatusIcon.jsm | 4 ----
src/modules/linux/FiretrayWindow.jsm | 33 +++++++++++---------------
6 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/src/modules/FiretrayChat.jsm b/src/modules/FiretrayChat.jsm
index d1aea37..a8624e7 100644
--- a/src/modules/FiretrayChat.jsm
+++ b/src/modules/FiretrayChat.jsm
@@ -9,6 +9,7 @@ const Cu = Components.utils;
Cu.import("resource:///modules/imServices.jsm");
Cu.import("resource://firetray/commons.js");
Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
+Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
let log = firetray.Logging.getLogger("firetray.Chat");
@@ -106,7 +107,7 @@ firetray.Chat = {
log.debug("unread-im-count-changed");
let unreadMsgCount = data;
if (unreadMsgCount == 0)
- this.stopGetAttentionMaybe(firetray.Handler.findActiveWindow());
+ this.stopGetAttentionMaybe(firetray.Handler.getActiveWindow());
let localizedTooltip = PluralForm.get(
unreadMsgCount,
@@ -125,7 +126,7 @@ firetray.Chat = {
if (this.shouldAcknowledgeConvs.ids[conv.id]) return; // multiple messages
let convIsCurrentlyShown =
- this.isConvCurrentlyShown(conv, firetray.Handler.findActiveWindow());
+ this.isConvCurrentlyShown(conv, firetray.Handler.getActiveWindow());
log.debug("convIsCurrentlyShown="+convIsCurrentlyShown);
if (convIsCurrentlyShown) return; // don't blink when conv tab already on top
@@ -161,14 +162,14 @@ firetray.Chat = {
if(this.shouldAcknowledgeConvs.length() === 0) {
log.debug("do stop icon blinking !!!");
- firetray.ChatStatusIcon.setUrgency(xid, false);
+ firetray.Window.setUrgency(xid, false);
firetray.ChatStatusIcon.stopIconBlinking();
}
},
onSelect: function(event) {
log.debug("select event ! ");
- firetray.Chat.stopGetAttentionMaybe(firetray.Handler.findActiveWindow());
+ firetray.Chat.stopGetAttentionMaybe(firetray.Handler.getActiveWindow());
},
isConvCurrentlyShown: function(conv, activeWin) {
@@ -227,7 +228,7 @@ firetray.Chat = {
continue;
/* item.conv is only initialized if chat tab is open */
if (item.hasOwnProperty('conv') && item.conv.target === conv) {
- firetray.ChatStatusIcon.setUrgency(xid, true);
+ firetray.Window.setUrgency(xid, true);
break;
}
}
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index b6a4c01..ea59ec4 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -305,7 +305,7 @@ firetray.Handler = {
showWindow: function(winId) {},
showHideAllWindows: function() {},
activateLastWindowCb: function(gtkStatusIcon, gdkEvent, userData) {},
- findActiveWindow: function() {},
+ getActiveWindow: function() {},
showAllWindows: function() {
log.debug("showAllWindows");
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 05780f8..d58945b 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -165,13 +165,17 @@ firetray.Messaging = {
if (!this.initialized) return;
if ("undefined" === typeof(callback) || !callback)
- callback = function(msgCountChanged, newMsgCount) { // default
+ callback = function(currentMsgCount, newMsgCount) { // default
firetray.Messaging.updateIcon(newMsgCount);
- if (msgCountChanged) {
+ if (newMsgCount !== currentMsgCount) {
let mailChangeTriggerFile = firetray.Utils.prefService.getCharPref("mail_change_trigger");
if (mailChangeTriggerFile)
firetray.Messaging.runProcess(mailChangeTriggerFile, [newMsgCount.toString()]);
+
+ if (newMsgCount > currentMsgCount)
+ for (let winId in firetray.Handler.windows)
+ firetray.Window.setUrgency(winId, true);
}
};
@@ -184,8 +188,9 @@ firetray.Messaging = {
} else
log.error('unknown message count type');
- let msgCountChanged = (this.newMsgCount !== this.currentMsgCount);
- callback.call(this, msgCountChanged, this.newMsgCount);
+ /* currentMsgCount and newMsgCount may be integers or bool, which do
+ also support comparaison operations */
+ callback.call(this, this.currentMsgCount, this.newMsgCount);
this.currentMsgCount = this.newMsgCount;
},
diff --git a/src/modules/ctypes/linux/gdk.jsm b/src/modules/ctypes/linux/gdk.jsm
index b665499..4f0b302 100644
--- a/src/modules/ctypes/linux/gdk.jsm
+++ b/src/modules/ctypes/linux/gdk.jsm
@@ -319,6 +319,7 @@ function gdk_defines(lib) {
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_screen_get_active_window", this.GdkWindow.ptr, this.GdkScreen.ptr);
lib.lazy_bind("gdk_display_get_n_screens", gobject.gint, this.GdkDisplay.ptr);
lib.lazy_bind("gdk_display_get_screen", this.GdkScreen.ptr, this.GdkDisplay.ptr, gobject.gint);
diff --git a/src/modules/linux/FiretrayChatStatusIcon.jsm b/src/modules/linux/FiretrayChatStatusIcon.jsm
index 6881ca6..0e44dd5 100644
--- a/src/modules/linux/FiretrayChatStatusIcon.jsm
+++ b/src/modules/linux/FiretrayChatStatusIcon.jsm
@@ -105,10 +105,6 @@ firetray.ChatStatusIcon = {
this.on = false;
},
- setUrgency: function(xid, urgent) {
- gtk.gtk_window_set_urgency_hint(firetray.Handler.gtkWindows.get(xid), urgent);
- },
-
setIconTooltip: function(txt) {
if (!this.trayIcon) return false;
gtk.gtk_status_icon_set_tooltip_text(this.trayIcon, txt);
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index eae4f0c..3546a93 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -407,6 +407,10 @@ firetray.Window = {
log.debug("window raised");
},
+ setUrgency: function(xid, urgent) {
+ gtk.gtk_window_set_urgency_hint(firetray.Handler.gtkWindows.get(xid), urgent);
+ },
+
/**
* YOU MUST x11.XFree() THE VARIABLE RETURNED BY THIS FUNCTION
* @param xwin: a x11.Window
@@ -553,6 +557,9 @@ firetray.Window = {
firetray.Window.updateVisibility(xid, true);
log.debug("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
}
+
+ if (xid === firetray.Handler.getActiveWindow())
+ firetray.Window.setUrgency(xid, false);
break;
case x11.UnmapNotify: // for catching 'iconify'
@@ -724,25 +731,13 @@ firetray.Handler.activateLastWindowCb = function(gtkStatusIcon, gdkEvent, userDa
};
/* NOTE: gtk_window_is_active() not reliable, and _NET_ACTIVE_WINDOW may not
- always be set before 'focus-in-event' (gnome-shell/mutter 3.4.1) */
-firetray.Handler.findActiveWindow = function() {
- let rootWin = x11.XDefaultRootWindow(x11.current.Display);
- let [propsFound, nitems] =
- firetray.Window.getXWindowProperties(rootWin, x11.current.Atoms._NET_ACTIVE_WINDOW);
-
- log.debug("ACTIVE_WINDOW propsFound, nitems="+propsFound+", "+nitems);
- if (!propsFound) return null;
-
- let activeWin = null;
- if (firetray.js.strEquals(nitems.value, 0))
- log.warn("active window not found");
- else if (firetray.js.strEquals(nitems.value, 1))
- activeWin = propsFound.contents[0];
- else
- throw new RangeError("more than one active window found");
-
- x11.XFree(propsFound);
-
+ always be set before 'focus-in-event' (gnome-shell/mutter 3.4.1). */
+firetray.Handler.getActiveWindow = function() {
+ let gdkActiveWin = gdk.gdk_screen_get_active_window(gdk.gdk_screen_get_default()); // inspects _NET_ACTIVE_WINDOW
+ log.debug("gdkActiveWin="+gdkActiveWin);
+ if (firetray.js.strEquals(gdkActiveWin, 'GdkWindow.ptr(ctypes.UInt64("0x0"))'))
+ return null;
+ let activeWin = firetray.Window.getXIDFromGdkWindow(gdkActiveWin);
log.debug("ACTIVE_WINDOW="+activeWin);
return activeWin;
};
--
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