Merge branch 'urgency'
Conflicts: src/modules/FiretrayChat.jsm src/modules/linux/FiretrayChatStatusIcon.jsm
This commit is contained in:
commit
f6508616e6
|
@ -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");
|
||||
|
||||
|
@ -112,7 +113,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,
|
||||
|
@ -130,7 +131,7 @@ firetray.Chat = {
|
|||
log.debug('startGetAttentionMaybe conv.id='+conv.id);
|
||||
|
||||
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
|
||||
|
||||
|
@ -199,7 +200,7 @@ firetray.Chat = {
|
|||
|
||||
onSelect: function(event) {
|
||||
log.debug("select event ! ");
|
||||
firetray.Chat.stopGetAttentionMaybe(firetray.Handler.findActiveWindow());
|
||||
firetray.Chat.stopGetAttentionMaybe(firetray.Handler.getActiveWindow());
|
||||
},
|
||||
|
||||
isConvCurrentlyShown: function(conv, activeWin) {
|
||||
|
@ -258,7 +259,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,7 +277,6 @@ firetray.Handler = {
|
|||
if (enabled) {
|
||||
firetray.Chat.init();
|
||||
for (let winId in firetray.Handler.windows) {
|
||||
firetray.ChatStatusIcon.attachOnFocusInCallback(winId);
|
||||
firetray.Chat.attachSelectListeners(firetray.Handler.windows[winId].chromeWin);
|
||||
}
|
||||
|
||||
|
@ -305,7 +304,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;
|
||||
},
|
||||
|
||||
|
|
|
@ -322,6 +322,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);
|
||||
|
|
|
@ -52,29 +52,6 @@ Cu.import("resource://firetray/ctypes/linux/glib.jsm");
|
|||
|
||||
function gobject_defines(lib) {
|
||||
|
||||
this.GdkEventMask = ctypes.int; // enum
|
||||
this.GDK_EXPOSURE_MASK = 1 << 1;
|
||||
this.GDK_POINTER_MOTION_MASK = 1 << 2;
|
||||
this.GDK_POINTER_MOTION_HINT_MASK = 1 << 3;
|
||||
this.GDK_BUTTON_MOTION_MASK = 1 << 4;
|
||||
this.GDK_BUTTON1_MOTION_MASK = 1 << 5;
|
||||
this.GDK_BUTTON2_MOTION_MASK = 1 << 6;
|
||||
this.GDK_BUTTON3_MOTION_MASK = 1 << 7;
|
||||
this.GDK_BUTTON_PRESS_MASK = 1 << 8;
|
||||
this.GDK_BUTTON_RELEASE_MASK = 1 << 9;
|
||||
this.GDK_KEY_PRESS_MASK = 1 << 10;
|
||||
this.GDK_KEY_RELEASE_MASK = 1 << 11;
|
||||
this.GDK_ENTER_NOTIFY_MASK = 1 << 12;
|
||||
this.GDK_LEAVE_NOTIFY_MASK = 1 << 13;
|
||||
this.GDK_FOCUS_CHANGE_MASK = 1 << 14;
|
||||
this.GDK_STRUCTURE_MASK = 1 << 15;
|
||||
this.GDK_PROPERTY_CHANGE_MASK = 1 << 16;
|
||||
this.GDK_VISIBILITY_NOTIFY_MASK = 1 << 17;
|
||||
this.GDK_PROXIMITY_IN_MASK = 1 << 18;
|
||||
this.GDK_PROXIMITY_OUT_MASK = 1 << 19;
|
||||
this.GDK_SUBSTRUCTURE_MASK = 1 << 20;
|
||||
this.GDK_SCROLL_MASK = 1 << 21;
|
||||
this.GDK_ALL_EVENTS_MASK = 0x3FFFFE;
|
||||
this.GSignalMatchType = ctypes.int; // enum
|
||||
this.G_SIGNAL_MATCH_ID = 1 << 0;
|
||||
this.G_SIGNAL_MATCH_DETAIL = 1 << 1;
|
||||
|
|
|
@ -43,7 +43,6 @@ firetray.ChatStatusIcon = {
|
|||
return o;
|
||||
})(),
|
||||
themedIconNameCurrent: null,
|
||||
signals: {'focus-in': {callback: {}, handler: {}}},
|
||||
timers: {'blink': null, 'fade-step': null, 'fade-loop': null},
|
||||
events: {},
|
||||
generators: {},
|
||||
|
@ -296,34 +295,6 @@ firetray.ChatStatusIcon = {
|
|||
|
||||
setIconTooltipDefault: function() {
|
||||
this.setIconTooltip(firetray.Handler.appName+" Chat");
|
||||
},
|
||||
|
||||
attachOnFocusInCallback: function(xid) {
|
||||
log.debug("attachOnFocusInCallback xid="+xid);
|
||||
this.signals['focus-in'].callback[xid] =
|
||||
gtk.GCallbackWidgetFocusEvent_t(firetray.ChatStatusIcon.onFocusIn);
|
||||
this.signals['focus-in'].handler[xid] = gobject.g_signal_connect(
|
||||
firetray.Handler.gtkWindows.get(xid), "focus-in-event",
|
||||
firetray.ChatStatusIcon.signals['focus-in'].callback[xid], null);
|
||||
log.debug("focus-in handler="+this.signals['focus-in'].handler[xid]);
|
||||
},
|
||||
|
||||
detachOnFocusInCallback: function(xid) {
|
||||
log.debug("detachOnFocusInCallback xid="+xid);
|
||||
let gtkWin = firetray.Handler.gtkWindows.get(xid);
|
||||
gobject.g_signal_handler_disconnect(gtkWin, this.signals['focus-in'].handler[xid]);
|
||||
delete this.signals['focus-in'].callback[xid];
|
||||
delete this.signals['focus-in'].handler[xid];
|
||||
},
|
||||
|
||||
// NOTE: fluxbox issues a FocusIn event when switching workspace
|
||||
// by hotkey, which means 2 FocusIn events when switching to a moz app :(
|
||||
// (http://sourceforge.net/tracker/index.php?func=detail&aid=3190205&group_id=35398&atid=413960)
|
||||
onFocusIn: function(widget, event, data) {
|
||||
log.debug("onFocusIn");
|
||||
let xid = firetray.Window.getXIDFromGtkWidget(widget);
|
||||
log.debug("xid="+xid);
|
||||
firetray.Chat.stopGetAttentionMaybe(xid);
|
||||
}
|
||||
|
||||
// TODO: onclick/activate -> chatHandler.showCurrentConversation()
|
||||
|
|
|
@ -58,6 +58,7 @@ firetray.Handler.gtkPopupMenuWindowItems = new ctypesMap(gtk.GtkImageMenuItem.pt
|
|||
|
||||
|
||||
firetray.Window = {
|
||||
signals: {'focus-in': {callback: {}, handler: {}}},
|
||||
|
||||
init: function() {
|
||||
let gtkVersionCheck = gtk.gtk_check_version(
|
||||
|
@ -215,8 +216,8 @@ firetray.Window = {
|
|||
return false;
|
||||
}
|
||||
|
||||
firetray.Window.detachOnFocusInCallback(xid);
|
||||
if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized) {
|
||||
firetray.ChatStatusIcon.detachOnFocusInCallback(xid);
|
||||
firetray.Chat.detachSelectListeners(firetray.Handler.windows[xid].chromeWin);
|
||||
}
|
||||
|
||||
|
@ -407,6 +408,11 @@ firetray.Window = {
|
|||
log.debug("window raised");
|
||||
},
|
||||
|
||||
setUrgency: function(xid, urgent) {
|
||||
log.debug("setUrgency: "+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
|
||||
|
@ -612,8 +618,40 @@ firetray.Window = {
|
|||
|
||||
for(var key in firetray.Handler.windows); // FIXME: this is not the proper way for finding the last registered window !
|
||||
firetray.Window.activate(key);
|
||||
}
|
||||
},
|
||||
|
||||
attachOnFocusInCallback: function(xid) {
|
||||
log.debug("attachOnFocusInCallback xid="+xid);
|
||||
this.signals['focus-in'].callback[xid] =
|
||||
gtk.GCallbackWidgetFocusEvent_t(firetray.Window.onFocusIn);
|
||||
this.signals['focus-in'].handler[xid] = gobject.g_signal_connect(
|
||||
firetray.Handler.gtkWindows.get(xid), "focus-in-event",
|
||||
firetray.Window.signals['focus-in'].callback[xid], null);
|
||||
log.debug("focus-in handler="+this.signals['focus-in'].handler[xid]);
|
||||
},
|
||||
|
||||
detachOnFocusInCallback: function(xid) {
|
||||
log.debug("detachOnFocusInCallback xid="+xid);
|
||||
let gtkWin = firetray.Handler.gtkWindows.get(xid);
|
||||
gobject.g_signal_handler_disconnect(gtkWin, this.signals['focus-in'].handler[xid]);
|
||||
delete this.signals['focus-in'].callback[xid];
|
||||
delete this.signals['focus-in'].handler[xid];
|
||||
},
|
||||
|
||||
// NOTE: fluxbox issues a FocusIn event when switching workspace
|
||||
// by hotkey, which means 2 FocusIn events when switching to a moz app :(
|
||||
// (http://sourceforge.net/tracker/index.php?func=detail&aid=3190205&group_id=35398&atid=413960)
|
||||
onFocusIn: function(widget, event, data) {
|
||||
log.debug("onFocusIn");
|
||||
let xid = firetray.Window.getXIDFromGtkWidget(widget);
|
||||
log.debug("xid="+xid);
|
||||
|
||||
firetray.Window.setUrgency(xid, false);
|
||||
|
||||
if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized) {
|
||||
firetray.Chat.stopGetAttentionMaybe(xid);
|
||||
}
|
||||
}
|
||||
|
||||
}; // firetray.Window
|
||||
|
||||
|
@ -664,8 +702,8 @@ firetray.Handler.registerWindow = function(win) {
|
|||
this.windows[xid].startupFilterCb = gdk.GdkFilterFunc_t(firetray.Window.startupFilter);
|
||||
gdk.gdk_window_add_filter(gdkWin, this.windows[xid].startupFilterCb, null);
|
||||
|
||||
firetray.Window.attachOnFocusInCallback(xid);
|
||||
if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized) {
|
||||
firetray.ChatStatusIcon.attachOnFocusInCallback(xid);
|
||||
firetray.Chat.attachSelectListeners(win);
|
||||
}
|
||||
|
||||
|
@ -724,25 +762,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