set urgency hint on all windows for new messages
This commit is contained in:
parent
91792afe0b
commit
419ac2d0f0
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue